Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Aug 2004

    How to get different Bluetooth connection urls for applications on same device?


    I am developing a Bluetooth client/server-application. I intend to do the device search and service discovery on both devices only once and then store the connection url I get by calling serviceRecord.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false); to record store and use that value whenever I start the applications and need to communicate over Bluetooth.

    It works fine, but the problem is that the method returns the same url for both applications. This means that If I have two servers or two clients running on different devices they will also try to communicate with each others. Can I somehow get urls that are different for different services on the same device or what is the best way to prevent this unwanted communication from happening?

    I have also registered the connections to the devices' push registry by calling PushRegistry.registerConnection("btspp://:" + uuid.toString(), this.getClass().getName(), "*"); (naturally different UUIDs for client and server applications). However, the registered connections seem to be the same since for example server application on some device can invoke server application on another device, when trying to communicate with the client application. Again, are there some additional parameters I should use in the connection url that I am registering to the push registry or how to make sure that the wrong application is not invoked?

  2. #2
    Registered User
    Join Date
    Mar 2003
    First of all, you should not and actually you cannot cache thes URLs. Although it does not happen for many devices, the RFCOMM channel is allowed to move. Nevertheless, you can and might cache the Bluetooth addresses of devices.

    I do not understand your section question. Because of different Bluetooth devices addresses it should not be possible to get the same URL again. Or are you in an emulator, or have your devices the addresses?

    Additionally, I do not understand your last question. The UUID should be the same for client and server. I need a bit more information, to understand you. Nevertheless, Push Registry for Bluetooth works reliable only in Nokia S60 3rd Edition (and probably Nokia Series 40 3rd Edition Feature Pack 1).

  3. #3
    Registered User
    Join Date
    Aug 2004

    Re: How to get different Bluetooth connection urls for applications on same device?

    Ok. So I should store the address I get from remoteDevice.getBluetoothAddress() instead. Does this mean that I should still do service search everytime I want to communicate over Bluetooth? Also,
    what is the best way to use the known Bluetooth address in Java Bluetooth API since for some reason constructor RemoteDevice(java.lang.String address) is protected? Naturally, I could extend RemoteDevice class to get access to that constructor, but that doesn't seem very neat.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Yes, you are right.

    Better idea: Save the whole connection URI as you do already and then check the returned Connection n and then ask for the service UUID.
    UUID u = null;
    try {
    ServiceRecord r = LocalDevice.getRecord(n);
    DataElement d = r.getAttributeValue(0x0001);
    Enumeration e = d.getValue();
    UUID u = (UUID) e.nextElement();
    catch (Exception e) {}
    if (true == yourUUID.equals(u))
    Additionally, set this attribute within the remote device correctly, as many implementation have bugs here.
    LocalDevice l = LocalDevice.getLocalDevice();
    ServiceRecord r = l.getRecord(n);
    DataElement d = new DataElement(DataElement.UUID, yourUUID);
    DataElement e = new DataElement(DataElement.DATSEQ);
    boolean b = r.setAttributeValue(0x0001, e);

Similar Threads

  1. Canyon Bluetooth adapter not working with PC Suite?
    By sNNooPY in forum Bluetooth Technology
    Replies: 6
    Last Post: 2006-08-10, 08:43
  2. Bluetooth connection slow to close
    By scole96 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-10-22, 16:26
  3. Nokia 7650 support Bluetooth audo?
    By ovjo12 in forum Bluetooth Technology
    Replies: 5
    Last Post: 2003-07-17, 18:50
  4. Suggestion for resolving PC suite connection via bluetooth
    By Kazi in forum Bluetooth Technology
    Replies: 0
    Last Post: 2003-03-14, 19:35
  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