File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -209,15 +209,23 @@ bool wifiConnectionTimeout()
209209void wifiStart (char * ssid, char * pw)
210210{
211211#ifdef COMPILE_WIFI
212+ bool restartESPNow = false ;
213+
212214 if ((wifiState == WIFI_OFF) || (wifiState == WIFI_ON))
213215 {
214216 wifiSetState (WIFI_NOTCONNECTED);
215217
216218#ifdef COMPILE_ESPNOW
217219 if (espnowState > ESPNOW_OFF)
220+ {
221+ restartESPNow = true ;
222+ espnowStop ();
218223 esp_wifi_set_protocol (WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR); // Enable WiFi + ESP-Now. Stops WiFi Station.
224+ }
219225 else
226+ {
220227 esp_wifi_set_protocol (WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N); // Set basic WiFi protocols. Stops WiFi Station.
228+ }
221229#else
222230 // Be sure the standard protocols are turned on. ESP Now have have previously turned them off.
223231 esp_wifi_set_protocol (WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N); // Set basic WiFi protocols. Stops WiFi Station.
@@ -229,6 +237,11 @@ void wifiStart(char* ssid, char* pw)
229237 WiFi.begin (ssid, pw);
230238 wifiTimer = millis ();
231239
240+ #ifdef COMPILE_ESPNOW
241+ if (restartESPNow == true )
242+ espnowStart ();
243+ #endif
244+
232245 // Display the heap state
233246 reportHeapNow ();
234247 }
You can’t perform that action at this time.
0 commit comments