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.

Parents
  • I found this information:

    There are 4 types of addresses defined for BLE:

    Public IEEE Format– Manufacturer specific IEEE Bluetooth address and company identifiers can be purchased through the IEEE Registration Authority.

    Random Static– Burned into radio silicon upon shipment or can be randomly generated to a new value at each power cycle.

    Random Private Resolvable– Used in bonded devices and requires the Identity Resolving Key (IRK) be shared during Phase 3 of the pairing procedure. This changes periodically based on a timer or other method. This is the default use case for iOS devices and for Android devices with Lollipop or newer.

    Random Private Non-Resolvable– Shared between bonded devices for use during reconnection. This changes with each connection.

    See also GAP Address types [closed] and How to distinguish between random and public GAP addresses?

Reply
  • I found this information:

    There are 4 types of addresses defined for BLE:

    Public IEEE Format– Manufacturer specific IEEE Bluetooth address and company identifiers can be purchased through the IEEE Registration Authority.

    Random Static– Burned into radio silicon upon shipment or can be randomly generated to a new value at each power cycle.

    Random Private Resolvable– Used in bonded devices and requires the Identity Resolving Key (IRK) be shared during Phase 3 of the pairing procedure. This changes periodically based on a timer or other method. This is the default use case for iOS devices and for Android devices with Lollipop or newer.

    Random Private Non-Resolvable– Shared between bonded devices for use during reconnection. This changes with each connection.

    See also GAP Address types [closed] and How to distinguish between random and public GAP addresses?

Children
No Data
Related