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,7 +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_UIDMAC )
289+ #if defined(CONFIG_NETINIT_WIFIMAC )
290+ char macstr [20 ];
291+ uint8_t wifi_mac [IFHWADDRLEN ];
292+ #elif defined(CONFIG_NETINIT_UIDMAC )
290293 uint8_t uid [CONFIG_BOARDCTL_UNIQUEID_SIZE ];
291294#elif defined(CONFIG_NET_ETHERNET )
292295 uint8_t mac [IFHWADDRLEN ];
@@ -296,7 +299,15 @@ static void netinit_set_macaddr(void)
296299
297300 /* Many embedded network interfaces must have a software assigned MAC */
298301
299- #if defined(CONFIG_NETINIT_UIDMAC )
302+ #if defined(CONFIG_NETINIT_WIFIMAC )
303+ #define BOARDIOC_USER_MAC_WIFI (BOARDIOC_USER + 3)
304+
305+ boardctl (BOARDIOC_USER_MAC_WIFI , (uintptr_t )macstr );
306+ if (netlib_ethaddrconv (macstr , wifi_mac ))
307+ {
308+ netlib_setmacaddr (NET_DEVNAME , wifi_mac );
309+ }
310+ #elif defined(CONFIG_NETINIT_UIDMAC )
300311 boardctl (BOARDIOC_UNIQUEID , (uintptr_t )& uid );
301312 uid [0 ] = (uid [0 ] & 0b11110000 ) | 2 ; /* Locally Administered MAC */
302313 netlib_setmacaddr (NET_DEVNAME , uid );
You can’t perform that action at this time.
0 commit comments