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

how to use whitelist in ble_app_hrs_c?

S130, SDK 12.3, ble_app_hrs_c example. I want to use whitelist function in this example but I can't finish it.

When I run peer_list_get(), it gets all 0xFF, means that there is no peer in flash.

So I use the code below:

static void peer_list_get(pm_peer_id_t * p_peers, uint32_t * p_size){
pm_peer_id_t peer_id;
uint32_t     peers_to_copy;

	const ble_gap_id_key_t m_peer1 = {
		.id_info ={
				.irk = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},},
		.id_addr_info = {
			.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC,
			.addr = {0xC2, 0x78, 0x06, 0x3C, 0x62, 0x6A},}
	};
	
pm_peer_data_bonding_t peer_bonding_data;
  peer_bonding_data.own_role = BLE_GAP_ROLE_CENTRAL;
  peer_bonding_data.peer_ble_id = m_peer1;
	uint32_t err_code = pm_peer_new(&peer_id,&peer_bonding_data,NULL);
APP_ERROR_CHECK(err_code);
	err_code = pm_peer_data_bonding_store(peer_id,&peer_bonding_data,NULL);
APP_ERROR_CHECK(err_code);

peers_to_copy = (*p_size < BLE_GAP_WHITELIST_ADDR_MAX_COUNT) ?
                 *p_size : BLE_GAP_WHITELIST_ADDR_MAX_COUNT;

//peer_id = pm_next_peer_id_get(PM_PEER_ID_INVALID);
*p_size = 0;

while ((peer_id != PM_PEER_ID_INVALID) && (peers_to_copy--))
{
    p_peers[(*p_size)++] = peer_id;
    peer_id = pm_next_peer_id_get(peer_id);
}

}

But I got FDS_ERR_NOT_FOUND by peer_data_find in pm_whitelist_get().

So how to use whitelist in ble_app_hrs_c?

  • Hi Kamisen,

    Do you do bonding with the peer device ? If you do, then the peer should be added automatically to the peer list.

    If you don't do bonding, I don't think calling pm_peer_new() and pm_peer_data_bonding_store() with NULL bonding information is a good idea.

    What you can do, if you don't do bonding, is to add the address to p_whitelist_addrs directly . You can find where to add it in scan_start() , just add your extra address after the call pm_whitelist_get() and increase add_cnt.

Related