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

Return error by “pm_device_identities_list_set”

52832 & s112 & sd6.0 & sdk15.0

If you have multiple pairings on the same host will return error by “pm_device_identities_list_set”

err_code = BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE.

if I ignore this error seems no issue.

pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};  

  case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
        {
            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_INFO("New Bond, add the peer to the whitelist if possible");
                NRF_LOG_INFO("\tm_whitelist_peer_cnt %d, MAX_PEERS_WLIST %d",
                               m_whitelist_peer_cnt + 1,
                               BLE_GAP_WHITELIST_ADDR_MAX_COUNT);
               // Note: You should check on what kind of white list policy your application should use.

                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;
                                                                                NRF_LOG_INFO(" new peer ID %d", m_peer_id);
                                                                                
                    // The whitelist has been modified, update it in the Peer Manager.
                    err_code = pm_whitelist_set(m_whitelist_peers, m_whitelist_peer_cnt);
                    APP_ERROR_CHECK(err_code);

                    err_code = pm_device_identities_list_set(m_whitelist_peers, m_whitelist_peer_cnt);
                    if (err_code != NRF_ERROR_NOT_SUPPORTED)
                    {
                        APP_ERROR_CHECK(err_code);
                    }
                }
            }
        } break;

Parents Reply
  • You are right, the issue can be seen with the stock example if changing allow_repairing  = true. 

     

    That's why we suggested to do a check before this call m_whitelist_peers[m_whitelist_peer_cnt++] = m_peer_id; in PM_EVT_PEER_DATA_UPDATE_SUCCEEDED, to see if the m_peer_id isn't already exist in the list. This way, we avoid duplicate peer identity to be sent to pm_device_identities_list_set(). 

Children
Related