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

SDK15.2 ANCS phone unable to bind after forgot device

Example:nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_ancs_c\pca10040e\s112\arm4

I tested ancs on the board,connected ancs with the iphone, chose to forget the device in Bluetooth, clicked on the device again, and showed pairing unsuccessful. I don't know how to delete pairing in the examples. I think after iphone forget the device,click on the device again to  pairing;
Parents
  • Hi,

    The SDK examples will reject bond refresh by default. Please have a look at my answers in this thread, they explain how you can override this: https://devzone.nordicsemi.com/f/nordic-q-a/38663/keep-getting-failed-to-secure-connection-error/158087#158087 

  • I modified the following places. After the pairing is successful, I forgot the device in the Bluetooth settings of the iphone. After the new pairing is successful, I will turn off the Bluetooth of the iphone, and then open the Bluetooth of the iphone. The ancs of the iphone cannot be reconnected automatically. How to solve this problem?

  • I forgot my device and re-paired it. After I quit the bluetooth page of my phone, the connection was automatically disconnected

  • Hi,

    m_whitelist_peer_cnt should not be incremented if you get BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE so the code should have been something like this instead:

                // 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++] = p_evt->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 == BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE)
                        {
                            m_whitelist_peers[--m_whitelist_peer_cnt] = PM_PEER_ID_INVALID;
                        }
                        else if (ret != NRF_ERROR_NOT_SUPPORTED)
                        {
                            APP_ERROR_CHECK(ret);
                        }
    
                        ret = pm_whitelist_set(m_whitelist_peers, m_whitelist_peer_cnt);
                        APP_ERROR_CHECK(ret);
    
                        NRF_LOG_HEXDUMP_INFO(m_whitelist_peers, sizeof(m_whitelist_peers));
                    }

    Regarding the re-connect issue, I see the same here. After bond refresh I need to manually re-connect to the ANCS. However, autoconnect seems to work fine after that. This might be an iOS limitation.  

Reply
  • Hi,

    m_whitelist_peer_cnt should not be incremented if you get BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE so the code should have been something like this instead:

                // 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++] = p_evt->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 == BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE)
                        {
                            m_whitelist_peers[--m_whitelist_peer_cnt] = PM_PEER_ID_INVALID;
                        }
                        else if (ret != NRF_ERROR_NOT_SUPPORTED)
                        {
                            APP_ERROR_CHECK(ret);
                        }
    
                        ret = pm_whitelist_set(m_whitelist_peers, m_whitelist_peer_cnt);
                        APP_ERROR_CHECK(ret);
    
                        NRF_LOG_HEXDUMP_INFO(m_whitelist_peers, sizeof(m_whitelist_peers));
                    }

    Regarding the re-connect issue, I see the same here. After bond refresh I need to manually re-connect to the ANCS. However, autoconnect seems to work fine after that. This might be an iOS limitation.  

Children
Related