Skip to content

Commit 2c77152

Browse files
committed
Move wifiMulti to pointer
1 parent ec03482 commit 2c77152

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ bool restartWiFi = false; // Restart WiFi if user changes anything
2323

2424
#ifdef COMPILE_WIFI
2525

26+
WiFiMulti *wifiMulti;
27+
2628
//----------------------------------------
2729
// Constants
2830
//----------------------------------------
@@ -213,18 +215,19 @@ bool wifiConnect(unsigned long timeout, bool useAPSTAMode, bool *wasInAPmode)
213215

214216
systemPrintln("Connecting WiFi... ");
215217

216-
static WiFiMulti wifiMulti;
218+
if (wifiMulti == nullptr)
219+
wifiMulti = new WiFiMulti;
217220

218221
// Load SSIDs
219-
wifiMulti.APlistClean();
222+
wifiMulti->APlistClean();
220223
for (int x = 0; x < MAX_WIFI_NETWORKS; x++)
221224
{
222225
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);
225228
}
226229

227-
int wifiStatus = wifiMulti.run(timeout);
230+
int wifiStatus = wifiMulti->run(timeout);
228231
if (wifiStatus == WL_CONNECTED)
229232
{
230233
wifiRunning = true;
@@ -585,6 +588,9 @@ void wifiStop()
585588
// Take the network offline
586589
networkMarkOffline(NETWORK_WIFI);
587590

591+
if (wifiMulti != nullptr)
592+
wifiMulti = nullptr;
593+
588594
// Display the heap state
589595
reportHeapNow(settings.debugWifiState);
590596
wifiRunning = false;

0 commit comments

Comments
 (0)