我在尝试使用带有 64 位 JVM 的 Linux x64 中的 Bluecove(bluecove 和 bluecove-gpl 2.1.1 SNAPSHOT 库)的配对过程中验证 BT 设备时遇到了麻烦。虽然发现似乎很好,但在尝试使用已知 PIN 进行身份验证时,恐怕大多数情况下它永远不会这样做,因为这个功能从未实现过。
这是实际进行配对的方法:
public Boolean pairingDevice()
{
//check if authenticated already
if (remoteDevice.isAuthenticated()){
return true;
}
else{
LOG.info("--> Pairing device");
try {
PIN = "111111";
boolean paired = RemoteDeviceHelper.authenticate(remoteDevice, PIN);
//LOG.info("Pair with " + remoteDevice.getFriendlyName(true) + (paired ? " succesfull" : " failed"));
devicePaired = paired;
if (devicePaired)
LOG.info("--> Pairing successful with device " + remoteDevice.getBluetoothAddress());
else
LOG.info("--> Pairing unsuccessful with device " + remoteDevice.getBluetoothAddress());
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
LOG.info("--> Pairing unsuccessful with device " + remoteDevice.getBluetoothAddress());
devicePaired = false;
}
LOG.info("--> Pairing device Finish");
return devicePaired;
}
}
现在调用
boolean paired = RemoteDeviceHelper.authenticate(remoteDevice, PIN);
最后调用 BluetoothStackBlueZ.authenticateRemoteDevice(long address, String passkey):
/*
* (non-Javadoc)
*
* @see com.intel.bluetooth.BluetoothStack#authenticateRemoteDevice(long, java.lang.String)
*/
public boolean authenticateRemoteDevice(long address, String passkey) throws IOException {
return false;
}
如您所见,这总是返回 FALSE,这会导致未定义的行为。问题是......我可以做些什么来使用 Bluecove 在 Linux 中验证 remoteDevice?
Bluecove 有什么替代品吗?我听说同样的代码在 Windows 中工作,但我真的不想因为这个原因切换到 Windows...
提前致谢, 亚历克斯