Author Topic: Asynchronous Proximity check on specific device  (Read 2476 times)

Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Asynchronous Proximity check on specific device
« on: March 25, 2008, 06:54:40 AM »
Hi,
 Have a nice day :)
could u pls help me in developing a sample screen lock application :(

I need to check a single paired device is in range or not.
I got simple exaples. but it automatically terminates connection after a specific time.
I need to monitor that device even after long time.
I have already tried using the RFsignal strength measurement but its not much sensitive.
pls do provide me all the possible methods to achieve the same.
Awaiting ur replies...
Thanx in advance :)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2491
  • Karma: 1000
    • Wireless Communication Library
Re: Asynchronous Proximity check on specific device
« Reply #1 on: March 25, 2008, 11:59:26 AM »
Good day!

Its easy. I'l do the sample when WCL ActiveX released (it should happen tonight)
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #2 on: March 25, 2008, 06:37:33 PM »
thanks for ur quick reply.
awaiting for WCL ActiveX release.
also please provide me another info.
whenever the specific mobile device comes within systems blutooth proximity range, some sort of data communication should takes place automatically without user interaction between the system and mobile midlet application. what type of communication method best suites this situation?
silent authentication reduces some user interaction in system application.

thanks :)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2491
  • Karma: 1000
    • Wireless Communication Library
Re: Asynchronous Proximity check on specific device
« Reply #3 on: March 25, 2008, 07:05:32 PM »
I am not sure I clean understand what do you want to do. If you need to communicate with midlet runnng on the target device then you may avoid authentication in midlet.

If you need to send data to any device then there is no way to avoid confirmation message. Authentication is not required for the sending file using object push profile.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #4 on: March 26, 2008, 04:51:30 AM »
Have a great day....  :)
awaiting for WCL ActiveX release.....
let me explain my requirement clearly. I need to create a system application using our BTFramework in VB and an another J2ME application for mobile. The system App should act as server and it should regularly watch for previously paired specific mobile wheather its within bluetooth proximity range of the system.If so then computer is unlocked along with someother activities r done. If not then the workstation is locked automatically. moreover whenever the mobile client arrives within sys's BT proximity, some sort of previously logged log file from sys should be transerred to mobile's persistant memory which should be invisible to client i,e no sort of user interaction should takes place at this scenario. n this file should be used by mobile client to display some details to user even if its not within BT proximity range of sys currently.
pls provide me some idea regarding,
What sort of communication mechanism can be used to transfer this log file to client? :)
Is it possible for a  MIDLET to access a file written by system to mobile's persistant memory? :)
Instead is there any other way to send to send some data directly to MIDLET app whenver client comes within SYS's BT range? :)
How to detect accurately in SYStem Application wheather the device is within proximity or not? :)
 Thanx


Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #5 on: March 27, 2008, 01:13:22 AM »
Have a great day....  :)
awaiting for WCL ActiveX release.....
let me explain my requirement clearly. I need to create a system application using our BTFramework in VB and an another J2ME application for mobile. The system App should act as server and it should regularly watch for previously paired specific mobile wheather its within bluetooth proximity range of the system.If so then computer is unlocked along with someother activities r done. If not then the workstation is locked automatically. moreover whenever the mobile client arrives within sys's BT proximity, some sort of previously logged log file from sys should be transerred to mobile's persistant memory which should be invisible to client i,e no sort of user interaction should takes place at this scenario. n this file should be used by mobile client to display some details to user even if its not within BT proximity range of sys currently.
pls provide me some idea regarding,
What sort of communication mechanism can be used to transfer this log file to client? :)
Is it possible for a  MIDLET to access a file written by system to mobile's persistant memory? :)
Instead is there any other way to send to send some data directly to MIDLET app whenver client comes within SYS's BT range? :)
How to detect accurately in SYStem Application wheather the device is within proximity or not? :)
 Thanx



Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2491
  • Karma: 1000
    • Wireless Communication Library
Re: Asynchronous Proximity check on specific device
« Reply #6 on: March 27, 2008, 07:12:45 AM »
Good day!

I think the PC app should work as client. Server is the phone.

All other tasks are easy to do.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline jcb871

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #7 on: March 29, 2008, 07:57:35 PM »
Hi,
I'm a friend of Kesavamoorthi...
We two are doing this program in VB n J2ME.
Pls help me in developing a basic j2me mobile app to system communication(ordinary text) program.
Can u help me in this pls :)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2491
  • Karma: 1000
    • Wireless Communication Library
