Reading/logging Wifi MAC address from main app

Hello,

We are using an nRF5340 + nRF7002 combo. We've been having trouble trying to read Wifi MAC addresses on provisioned devices without accessing OTP directly. From the main app, is there a way to read a Wifi MAC address similar to reading the Ethernet/link MAC address?

For example, reading the Ethernet MAC address is straightforward:

struct net_if *iface;
const struct net_linkaddr *link_addr;
char mac_addr_str[18];

// Iterate over all network interfaces to find the Wi-Fi interface
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(ETHERNET));
if (!iface) {
    shell_print(sh, "No Wi-Fi network interface found!");
    return;
}

link_addr = net_if_get_link_addr(iface);
if (!link_addr) {
    shell_print(sh, "No link address found for the Wi-Fi interface!");
    return;
}

snprintf(mac_addr_str, sizeof(mac_addr_str), "%02X:%02X:%02X:%02X:%02X:%02X",
         link_addr->addr[0], link_addr->addr[1], link_addr->addr[2],
         link_addr->addr[3], link_addr->addr[4], link_addr->addr[5]);

shell_print(sh, "Device MAC Address: %s", mac_addr_str);

Parents
  • Hi, 

    Could you use net_if_get_first_wifi() to get Wi-Fi interface in line#6?

    net_if_get_link_addr should work independently of the network interface. Could you please share logs in the failure case?

    We are currently understaffed due to the summer vacation period, so delayed replies must be expected. I am sorry about any inconvenience this might cause.

    -Amanda H.

Reply
  • Hi, 

    Could you use net_if_get_first_wifi() to get Wi-Fi interface in line#6?

    net_if_get_link_addr should work independently of the network interface. Could you please share logs in the failure case?

    We are currently understaffed due to the summer vacation period, so delayed replies must be expected. I am sorry about any inconvenience this might cause.

    -Amanda H.

Children
No Data
Related