Using FICR device address with hci_uart example from NCS on nRF52x

Hi,

is it possible to configure the hci_uart example from NCS in a way that the FICR device address of a nRF52840 is used as public device address? I cloned and compiled the project without any changes and would like the controller to use the hardware device address without providing a static random address from the host. 

Regards,
Oliver

  • Found a solution in the meantime:

    Using bt_ctlr_set_public_addr from bluetooth/controller.h I can set the public address:

    static void get_device_address(uint8_t mac_address[6]) {
      unsigned int device_addr_0 = NRF_FICR->DEVICEADDR[0];
      unsigned int device_addr_1 = NRF_FICR->DEVICEADDR[1];
      const uint8_t *part_0 = (const uint8_t *)(&device_addr_0);
      const uint8_t *part_1 = (const uint8_t *)(&device_addr_1);
      mac_address[0] = part_1[1];
      mac_address[1] = part_1[0];
      mac_address[2] = part_0[3];
      mac_address[3] = part_0[2];
      mac_address[4] = part_0[1];
      mac_address[5] = part_0[0];
    
      LOG_HEXDUMP_DBG(mac_address, 6, "Address");
    }
    
    void main(void) {
      ...
    
      uint8_t address[6];
      get_mac_address(address);
      bt_ctlr_set_public_addr(address);
    
      /* Enable the raw interface, this will in turn open the HCI driver */
      bt_enable_raw(&rx_queue);
      
      ...
    }

    Thanks to  Retrieve BLE MAC address in Zephyr environment  for implementation of get_device_address().

  • Hi Oliver, 

    I was working on your case. Good to know that you found a solution.

    Here is how I solved it:

    We can use NRF_FICR structure to read device ID, and we can use bt_ctlr_set_public_addr() to set the address read.

       
    DA[0] = NRF_FICR->DEVICEID[0];
    DA[1] = NRF_FICR->DEVICEID[1];
    bt_ctlr_set_public_addr(DA);

    Thanks and regards,

    Naeem

Related