how to set USB serialnumber as the ble mac address

Hi,

    my product now is base on the nrf5340,  I want to set the USB's serialnumber same as the ble mac address.

    when I use the nrf52840,  I can set it as follows simply.

    

int32_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
{
    uint16_t serial_num_high_bytes = sys_cpu_to_be16(((NRF_FICR->  DEVICEADDR[1]) & 0xffff) | 0xC000);
    uint32_t serial_num_low_bytes  = sys_cpu_to_be32(NRF_FICR->DEVICEADDR[0]);

    memcpy(buffer, (uint8_t *)&serial_num_high_bytes, 2);
    memcpy(buffer + 2, (uint8_t *)&serial_num_low_bytes, 4);
    return 6;
}

    I found the DEVCIEADDR in the network core,  but it is not accessible from the application core. 

    is there another way to set the USB serialnumber dynamically?

Parents
  • Hi,

    I apologize for the late response.

    You can get the DEVICEADDR on the application core by including hci_vs.h:

    #include <bluetooth/hci_vs.h>

    Then use a hci command to read the static addresses:

    struct net_buf * rsp;
    err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_STATIC_ADDRS, NULL, &rsp);
    if (err) {
    	printk("Failed to read DEVICEADDR Err: %d\n", err);
    }

    Let me know if you have any issues.

Reply
  • Hi,

    I apologize for the late response.

    You can get the DEVICEADDR on the application core by including hci_vs.h:

    #include <bluetooth/hci_vs.h>

    Then use a hci command to read the static addresses:

    struct net_buf * rsp;
    err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_STATIC_ADDRS, NULL, &rsp);
    if (err) {
    	printk("Failed to read DEVICEADDR Err: %d\n", err);
    }

    Let me know if you have any issues.

Children
Related