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

[SDK] ANCS+BONDING > .allow_repairing (SDK12.2 to SDK14.2)

Hi team support,

Got a problem with project ANCS and more precisely with the bonding and the Flag "allow_repairing" which was false and set by myself to true. But on SDK14.2, regarding to this change, the expected behavior is not produced !

I mean, I run LightBlue, I connect to my example ANCS (SDK 14.2 — Dev Kit nRF52 — iOS 11.2 — allow_repairing = false):

  • I connect to my device with LightBlue
  • The system launches me an explicit PopUp of peering request to my device
  • I accept, I am connected to my device and paired
  • I go in iOS Settings, I remove pairing from my device
  • I re-connect to my device from LightBlue
  • The system does not ask me to pair with my device
  • Until all goes well, it's normal

I modify my flag allow_repairing and I set it to "true", I erase my device and reporgram it all.

  • I connect to my device with LightBlue

  • The system launches me an explicit PopUp of peering request to my device, I accept

  • I am connected to my device and paired

  • I go in iOS Settings, I remove pairing from my device

  • I re-connect to my device with LightBlue

  • The system re-launches me an explicit PopUp of peering request to my device, I accept

  • And here is the drama, I have an error message: "Disconnected Alert" "The peripheral has disconnected" and in LightBlue: "Disconnected. Data is Stale" and in my Bluetooth iOS Settings my device is marked as not connected and not paired ...

I just did the test under a version of SDK12.2, with the same example, everything goes well

Where is the eel under rock ?

Thank you for your help !

Parents
  • Hi,

    The PM will report PM_EVT_PEER_DATA_UPDATE_SUCCEEDED with PM_PEER_DATA_ID_BONDING id after initial pairing and after re-pairing (bond refresh), but the implementation in SDK 14 doesn't account for the re-pairing scenario. It tries to add the re-paired device as a new device into the whitelist which leads to the BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE assert.

    A solution could be to simply ignore this error code:

         case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
        {
            // Note: You should check on what kind of white list policy your application should use.
            if (     p_evt->params.peer_data_update_succeeded.flash_changed
                 && (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING))
            {
                NRF_LOG_DEBUG("New Bond, add the peer to the whitelist if possible");
                NRF_LOG_DEBUG("\tm_whitelist_peer_cnt %d, MAX_PEERS_WLIST %d",
                               m_whitelist_peer_cnt + 1,
                               BLE_GAP_WHITELIST_ADDR_MAX_COUNT);
    
                if (m_whitelist_peer_cnt < BLE_GAP_WHITELIST_ADDR_MAX_COUNT)
                {
                    // Bonded to a new peer, add it to the whitelist.
                    m_whitelist_peers[m_whitelist_peer_cnt++] = m_peer_id;
    
                    // The whitelist has been modified, update it in the Peer Manager.
                    ret = pm_device_identities_list_set(m_whitelist_peers, m_whitelist_peer_cnt);
                    if (ret != NRF_ERROR_NOT_SUPPORTED && 
                        ret != BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE)
                    {
                        APP_ERROR_CHECK(ret);
                    }
    
                    if (ret != BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE)
                    {
                        ret = pm_whitelist_set(m_whitelist_peers, m_whitelist_peer_cnt);
                        APP_ERROR_CHECK(ret);
                    }
                }
            }
        } break;
    

    EDIT: I guess the m_whitelist_peer_cnt variable shouldn't be incremented in case of duplicate entry.

  • Hi Vidar, Thanks it works, since you advised me to comment that PM_EVT_PEER_DATA_UPDATE_SUCCEEDED, And you are right, in my debugger, if I forgot my Device in my iOS Settings, and make the re-pairing, it puts me: nrf_sdh_ble: BLE event: 0x10. app: Connected to previously bonded device app: Connected.

    So i guess too, the m_whitelist_peer_cnt shouldn't be incremented!

    Thanks

Reply
  • Hi Vidar, Thanks it works, since you advised me to comment that PM_EVT_PEER_DATA_UPDATE_SUCCEEDED, And you are right, in my debugger, if I forgot my Device in my iOS Settings, and make the re-pairing, it puts me: nrf_sdh_ble: BLE event: 0x10. app: Connected to previously bonded device app: Connected.

    So i guess too, the m_whitelist_peer_cnt shouldn't be incremented!

    Thanks

Children
No Data
Related