Skip to content

Commit 9704169

Browse files
committed
Fix WiFi compile guards
Correctly reset wifi connection attempts, not timeout.
1 parent f3749ad commit 9704169

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

Firmware/RTK_Surveyor/Form.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ void stopWebServer()
164164

165165
if (websocket != NULL)
166166
{
167-
websocket->end()
168167
delete websocket;
169168
websocket = NULL;
170169
}

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ bool sdSizeCheckTaskComplete = false;
172172

173173
#include "base64.h" //Built-in. Needed for NTRIP Client credential encoding.
174174

175-
static int wifiConnectionAttempts = 0; //Count the number of connection attempts between restarts
176175
static int ntripClientConnectionAttempts = 0; //Count the number of connection attempts between restarts
177176
static int ntripServerConnectionAttempts = 0; //Count the number of connection attempts between restarts
178177

Firmware/RTK_Surveyor/WiFi.ino

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ static const int WIFI_IP_ADDRESS_DISPLAY_INTERVAL = 12 * 1000; //Milliseconds
3838

3939
//Give up connecting after this number of attempts
4040
//Connection attempts are throttled to increase the time between attempts
41-
//30 attempts with 15 second increases will take almost two hours
42-
static const int MAX_WIFI_CONNECTION_ATTEMPTS = 30;
41+
static const int MAX_WIFI_CONNECTION_ATTEMPTS = 500;
4342

4443
#define WIFI_MAX_TCP_CLIENTS 4
4544

45+
//Throttle the time between connection attempts
46+
//ms - Max of 4,294,967,295 or 4.3M seconds or 71,000 minutes or 1193 hours or 49 days between attempts
47+
static int wifiConnectionAttempts = 0; //Count the number of connection attempts between restarts
48+
static uint32_t wifiConnectionAttemptsTotal; //Count the number of connection attempts absolutely
49+
static uint32_t wifiLastConnectionAttempt = 0;
50+
static uint32_t wifiConnectionAttemptTimeout = 0;
51+
4652
//----------------------------------------
4753
// Locals - compiled out
4854
//----------------------------------------
@@ -60,12 +66,6 @@ static uint32_t lastWifiState = 0;
6066
static WiFiServer *wifiTcpServer = NULL;
6167
static WiFiClient wifiTcpClient[WIFI_MAX_TCP_CLIENTS];
6268

63-
//Throttle the time between connection attempts
64-
//ms - Max of 4,294,967,295 or 4.3M seconds or 71,000 minutes or 1193 hours or 49 days between attempts
65-
static uint32_t wifiConnectionAttemptsTotal; //Count the number of connection attempts absolutely
66-
static uint32_t wifiLastConnectionAttempt = 0;
67-
static uint32_t wifiConnectionAttemptTimeout = 0;
68-
6969
//----------------------------------------
7070
// WiFi Routines - compiled out
7171
//----------------------------------------
@@ -231,7 +231,7 @@ void wifiUpdate()
231231
if (wifiIsConnected() == false)
232232
{
233233
log_d("WiFi link lost");
234-
wifiConnectionAttemptTimeout = 0; //Reset the timeout
234+
wifiConnectionAttempts = 0; //Reset the timeout
235235
wifiSetState(WIFI_CONNECTING);
236236
}
237237
else
@@ -243,9 +243,8 @@ void wifiUpdate()
243243
wifiStop();
244244
}
245245
break;
246-
247-
#endif //COMPILE_WIFI
248246
}
247+
#endif //COMPILE_WIFI
249248
}
250249

251250
//Starts the WiFi connection state machine (moves from WIFI_OFF to WIFI_CONNECTING)
@@ -332,8 +331,8 @@ void wifiStop()
332331
}
333332

334333
wifiSetState(WIFI_OFF);
335-
336-
wifiConnectionAttemptTimeout = 0; //Reset the timeout
334+
335+
wifiConnectionAttempts = 0; //Reset the timeout
337336

338337
#ifdef COMPILE_ESPNOW
339338
//If WiFi is on but ESP NOW is off, then turn off radio entirely
@@ -366,11 +365,15 @@ void wifiStop()
366365

367366
bool wifiIsConnected()
368367
{
368+
#ifdef COMPILE_WIFI
369369
bool isConnected = (wifiGetStatus() == WL_CONNECTED);
370370
if (isConnected)
371371
wifiPeriodicallyDisplayIpAddress();
372372

373373
return isConnected;
374+
#else
375+
return false;
376+
#endif
374377
}
375378

376379
//Attempts a connection to all provided SSIDs

0 commit comments

Comments
 (0)