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

Creating Whitelist with PM on Manually added peer (ERROR 0x12802 BLE_ERROR_GAP_INVALID_BLE_ADDR)

Hello,

I have the following problem. I want to create a whitelist using the PM on a manually added peer. 

I manually add a peer by adding its GAP address. 

ret_code_t peer_manager_add_new_peer(pm_peer_id_t *p_new_peer_id, ble_gap_addr_t *p_target_central_addr)
{
    ret_code_t err_code;
    
    pm_peer_data_bonding_t  new_peer_bonding_data;

    memset(&new_peer_bonding_data,0,sizeof(new_peer_bonding_data));
    new_peer_bonding_data.own_role = BLE_GAP_ROLE_PERIPH;
    new_peer_bonding_data.peer_ble_id.id_addr_info = *p_target_central_addr;    

    err_code = pm_peer_new(p_new_peer_id,&new_peer_bonding_data,NULL);
    return err_code;
}

Then I try to whitelist this peer with the following routine:

ret_code_t peer_manager_whitelist_set(void)
{
    ret_code_t err_code;

    // Fetch a list of peer IDs from Peer Manager and whitelist them.
    pm_peer_id_t peer_ids[8] = {PM_PEER_ID_INVALID};
    uint32_t     n_peer_ids  = 0;    
    pm_peer_id_t peer_id     = pm_next_peer_id_get(PM_PEER_ID_INVALID);
    while((peer_id != PM_PEER_ID_INVALID) && (n_peer_ids < 8))
    {
        peer_ids[n_peer_ids++] = peer_id;
        peer_id = pm_next_peer_id_get(peer_id);
    }
    // Whitelist peers.
    err_code = pm_whitelist_set(peer_ids, n_peer_ids);
    APP_ERROR_CHECK(err_code);

    return err_code;
}

But what I get is error 0x12802 - BLE_ERROR_GAP_INVALID_BLE_ADDR

Looking into the ID manager when the record for the added peer is read from Flash, it comes back completely wrong. The address is wrong and most importantly the address type.

What am I doing wrong? Is the manual addition of the peer with only its address wrong?

Thank you for your help

Related