[英]How we can achieve the BLE peripheral device to connect to only our Android app (Central) if any other app try to connect need to disconnect
As question suggested we have our own BLE device and Android app to connect with that device. 有问题的建议我们拥有自己的BLE设备和与该设备连接的Android应用。 We are able to connect with BLE device and do all operations successfully.
我们能够与BLE设备连接并成功完成所有操作。
In the meantime, we are able to detect our BLE device with other 3rd party apps and able to connect and do operations. 同时,我们能够与其他第三方应用程序一起检测我们的BLE设备,并能够进行连接和操作。
But we want to restrict the other apps to connect with our BLE device and if they connect with device immediately it needs to disconnect. 但是我们想限制其他应用程序与我们的BLE设备连接,如果它们立即与设备连接,则需要断开连接。 I have searched in google and SO but unable to get any information to achieve this, if any one have idea help me out
我已经在Google和SO中进行了搜索,但无法获得任何信息来实现这一目标,如果有人有想法可以帮助我
on connect event send some data from app to the device and get verified data from device to app, change some programmed mechanism that app send some data to device and device verify and gives acknowledgement and based on that you keep connections or else you can disconnect from the device. 在连接事件上,将一些数据从应用程序发送到设备,并从设备到应用程序获取经过验证的数据,更改某种编程机制,使应用程序向设备和设备发送一些数据,并进行确认,并在此基础上保持连接,否则您可以断开连接设备。 I had implemented this things and working perfectly
我已经实现了这些东西,并且工作完美
public boolean connectDeviceBonded(String address, String name) {
if (address == null) {
throw new NullPointerException("Address cannot be null or not found");
}
macAddress = address;
boolean value = bluetoothLe.connectScannerBonded(address);
if ( value) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
int ret = reqEncryptedKey(10000);
if (ret != SUCCESS){
return false;
}
}
return value;
}
reqEncryptedKey() send some encrypted data to device and device has same encryption algorithm and device verify my data and gives response to app the success and fail, based on success and fail app can keep connection and disconnect. reqEncryptedKey()向设备发送一些加密数据,并且设备具有相同的加密算法,并且设备验证我的数据并根据成功与失败对应用程序做出响应,基于成功与失败,应用程序可以保持连接和断开连接。 and I also put some piece of code in device so that if device is giving fail then device disconnects automatically.
并且我还在设备中放置了一些代码,以便如果设备出现故障,则设备会自动断开连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.