Skip to content

Commit 1131bd2

Browse files
committed
Check whether WIFI is open before closing
1 parent a35f474 commit 1131bd2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

components/wifiManager/wifiManager/wifiManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ void WiFiManager::ConnectWithHardcodedCredentials()
102102
{
103103
SystemEvent event = {EventSource::WIFI, WiFiState_e::WiFiState_ReadyToConnect};
104104
this->SetCredentials(CONFIG_WIFI_SSID, CONFIG_WIFI_PASSWORD);
105-
// Skip esp_wifi_stop() on first connection - WiFi not started yet
105+
106+
wifi_mode_t mode;
107+
if (esp_wifi_get_mode(&mode) == ESP_OK) {
108+
esp_wifi_stop();
109+
}
110+
106111
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
107112
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &_wifi_cfg));
108113

0 commit comments

Comments
 (0)