无法检测蓝牙服务(java.lang.NumberFormatException:输入字符串:“0S”)

时间:2011-12-11 15:50:11

标签: java bluetooth serial-port uuid bluecove

您好我想从我的电脑上检测外部蓝牙设备的串口蓝牙服务,因为我正在使用Bluecove API和以下代码:

 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;
         }

但是我继续使用“java.lang.NumberFormatException:对于输入字符串:行中的”0S“”异常:

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

谢谢你的帮助

1 个答案:

答案 0 :(得分:0)

来自bluecove的documentation

“从提供的字符串创建UUID对象。字符串中的字符必须来自十六进制集[0-9,a-f,A-F]。”

“SPP”不是有效的十六进制数。