@@ -210,6 +210,10 @@ void ConfigurationManager_EnumerateConfigurationBlocks()
210210
211211 // have to enumerate again to pick it up
212212 networkConfigs = ConfigStorage_FindNetworkConfigurationBlocks ();
213+ if (!networkConfigs) {
214+ ESP_LOGE (TAG, " Re-enumeration of config returned NULL" );
215+ return ;
216+ }
213217 ESP_LOGI (TAG, " networkCount %d/%d" , networkCount, networkConfigs->Count );
214218 }
215219
@@ -356,7 +360,7 @@ void InitialiseWirelessAPDefaultConfig(HAL_Configuration_WirelessAP *config, uin
356360// Default initialisation of Network interface config blocks for ESP32 targets
357361bool InitialiseNetworkDefaultConfig (HAL_Configuration_NetworkInterface *config, uint32_t configurationIndex)
358362{
359- esp_err_t err = ESP_OK ;
363+ int macType = - 1 ;
360364
361365 // make sure the config block marker is set
362366 memcpy (config->Marker , c_MARKER_CONFIGURATION_NETWORK_V1, sizeof (c_MARKER_CONFIGURATION_NETWORK_V1));
@@ -367,29 +371,23 @@ bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface *config,
367371 config->StartupAddressMode = AddressMode_DHCP;
368372 config->AutomaticDNS = 1 ;
369373 config->SpecificConfigId = 0 ;
370-
371- // get default MAC for interface
372- err = esp_read_mac (config->MacAddress , ESP_MAC_WIFI_STA);
374+ macType = ESP_MAC_WIFI_STA;
373375 break ;
374376
375377 case NetworkInterfaceType_WirelessAP: // Wireless AP
376378 config->StartupAddressMode = AddressMode_Static;
377379 config->SpecificConfigId = 0 ;
380+ macType = ESP_MAC_WIFI_SOFTAP;
378381 // Set default address 192.168.1.1
379382 // config->IPv4Address
380383 // config->IPv4NetMask
381384 // config->IPv4GatewayAddress
382-
383- // get default MAC for interface
384- err = esp_read_mac (config->MacAddress , ESP_MAC_WIFI_SOFTAP);
385385 break ;
386386
387387 case NetworkInterfaceType_Ethernet: // Ethernet
388388 config->StartupAddressMode = AddressMode_DHCP;
389389 config->AutomaticDNS = 1 ;
390-
391- // get default MAC for interface
392- err = esp_read_mac (config->MacAddress , ESP_MAC_ETH);
390+ macType = ESP_MAC_ETH;
393391 break ;
394392
395393#if HAL_USE_THREAD == TRUE
@@ -403,10 +401,15 @@ bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface *config,
403401 break ;
404402 }
405403
406- if (err != ESP_OK )
404+ if (macType != - 1 )
407405 {
408- // On ESP32_P4 esp_read_mac can fail
409- esp_efuse_mac_get_default (config->MacAddress );
406+ // get default MAC for interface
407+ if (esp_read_mac (config->MacAddress , (esp_mac_type_t )macType) != ESP_OK)
408+ {
409+ // On ESP32_P4 esp_read_mac can fail with host wifi
410+ esp_efuse_mac_get_default (config->MacAddress );
411+ config->MacAddress [5 ] += macType; // make sure each interface has a different MAC
412+ }
410413 }
411414
412415 // always good
0 commit comments