Skip to content

Commit

Permalink
Fix race condition enabling access point
Browse files Browse the repository at this point in the history
With Basic_WiFi sample, system crashes in multicore.
If station is initialised *before* access point, this doesn't happen.
Deferring the call to `esp_wifi_start` fixes the issue.
  • Loading branch information
mikee47 committed Nov 25, 2024
1 parent ace7e33 commit 8e93a18
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void AccessPointImpl::enable(bool enabled, bool save)
}
}
ESP_ERROR_CHECK(esp_wifi_set_storage(save ? WIFI_STORAGE_FLASH : WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode((wifi_mode_t)mode));
ESP_ERROR_CHECK(esp_wifi_set_mode(mode));
}

bool AccessPointImpl::isEnabled() const
Expand Down Expand Up @@ -88,10 +88,13 @@ bool AccessPointImpl::config(const String& ssid, String password, WifiAuthMode m
config.ap.authmode = (wifi_auth_mode_t)mode;
config.ap.max_connection = 8;

bool enabled = isEnabled();
enable(true, false);

ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &config));
ESP_ERROR_CHECK(esp_wifi_start());
if(enabled) {
System.queueCallback(esp_wifi_start);
}

return true;
}
Expand Down

0 comments on commit 8e93a18

Please sign in to comment.