How to get Mac address using NRF5340_DK

I want to get mac address   using   NRF5340_DK

Which function is used to get   print mac address   using   NRF5340_DK.

I try to   print   the   current device's   MAC address   using   NRF5340_DK. So

 

Parents Reply
  • Hi,

    Ah, you are right, that does not work with the random static address. I tested now, and bt_read_static_addr() works. You can use it like this:

    	static char addr_str[BT_ADDR_STR_LEN];
    	struct bt_hci_vs_static_addr addr;
    	int addr_count;
    
    	addr_count = bt_read_static_addr(&addr, 1);
    
    	if (addr_count > 0)
    	{
    		bt_addr_to_str(&(addr.bdaddr), addr_str, sizeof(addr_str));
    		printk("BT addr: %s\n", addr_str);
    	}

    Note that you need the following includes:

    #include <zephyr/bluetooth/hci_vs.h>
    #include <zephyr/drivers/bluetooth/hci_driver.h>

    And also need CONFIG_BT_HCI_VS_EXT=y in your prj.conf or similar.

Children
Related