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

How to get connected device mac address ?

Hello I try to get the mac address of connected device

/**@brief Function for the application's SoftDevice event handler.
 *
 * @param[in] p_ble_evt SoftDevice event.
 */
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    uint32_t  err_code;
	
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

            //Connected device 
            ble_gap_addr_t  addr;
            memcpy(addr.addr, p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr, 6);
            mprintf(UART, " Connected to %X:%X:%X:%X:%X:%X AddrType:0x0%d\n", 
               addr.addr[5],addr.addr[4],addr.addr[3],
               addr.addr[2],addr.addr[1],addr.addr[0],
               p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr_type);

And I get

Connected to 54:2A:F2:4D:0:89 AddrType:0x02

The address given by my Android is [A0:39:F7:0E:28:C7]. So I expect to have this address.

What can be the mistakes ?

Thanks.

Related