Question

Hello i'want to detect the serial port bluetooth service of an external bluetooth device from my computer, for that i'm using the Bluecove API and the following code :

 BluetoothDeviceDiscovery bluetoothDeviceDiscovery=new BluetoothDeviceDiscovery();

        //display local device address and name
        LocalDevice localDevice = LocalDevice.getLocalDevice();
        System.out.println("Address: "+localDevice.getBluetoothAddress());
        System.out.println("Name: "+localDevice.getFriendlyName());

        //find devices
        DiscoveryAgent agent = localDevice.getDiscoveryAgent();
        UUID uuid = new UUID("SPP", true);
         String ServiceURL = agent.selectService(uuid,ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);//"btspp://localhost:"+rd.getBluetoothAddress()+";name=SPP"; 
        if( ServiceURL == null) {
            System.out.println("Connection failed: "+ uuid +"\n");
            return;
         }

But i keep having the "java.lang.NumberFormatException: For input string: "0S" " exception in the line :

 UUID uuid = new UUID("SPP", true);

thank you for your help

Was it helpful?

Solution

From bluecove's documentation

"Creates a UUID object from the string provided. The characters in the string must be from the hexadecimal set [0-9, a-f, A-F]."

"SPP" is not a valid hex number.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top