iOS - How to deal with bonded devices in BLE

时光毁灭记忆、已成空白 提交于 2019-12-11 13:03:07

问题


I have interract with a BLE device using an iOS App. These devices are bonded.

The problem appears when I go to Settings and I press 'Forget Device'. The application keeps trying to connect even though the device was forgotten because on the "peripheral:didDisconnect" callback I try to reconnect to the device. The bluetooth device sends a disconnect event because the bond is not good anymore. Then the application tries again a connection and so on.

I tried to look at the error code in the "peripheral:didDisconnect:" but It did not look very relevant.

Does anyone have a solution for this?


回答1:


I solved this problem using this callback:

-(void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error

The error looks like this:

Error Domain=CBATTErrorDomain Code=15 "Encryption is insufficient." UserInfo=0x170272f40 {NSLocalizedDescription=Encryption is insufficient.}


来源:https://stackoverflow.com/questions/31030619/ios-how-to-deal-with-bonded-devices-in-ble

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!