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

How to delete host bonds while keeping peripheral bonds

Hi,

I'm using nrf52832 as host and peripheral concurrently, with soft device s132. I know that peer manager can handle both host and peripheral.

I now have a need to remove the bonds of host, at the same time I want to keep the bond data of peripheral.

So how can I get a list of bond device and determine which one belongs to host and which one belongs to peripheral?

I tried to search the forum but did not find related info.

Thank you.

Parents
  • Hi,

    The GAP role is included as a part of the bonding information. It should be possible to use the pm_peer_count() and pm_peer_data_load() API exposed in peer_manager.h to first find the number of bonds, then retrieve the bonding information to find the GAP role of a particular bond.

    You can probably do something like this to run through the list of bonds (I have not tested it): 

    uint32_t               err_code;
    uint32_t               bond_cnt;
    pm_peer_data_bonding_t bonding_info;
    
    bond_cnt = pm_peer_count();
    
    for (pm_peer_id_t id=0; id < bond_cnt; id++)
    {
        err_code = pm_peer_data_bonding_load(id, &bonding_info)
        APP_ERROR_CHECK(err_code);
        
        if (bonding_info.own_role == BLE_GAP_ROLE_PERIPH)
        {
            //TODO: Bond belongs to GAP peripheral role
        }
        else if (bonding_info.own_role == BLE_GAP_ROLE_CENTRAL)
        {
            //
        }  
    
    }

Reply
  • Hi,

    The GAP role is included as a part of the bonding information. It should be possible to use the pm_peer_count() and pm_peer_data_load() API exposed in peer_manager.h to first find the number of bonds, then retrieve the bonding information to find the GAP role of a particular bond.

    You can probably do something like this to run through the list of bonds (I have not tested it): 

    uint32_t               err_code;
    uint32_t               bond_cnt;
    pm_peer_data_bonding_t bonding_info;
    
    bond_cnt = pm_peer_count();
    
    for (pm_peer_id_t id=0; id < bond_cnt; id++)
    {
        err_code = pm_peer_data_bonding_load(id, &bonding_info)
        APP_ERROR_CHECK(err_code);
        
        if (bonding_info.own_role == BLE_GAP_ROLE_PERIPH)
        {
            //TODO: Bond belongs to GAP peripheral role
        }
        else if (bonding_info.own_role == BLE_GAP_ROLE_CENTRAL)
        {
            //
        }  
    
    }

Children
Related