This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Peer Manager LESC bonding only works the first time

While trying to bond an iPhone 6 (running nRF MCP App) with an nRF52 with S132 2.0.0 I encountered the following error:

On the first try, when the iPhone is not yet paired (the nRF52 is not showing up in Settings->Bluetooth->My Devices) everything appears to work.

BLE_GAP_EVT_AUTH_STATUS: status=0x0 bond=0x1 sm1_lv4:1 sm1_lv3:1 kdist_own:0x3 kdist_peer:0x2

When I try to connect a second time, this happens:

BLE_GAP_EVT_CONNECTED
PM_EVT_CONN_SEC_FAILED: peer_id=65535, error=4102
BLE_GAP_EVT_SEC_INFO_REQUEST
PM_EVT_CONN_SEC_START: peer_id=65535
BLE_GAP_EVT_SEC_PARAMS_REQUEST
BLE_GAP_EVT_LESC_DHKEY_REQUEST
uECC_shared_secret
uECC_shared_secret complete: 1
PM_EVT_CONN_SEC_FAILED: peer_id=0, error=4102
BLE_GAP_EVT_SEC_INFO_REQUEST
BLE_GAP_EVT_PASSKEY_DISPLAY: passkey=042983 match_req=1
Confirm passkey==042983: y/n
BLE_GAP_EVT_AUTH_STATUS: status=0x88 bond=0x1 sm1_lv4:0 sm1_lv3:0 kdist_own:0x38 kdist_peer:0x33

From what I see, the first try immediately fails with PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING. This triggers a forced rebonding through pm_conn_secure, which looks quite promising but fails even before the key exchange. I don't know what exactly happens as the Passkey is never confirmed. iOS seems to reject the bonding if you immediately confirm the passkey programatically, therefore in my implementation the key has to be confirmed manually, which I never do in this case, as BLE_GAP_EVT_AUTH_STATUS is called before one can handle.

Do you have any Ideas what goes wrong in the first place? Is there maybe something wrong with persistent storage?

Related