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

Connected device address

In ble events handler after connecting to peripheral device i handle BLE_GAP_EVT_CONNECTED event and try to identity connected device:

	case BLE_GAP_EVT_CONNECTED:
	{
		err_code = sd_ble_gap_address_get(&dev_addr);						
        if(err_code != NRF_SUCCESS)
	        APPL_LOG("[APPL]: Getting address failed, reason %d\r\n", err_code);
        else
        {
	        APPL_LOG("[APPL]: PeerAddressType:  %d\r\n", dev_addr->addr_type);
	        APPL_LOG("[APPL]: PeerAddress (MSB): %02x%02x%02x%02x%02x%02x\r\n", dev_addr->addr[5],\
		                                             dev_addr->addr[4],\
		                                             dev_addr->addr[3],\
		                                             dev_addr->addr[2],\
		                                             dev_addr->addr[1],\
		                                             dev_addr->addr[0]);
        }

        APPL_LOG("[APPL]: PeerAddressType:  %d\r\n", p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr_type);
        APPL_LOG("[APPL]: PeerAddress (MSB): %02x%02x%02x%02x%02x%02x\r\n", p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[5],\
		                                             p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[4],\
		                                             p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[3],\
		                                             p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[2],\
		                                             p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[1],\
		                                             p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[0]);        }

ie the address of the device, resulting sd_ble_gap_address_get() function is different from the address stored in ble_gap_evt_connected_t structure.

Can anyone suggest what I'm doing wrong?

Related