@@ -210,6 +210,10 @@ void ConfigurationManager_EnumerateConfigurationBlocks()
210
210
211
211
// have to enumerate again to pick it up
212
212
networkConfigs = ConfigStorage_FindNetworkConfigurationBlocks ();
213
+ if (!networkConfigs) {
214
+ ESP_LOGE (TAG, " Re-enumeration of config returned NULL" );
215
+ return ;
216
+ }
213
217
ESP_LOGI (TAG, " networkCount %d/%d" , networkCount, networkConfigs->Count );
214
218
}
215
219
@@ -356,7 +360,7 @@ void InitialiseWirelessAPDefaultConfig(HAL_Configuration_WirelessAP *config, uin
356
360
// Default initialisation of Network interface config blocks for ESP32 targets
357
361
bool InitialiseNetworkDefaultConfig (HAL_Configuration_NetworkInterface *config, uint32_t configurationIndex)
358
362
{
359
- esp_err_t err = ESP_OK ;
363
+ int macType = - 1 ;
360
364
361
365
// make sure the config block marker is set
362
366
memcpy (config->Marker , c_MARKER_CONFIGURATION_NETWORK_V1, sizeof (c_MARKER_CONFIGURATION_NETWORK_V1));
@@ -367,29 +371,23 @@ bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface *config,
367
371
config->StartupAddressMode = AddressMode_DHCP;
368
372
config->AutomaticDNS = 1 ;
369
373
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;
373
375
break ;
374
376
375
377
case NetworkInterfaceType_WirelessAP: // Wireless AP
376
378
config->StartupAddressMode = AddressMode_Static;
377
379
config->SpecificConfigId = 0 ;
380
+ macType = ESP_MAC_WIFI_SOFTAP;
378
381
// Set default address 192.168.1.1
379
382
// config->IPv4Address
380
383
// config->IPv4NetMask
381
384
// config->IPv4GatewayAddress
382
-
383
- // get default MAC for interface
384
- err = esp_read_mac (config->MacAddress , ESP_MAC_WIFI_SOFTAP);
385
385
break ;
386
386
387
387
case NetworkInterfaceType_Ethernet: // Ethernet
388
388
config->StartupAddressMode = AddressMode_DHCP;
389
389
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;
393
391
break ;
394
392
395
393
#if HAL_USE_THREAD == TRUE
@@ -403,10 +401,15 @@ bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface *config,
403
401
break ;
404
402
}
405
403
406
- if (err != ESP_OK )
404
+ if (macType != - 1 )
407
405
{
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
+ }
410
413
}
411
414
412
415
// always good
0 commit comments