File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -488,6 +488,13 @@ config NETINIT_SWMAC
488488 With this choice, you can assign a fixed MAC address determined by
489489 a NuttX configuration option.
490490
491+ config NETINIT_WIFIMAC
492+ bool "Device Wi-Fi MAC"
493+ depends on BOARDCTL_MACADDR
494+ ---help---
495+ With this choice, you can assign a fixed MAC address in the file
496+ device.info (DEVICE_INFO_PATH) defined by user.
497+
491498endchoice # MAC address selection
492499
493500config NETINIT_MACADDR_1
Original file line number Diff line number Diff line change @@ -286,6 +286,10 @@ static const uint16_t g_ipv6_netmask[8] =
286286 defined(HAVE_MAC )
287287static void netinit_set_macaddr (void )
288288{
289+ #if defined(CONFIG_NETINIT_WIFIMAC )
290+ struct boardioc_macaddr_s req ;
291+ uint8_t wifi_mac [IFHWADDRLEN ];
292+ #endif
289293#if defined(CONFIG_NETINIT_UIDMAC )
290294 uint8_t uid [CONFIG_BOARDCTL_UNIQUEID_SIZE ];
291295#elif defined(CONFIG_NET_ETHERNET )
@@ -296,6 +300,16 @@ static void netinit_set_macaddr(void)
296300
297301 /* Many embedded network interfaces must have a software assigned MAC */
298302
303+ #if defined(CONFIG_NETINIT_WIFIMAC )
304+ req .ifname = NET_DEVNAME ;
305+ req .mac = wifi_mac ;
306+
307+ if (boardctl (BOARDIOC_MACADDR , (uintptr_t )& req ) == 0 )
308+ {
309+ netlib_setmacaddr (NET_DEVNAME , wifi_mac );
310+ }
311+ #endif
312+
299313#if defined(CONFIG_NETINIT_UIDMAC )
300314 boardctl (BOARDIOC_UNIQUEID , (uintptr_t )& uid );
301315 uid [0 ] = (uid [0 ] & 0b11110000 ) | 2 ; /* Locally Administered MAC */
You can’t perform that action at this time.
0 commit comments