How do I obtain unique connectable BLE MAC address for my device ?

Zephyr / SDK 2.1.2 / nRF52833, acting as BLE peripheral.
My system consists of multiple peripherals, and I want each of these peripherals broadcast its own unique MAC address via non-connectable advertisement
Central device (which doesn't use Nordic) will use it to chose peripheral to connect to when such peripheral sends connectable advertisement.

Question - how can I obtain this MAC address ?

static void connected(struct bt_conn *conn, uint8_t err)
{
if (err)
{
printk("Connection failed (err %u)\n", err);
return;
}

//Generate random data for challenge on every new conenction
bt_rand(challenge_buf, BLE_CHALLENGE_LENGTH);

//Reset the authenticated flag for every new connection
is_ble_authenticated = false;

printk("Connected with MTU(%u)\n", bt_nus_get_mtu(conn));
struct bt_conn_info conn_info;
if(bt_conn_get_info(conn, &conn_info)) {
printk("connected: failed to get connection info\n");
}
if(conn_info.state != BT_CONN_STATE_CONNECTED) {
printk("connected, but connection state is NOT connected ???\n");
}
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(conn_info.le.src, addr, sizeof(addr));
printk("My MAC addr is %s\n", addr);

I get same MAC address printed every time I connect to this device,
but I'm concerned that it is marked as "random" because addr->type is BT_ADDR_LE_RANDOM

Parents
  • Hi,

    By default you will get a random static address. This address is fixed throughout the lifetime of the device, and technically it is fetched from the DEVICEADDR registers in FICR.

    The main exception to this is if you set CONFIG_BT_PRIVACY, which will change the address type to a resolvable random private address instead.

    Please note that a static address is not necessarily wanted, due to privacy reasons. If you have a fixed peer which will reconnect to your device, then resolvable random private addresses may actually be a better option. After establishing a bond on the first connection, the peer will then be able to recognize and reconnect to your device, even if it uses resolvable random private addresses, since with the bonding data your peer will be able to resolve the address.

    For more information on addresses, see e.g. Bluetooth address.

    Regards,
    Terje

Reply
  • Hi,

    By default you will get a random static address. This address is fixed throughout the lifetime of the device, and technically it is fetched from the DEVICEADDR registers in FICR.

    The main exception to this is if you set CONFIG_BT_PRIVACY, which will change the address type to a resolvable random private address instead.

    Please note that a static address is not necessarily wanted, due to privacy reasons. If you have a fixed peer which will reconnect to your device, then resolvable random private addresses may actually be a better option. After establishing a bond on the first connection, the peer will then be able to recognize and reconnect to your device, even if it uses resolvable random private addresses, since with the bonding data your peer will be able to resolve the address.

    For more information on addresses, see e.g. Bluetooth address.

    Regards,
    Terje

Children
No Data
Related