I am creating an iOS which needs to talk with nRF51822 Soft devices 100.
Problem i am facing is, I am not able to Encrypt the connection properly.
I am using
- security mode = 1 and level = 1 (open) for all custom characteristics, except level = 2 (encryption with no MITM protection) for notifications.
My iOS app can Discover the services/Characteristics.
When i try to Read/Write the data on Characteristics. i am able to do so without any kind of encryption.
When i try to Subscribe to Notifications iOS raises an alert if user wants to pair to Device. And everything works fine if user accepts Pairing.
But once I kill iOS App. i can see inside iOS logs that device adds the Device to RemoveFromWhiteList list. Which from sound of it looks like iOS is throwing away the keys.
And eventually if i try to reOpen the App. App is never able to connect to the BLE device.
iOS App acts like a Central.
BLE Device is Peripheral.
When looking at Wireshark Packets the logs which i can see are
Encrypted packet decrypted incorrectly (bad MIC)
Which is expected as iOS has thrown away the Keys and BLE Peripheral is still using the same keys.
Will appreciate any help regarding to this. It feels to me that some kind of encryption i am doing wrong.
Can i add encryption on connection level so that Pairing alert is raised during connection time.
Or Encryption is only defined on each characteristic.
I am facing this issue on iOS 10.3.3, iPhone 5.