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,12 @@ 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+ ---help---
494+ With this choice, you can assign a fixed MAC address in the file
495+ device.info (DEVICE_INFO_PATH) defined by user.
496+
491497endchoice # MAC address selection
492498
493499config 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+ char macstr [20 ];
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,14 @@ 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+ boardctl (BOARDIOC_NET_GETMAC , (uintptr_t )macstr );
305+ if (netlib_ethaddrconv (macstr , wifi_mac ))
306+ {
307+ netlib_setmacaddr (NET_DEVNAME , wifi_mac );
308+ }
309+ #endif
310+
299311#if defined(CONFIG_NETINIT_UIDMAC )
300312 boardctl (BOARDIOC_UNIQUEID , (uintptr_t )& uid );
301313 uid [0 ] = (uid [0 ] & 0b11110000 ) | 2 ; /* Locally Administered MAC */
You can’t perform that action at this time.
0 commit comments