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

NRF_ERROR_INTERNAL while bonding?

Hi,

After finding that Windows doesn't like HID devices if they can't be bonded to, I've been attempting to add peer_manager and bonding into my application.

However, having added it I'm getting loads of problems. I can connect normally, but:

Bonding (using nRF Connect) appears to work, but immediately after disconnecting, I get NRF_ERROR_NOT_FOUND from pm_whitelist_set in the BLE_GAP_EVT_DISCONNECTED handler (and the device resets).

Even after removing all the whitelist code (which I'm not too worried about), when attempting to bond I get NRF_ERROR_INTERNAL which comes via the PM_EVT_ERROR_UNEXPECTED handler (and the device also resets)

Any thoughts what could be the issue here? The internal error sounds a bit worrying.

The code that changed in order to add the peer manager without whitelist :

github.com/.../c969f3c52cb39cd0a66df6da4e22d61241486071...BLE_peer_manager_no_whitelist

Same code, but with the whitelist:

github.com/.../c969f3c52cb39cd0a66df6da4e22d61241486071...BLE_peer_manager

Is there anything obvious I've missed here? It kind of seemed like I'd got everything, but it's hard to tell from just looking through the HID example.

Parents
  • Ok, there appear to be 2 main problems:

    Problem 1 - SDK v3 bug

    You can't call pm_whitelist_set while advertising or you get an internal error - this could also be to do with the fact that advertising_start would overwrite m_whitelist_peers, but it seems to be fixed on SDK v4. For v3 you just need to ensure that advertising is done after pm_whitelist_set. In this case it just meant swapping the order of some lines in the BLE_GAP_EVT_DISCONNECTED handler

    pm_evt_handler issue

    For some reason, when I paired as a BLE HID device under Windows 10, PM_EVT_CONN_SEC_SUCCEEDED got called twice (but only on W10, not on anything else). The example code provided doesn't check for duplicates, so m_whitelist_peers got 2 of the same handle ID in the list, which then caused BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE when calling pm_whitelist_set. It just needs to check for duplicates before adding a new UUID.

    And that fixes the main issues I was having. There are still some more, but not related to this particular problem :)

    (And thanks for your help Håkon and Petter!)

Reply
  • Ok, there appear to be 2 main problems:

    Problem 1 - SDK v3 bug

    You can't call pm_whitelist_set while advertising or you get an internal error - this could also be to do with the fact that advertising_start would overwrite m_whitelist_peers, but it seems to be fixed on SDK v4. For v3 you just need to ensure that advertising is done after pm_whitelist_set. In this case it just meant swapping the order of some lines in the BLE_GAP_EVT_DISCONNECTED handler

    pm_evt_handler issue

    For some reason, when I paired as a BLE HID device under Windows 10, PM_EVT_CONN_SEC_SUCCEEDED got called twice (but only on W10, not on anything else). The example code provided doesn't check for duplicates, so m_whitelist_peers got 2 of the same handle ID in the list, which then caused BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE when calling pm_whitelist_set. It just needs to check for duplicates before adding a new UUID.

    And that fixes the main issues I was having. There are still some more, but not related to this particular problem :)

    (And thanks for your help Håkon and Petter!)

Children
No Data
Related