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

Peer list: Addition of Peers, Order of Peers, Compatibility with Whitelist

Hi,

I have a few questions about how the peer list works. (using S132 v 7.0.1 and SDK version 16)

  • How or when are peers added to the peer list of the Central? Are they added when connected, when paired or when bonded? do we need to call for example "sd_ble_gap_connect" or which function adds them?

  • When using a whitelist, we call the function like "peer_list_get" that will read the peers from the list. Then we set the whitelist with "im_whitelist_set". In this function we put the first 8 values in the peer list into the whitelist (see code snipplet below).
    • But which ones are those first 8 values i.e. how is this peer list ordered? I have read in the function definition of "pm_next_peer_id_get" that: "The order in which peer IDs are returned should be considered unpredictable". But If we have more than 8 peers, will older peers or those with lower RSSI not get added to the whitelist?

    ret = peers_id_keys_get(p_peers, peer_cnt, addrs, &wlist_addr_cnt, NULL, NULL);

    for (uint32_t i = 0; i < BLE_GAP_WHITELIST_ADDR_MAX_COUNT; i++)
    {
        addr_ptrs[i] = &addrs[i];
    }
    
    return sd_ble_gap_whitelist_set(addr_ptrs, peer_cnt);

Thank you for your kind assistance

  • Hello,

    I suggest you check some of the examples that uses bonding to see how this is stored.

    The peer manager will only add devices when they are bonded, Check out the ble_app_gls example, and how it secures the connection in the BLE_GAP_EVT_CONNECTED event in peer_manager_handler.c, using conn_secure(). This function will start the bonding procedure, including storing the data in the peer manager.

    Best regards,

    Edvin

     

    But which ones are those first 8 values i.e. how is this peer list ordered?

     They are ordered in the latest 8 peers that were connected. Look at the event PM_EVT_CONN_SEC_SUCCEEDED, which is called when a connection is secured (paired/bonded). In peer_manager_handler.c this event will call rank_highest(), putting that device on top of the devices in the device list.

    This is a really shallow explanation, but I suggest you look into the ble_app_gls example, and how it performs the bonding. Also note the difference between connecting pairing and bonding and whitelists, which is explained here.

    Best regards,

    Edvin

Related