1

I am using Java Bluecove to establish a connection between my pc and a remote bluetooth device. I use a a DiscoveryListener object to discover the URL of a certain service on the device; then I use that string URL as argument of Connector.open(URL) to open the connection but I get:

Connection timeout; [10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Here are two snippets from my program. The first one searches for a specified set of services

             UUID[] uuidSet = new UUID[1];
             uuidSet[0] = new UUID(0x1101); //serial port
             int[] attrIDs = new int[]{0x0100};
             LocalDevice localDevice = LocalDevice.getLocalDevice();
             DiscoveryAgent agent = localDevice.getDiscoveryAgent();
             agent.searchServices(attrIDs, uuidSet, device, transport); //if the specified service is found its URL is print to screen; so I know it

The following code is to establish the connection.

   String bt_addr = remDev.getBluetoothAddress(); //remDev is the remote device; I am sure it's the correct one
    try {
         connection = (StreamConnection) Connector.open("btspp://" + bt_addr + ":1;authenticate=false;encrypt=false;master=true;"); //HERE OCCURS THE TIMEOUT !
            } catch (javax.bluetooth.BluetoothConnectionException e) {}

Now, it may be that there are other services on the meter but I only look for 0x1101 which is not the one I have to use to connect to. But I don't know how to look for different services.

4

0 回答 0