问题
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