@@ -23,6 +23,8 @@ bool restartWiFi = false; // Restart WiFi if user changes anything
23
23
24
24
#ifdef COMPILE_WIFI
25
25
26
+ WiFiMulti *wifiMulti;
27
+
26
28
// ----------------------------------------
27
29
// Constants
28
30
// ----------------------------------------
@@ -213,18 +215,19 @@ bool wifiConnect(unsigned long timeout, bool useAPSTAMode, bool *wasInAPmode)
213
215
214
216
systemPrintln (" Connecting WiFi... " );
215
217
216
- static WiFiMulti wifiMulti;
218
+ if (wifiMulti == nullptr )
219
+ wifiMulti = new WiFiMulti;
217
220
218
221
// Load SSIDs
219
- wifiMulti. APlistClean ();
222
+ wifiMulti-> APlistClean ();
220
223
for (int x = 0 ; x < MAX_WIFI_NETWORKS; x++)
221
224
{
222
225
if (strlen (settings.wifiNetworks [x].ssid ) > 0 )
223
- wifiMulti. addAP ((const char *)&settings.wifiNetworks [x].ssid ,
224
- (const char *)&settings.wifiNetworks [x].password );
226
+ wifiMulti-> addAP ((const char *)&settings.wifiNetworks [x].ssid ,
227
+ (const char *)&settings.wifiNetworks [x].password );
225
228
}
226
229
227
- int wifiStatus = wifiMulti. run (timeout);
230
+ int wifiStatus = wifiMulti-> run (timeout);
228
231
if (wifiStatus == WL_CONNECTED)
229
232
{
230
233
wifiRunning = true ;
@@ -585,6 +588,9 @@ void wifiStop()
585
588
// Take the network offline
586
589
networkMarkOffline (NETWORK_WIFI);
587
590
591
+ if (wifiMulti != nullptr )
592
+ wifiMulti = nullptr ;
593
+
588
594
// Display the heap state
589
595
reportHeapNow (settings.debugWifiState );
590
596
wifiRunning = false ;
0 commit comments