×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    11

    Speedup Bluetooth Discovery to reach Connection (Bluetooth JSR-82)

    I've found that discovery using the function:

    startInquiry(DiscoveryAgent.GIAC, this);

    requires a large amount of time (which varies anywhere from 10-30 seconds).

    I'm attempting to speedup the connection process and get to 'static Connection open(String name)' in the Connector class a bit faster.

    Using the bluetooth hardware address won't work because there's more than one device that I want my program to discover and the hardware address may not be known beforehand.

    Using the bluetooth friendly name won't work either because startInquiry() must complete before 'java.lang.String getFriendlyName(boolean alwaysAsk)' can be called.

    So I've resorted to perhaps using the Class of Device (CoD) values to determine whether I've discovered one of my bluetooth devices. Once I have I can simply call 'boolean (DiscoveryAgent.)cancelInquiry(DiscoveryListener listener)' once I've found one of my bluetooth devices.

    I can set these values in the firmware of my bluetooth devices. But I'm not too sure if CoD values are specific enough to be absolutely sure I've discovered one of my bluetooth devices and not some device that has the same CoD value. Could someone tell me if CoD values are relatively unique for each device?

  2. #2
    Registered User
    Join Date
    Jun 2009
    Posts
    11

    Re: Speedup Bluetooth Discovery to reach Connection (Bluetooth JSR-82)

    Also, is there any alternative ways to connect to a bluetooth device other than Device Inquiry->Service Inquiry->Connect.

  3. #3
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Speedup Bluetooth Discovery to reach Connection (Bluetooth JSR-82)

    sure if you already have the Bluetooth service url you can connect directly...
    but that means you will have to perform a Bluetooth device/services search at least once...

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Does this help?

    amadcow, cancel the inquiry immediately after you have found device(s). Then you do a search for your service (private UUID). You cannot be more sure, can you? Forget about the name of the device or the name of your service, especially as some devices are very slow at reading names. However, in real world this has limitations:
    – Some JSR-82 implementations do not like this and are a bit slow; you have to test your target devices yourself.
    – Some remote devices require authentication (and starting a pairing process) even for service discovery. Those devices will slow down your search, the remote device create confusing messages to their users and some remote devices will even instruct your local device to start pairing, creating confusing messages on your local device.

    For example in Symbian (tested with Series 80 [which is similar to S60 2nd Edition Feature Pack 1] up to S60 5th Edition), after obtaining the remote services, the underlying channels are not closed immediately but after a certain timeout value. In my case, I get a five second break and the inquiry can not proceed. Furthermore, if the remote device is not reachable anymore my observed timeout value is 15 seconds longer. All together, sometimes I have to wait 20 seconds to start with the next device. Going back to one inquiry which collects all, is no help either as I face a 10 second timeout then, if that device is not reachable.

    With Series 40, my service discovery is very fast and does not take more than half a second. Anyway, if something goes wrong in that period, even then a timeout about 15 seconds is floating around. Unfortunately, I have not found a way to avoid, control or to minimise those timeouts. Should I do more garbage collection of objects? I do not know. From my personal experience, there are even some circumstances while receiving the service discovery which will never end.

    I would be very happy, if that could be improved. The correct way is to choose your remote device from a list. Many devices today allow getFirendlyName while doing an inquiry. The trick is to call getFriendlyName from its own thread rather than from within in the deviceDiscovered event which is a platform thread. Nevertheless, yes there are JSR-82 implementations which do not allow getFriendlyName while inquiring. For those again, you use cancelInquiry after each deviceDiscovered event.

    As you can see, there is no approach which fits all. If possible let the user decide which device to choose. After that start your service discovery.
    Quote Originally Posted by amadcow View Post
    Is there any alternative ways to connect to a bluetooth device other than Device Inquiry->Service Inquiry->Connect.
    Quote Originally Posted by amadcow View Post
    Using the bluetooth hardware address won't work because there's more than one device that I want my program to discover and the hardware address may not be known beforehand.
    Does this help? In your case, I do not think so.
    Last edited by traud; 2009-07-17 at 12:54.

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    11

    Re: Speedup Bluetooth Discovery to reach Connection (Bluetooth JSR-82)

    Thanks for the suggestions. I suppose the issue with the UUID is that it's not necessarily going to be unique for my device (the UUID for the device is simply the serial port profile 0x1101).

    When I do a getFriendlyName() during a deviceDiscovered() I get back a Java IO Exception 'Busy'. I'm not absolutely sure if this is from not spawning a new thread on the deviceDiscovered() event. But as you mentioned before, getFriendlyName() is fairly slow as the Bluetooth module needs to send an inquiry for its friendly name.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Why do you use 0x1101 as UUID for your own private service?

  7. #7
    Registered User
    Join Date
    Jun 2009
    Posts
    11

    Re: Speedup Bluetooth Discovery to reach Connection (Bluetooth JSR-82)

    Well I can't set the UUID on the BT device the phone is connecting to. The BT device I'm connecting to is a BlueSMIRF module (http://www.sparkfun.com/commerce/pro...roducts_id=582).

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    I would use such a module just for prototyping, actually, I would not use such a module at all as JSR-82 implementations are too unstable, already. Fixing a bug with such a set-up, happy bug hunting …

  9. #9
    Registered User
    Join Date
    Jun 2009
    Posts
    11

    Re: Speedup Bluetooth Discovery to reach Connection (Bluetooth JSR-82)

    Is there a way pairing with the device would speedup the connection process in Java? Is there some autoconnect or autodetect functionality available?

Similar Threads

  1. Bluesoleil Software
    By kencooper in forum Bluetooth Technology
    Replies: 9
    Last Post: 2008-08-29, 19:46
  2. Using bluetooth connection and http connection in one midlet
    By vipinmenontp in forum Bluetooth Technology
    Replies: 0
    Last Post: 2008-04-23, 10:57
  3. Closing a bluetooth connection
    By Alfury in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2008-04-01, 16:18
  4. Bluetooth connection slow to close
    By scole96 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-10-22, 16:26
  5. 6310 bluetooth connection with PCsuite fails
    By Nokia_Archive in forum Bluetooth Technology
    Replies: 1
    Last Post: 2002-05-28, 15:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×