Re: Asynchronous Proximity check on specific device
« Reply #8 on: March 29, 2008, 08:23:08 PM »
Somewhere on this forum the Java chat sample is available.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #9 on: March 30, 2008, 05:59:37 AM »
have a nice day  :)
I have managed to create a midlet which acts as server which publishes a service named "DeviceServerCOM". pls do provide me some codings for connecting to this service from the VB application(client) using BTFramework ActiveX component. The VB application just needs to detect the specific service from mobile device and opens a serial port communication. Then the message sent threw serial port from vb will be echoed back by the midlet to VB application. ::)
The midlet coding is shown below:

Code: [Select]
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class DeviceServerCOMM extends MIDlet {

// serial port profile
protected String UUID = new UUID("1101", true).toString();

protected int discoveryMode = DiscoveryAgent.GIAC; // no paring needed

protected int endToken = 255;

protected Form infoArea = new Form("Bluetooth Server");

protected void startApp() throws MIDletStateChangeException {
infoArea.deleteAll();
Display.getDisplay(this).setCurrent(infoArea);

try {
LocalDevice device = LocalDevice.getLocalDevice();
device.setDiscoverable(DiscoveryAgent.GIAC);

String url = "btspp://localhost:" + UUID + ";name=DeviceServerCOMM";

log("Create server by uri: " + url);
StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector
.open(url);

serverLoop(notifier);

} catch (Throwable e) {
log(e);
}
}
protected void pauseApp() {
}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
private void serverLoop(StreamConnectionNotifier notifier) {
try {
while (true) { // infinite loop to accept connections.
log("Waiting for connection...");
handleConnection(notifier.acceptAndOpen());
}
} catch (Exception e) {
log(e);
}
}
private void handleConnection(StreamConnection conn) throws IOException {
OutputStream out = conn.openOutputStream();
InputStream in = conn.openInputStream();
startReadThread(in);
try { // to write some tokens through the bluetooth link
int[] tokens = new int[] { 1, 3, 5, 7, endToken };
for (int i = 0; i < tokens.length; i++) {
out.write(tokens[i]);
out.flush();
log("write:" + tokens[i]);
// wait a sec before next write.
Thread.sleep(1 * 1000);
}
} catch (Exception e) {
log(e);
} finally {
log("Close connection.");
if (conn != null) {
try {
conn.close();
} catch (IOException e) {
}
}
}
}
private void startReadThread(final InputStream in) {
Thread reader = new Thread() {
public void run() {
try {
while (true) {
int r = in.read();
log("read:" + r);
if (r == endToken)
break;
}
} catch (Throwable e) {
log(e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
};
reader.start();
}
synchronized private void log(String msg) {
infoArea.append(msg);
infoArea.append("\n\n");
}
private void log(Throwable e) {
log(e.getMessage());
}
}

Please help :)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2491
  • Karma: 1000
    • Wireless Communication Library
Re: Asynchronous Proximity check on specific device
« Reply #10 on: March 30, 2008, 11:43:37 AM »
Take a look at Chat sample from the BTF package.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #11 on: March 30, 2008, 04:07:41 PM »
Thanks for those demo apps provided with BTF (bluechat) which  works well between two pc. But when i try to connect VB app as a client to the Midlet app which acts as server, I have some problem ::). Pls do provide me with parameters I have to use for BFClientX.
pls do consider the  shown code(midlet) in my previous post.

BFClientX.BluetoothTransport.Authentication = ?
BFClientX.BluetoothTransport.Encryption = ?
BFClientX.BluetoothTransport.Port = ?
BFClientX.BluetoothTransport.ServiceUUID = ?
BFClientX.BluetoothTransport.Service = ?

thanx  :)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2491
  • Karma: 1000
    • Wireless Communication Library
Re: Asynchronous Proximity check on specific device
« Reply #12 on: March 30, 2008, 05:25:29 PM »
All flags (Authentication, Engription) is False. Port = -1; ServiceName should be the same as in your midlet, ServiceUUID also the same as in your midlet.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #13 on: March 30, 2008, 10:27:57 PM »
 :) Thank you very much. I got it.

Offline kesavamoorthi

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: Asynchronous Proximity check on specific device
« Reply #14 on: April 01, 2008, 11:11:11 AM »
Have a nice day! :)

A list of device is reported when i use AxBFBluetoothDiscoveryX1.StartMonitoring(). I need only the devices which has specific service UUID. how this can be done to filter out devices supporting specific service among all other discovered devices?  ::)