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

delete peers by peer manager

nRF5_SDK_11.0.0-2.alpha. I create peer by peer_manager. When initializing the application, i delete them pm_peer_delete_all(). There's an application is stuck. It works only when i add peer_id_free () in implementation of pm_peer_delete_all (). As shown below. As far as it is correct, and why it works is only in such a case?

void pm_peer_delete_all(void)
    {
        pm_peer_id_t current_peer_id = PM_PEER_ID_INVALID;
        while (pdb_next_peer_id_get(PM_PEER_ID_INVALID) != PM_PEER_ID_INVALID)
        {
            current_peer_id = pdb_next_peer_id_get(current_peer_id);
            peer_id_free(current_peer_id); // [FIX]
            pm_peer_delete(current_peer_id);
        }
    }
  • The peer manager is still in experimental release, and there are some issues in the current release. Most likely what you experience at the moment is caused by that. You might try the following, it should do the same, but the best would be to wait for the next release where this will be fixed:

    void pm_peer_delete_all(void)
    {
        pm_peer_id_t current_peer_id = PM_PEER_ID_INVALID;
        while (pdb_next_peer_id_get(PM_PEER_ID_INVALID) != PM_PEER_ID_INVALID)
        {
            current_peer_id = pdb_next_peer_id_get(PM_PEER_ID_INVALID);
            pm_peer_delete(current_peer_id);
        }
    } 
    
Related