This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr nRF52840 - How to get the MAC address of BLE

Hello All,

How can I get my nRF52840's MAC address in Zephyr? Actually, I want to append the last 4 characters of the MAC address in CONFIG_BT_DEVICE_NAME.

So, when I will check in nRF Connect App. I should get the name like ABC_12:2D.

Thanks and advance.

Regards,

Neeraj Dhekale

Parents Reply Children
  • I have already tried above URL. I was getting an error

     error: 'reinterpret_cast' undeclared (first use in this function)
       31 |  const uint8_t* part_0 = reinterpret_cast<const uint8_t*>(&device_addr_0);
          |                          ^~~~~~~~~~~~~~~~
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU/src/IG_Eddystone.h:31:26: note: each undeclared identifier is reported only once for each function it appears in
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU/src/IG_Eddystone.h:31:43: error: expected expression before 'const'
       31 |  const uint8_t* part_0 = reinterpret_cast<const uint8_t*>(&device_addr_0);
          |                                           ^~~~~
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU/src/IG_Eddystone.h:32:43: error: expected expression before 'const'
       32 |  const uint8_t* part_1 = reinterpret_cast<const uint8_t*>(&device_addr_1);
          |                                           ^~~~~
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU/src/IG_Eddystone.h:30:15: warning: unused variable 'device_addr_1' [-Wunused-variable]
       30 |  unsigned int device_addr_1 = NRF_FICR->DEVICEADDR[1];
          |               ^~~~~~~~~~~~~
    /home/neeraj/Applications/Nordic/IOTiansRockFall_IMU/src/IG_Eddystone.h:29:15: warning: unused variable 'device_addr_0' [-Wunused-variable]
       29 |  unsigned int device_addr_0 = NRF_FICR->DEVICEADDR[0];

    Thanks and regards,

    Neeraj

  • Try using bt_id_get() like Einar suggested. Check out the Zephyr Bluetooth Beacon sample to see how to use this function.

    Best regards,

    Simon

Related