Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

im_ble_addr_get() gets old address right after bonding a new peer

Hi All,

I'm currently using SDK12 for nRF52832. In my BLE peripheral project I store central address who engaged my device to listen for ANCS notifications. This address is used to decide if ANCS resubscription is needed for a reconnected device.

I use im_ble_addr_get() to get that address and it works in most cases. Problem occurs when I call im_ble_addr_get() for just bonded peer to get its address. After bonding the peer address is changed (I don't really know why), but im_ble_addr_get() still produces an old address.

I made my function to get correct address right after bonding:

static void ble_get_real_address(uint16_t peer_id, ble_gap_addr_t *addr)
{
	pm_peer_data_t         peer_data;
	pm_peer_data_bonding_t bond_data;
	peer_data.p_bonding_data = &bond_data;
	uint32_t const buf_size  = sizeof(bond_data);

	pds_peer_data_read(peer_id, PM_PEER_DATA_ID_BONDING, &peer_data, &buf_size);
	*addr = bond_data.peer_id.id_addr_info;
}

static void pm_evt_handler(pm_evt_t const * p_evt)
{
    ....
    case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
    	if (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING)
		    ble_get_real_address(p_evt->peer_id, &real_central_addr);
        break;
}

So my questions are:

1) is it correct way to get peer address? may be I missed another more suitable function?

2) if yes, should im_ble_addr_get() work right after bonding? may be I missed another call to get m_connections[] (id_manager.c) updated after receiving bonding done event?

3) if I'am right, does this issue fixed in latest SDK (15)?

Thanks in advance!

Parents Reply Children
No Data
Related