I am working on a BT project using Java (JSR-82). My objective is to maintain a list of BT devices in the vicinity and display an alert if any of the device goes off range or gets switched off or other events that could indicate that the connection is lost.
The phone runs a small midlet which will monitor the nearby BT devices.
Here is how I crudely implemented this.
1.) Discover devices
2.) Keep found devices in an array/vector
3.) Discover again
4.) Keep found devices in a second array/vector
5.) compare both array/vector for difference
6.) if there is a difference, play a beep sound
7.) if no difference, then clear second array and rediscover devices
8.) loop back to step5
This crude method somewhat works, however performing multiple device discovery is utterly slow and 'lost' device response is delayed due to this.
Alternatively, I tried to use the RemodeDevice's getFriendlyName(boolean alwaysAsk), which is supposed to throw an exception if it cant contact the device. This however doesnt seem to work on 6600 or the 6260.
If any of you can think of any better method, do advise.
Lastly, the BT devices which I am monitoring has Serial Port Profile and its configured to act as a virtual serial port at 9600 baud. I am not sure how to make a service level connection to it. The examples I see are more like client/server ones. Simply put, if my PC exposes a SPP how can I connect to it from the phone via code?
My setup is. I have both 6600 and 6260, I am using J2MEWTK 2.2 along with the S60 MIDP package. As my usb bt dongle isnt supported by the s60 emulator, I use the default phone emulator on the WTK.
I am suprised there is no system level exception/notification of sudden loss of a client!
Thanks you for your time.