Skip to content

Commit aa87640

Browse files
committed
Properly separate WiFi state values from WiFi mode values
1 parent a04793d commit aa87640

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

Firmware/RTK_Surveyor/Display.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ uint32_t setRadioIcons()
752752

753753
// Count the number of radios in use
754754
uint8_t numberOfRadios = 1; // Bluetooth always indicated. TODO don't count if BT radio type is OFF.
755-
if (wifiState > WIFI_OFF)
755+
if (wifiState > WIFI_STATE_OFF)
756756
numberOfRadios++;
757757
if (espnowState > ESPNOW_OFF)
758758
numberOfRadios++;
@@ -770,7 +770,7 @@ uint32_t setRadioIcons()
770770
icons |= setBluetoothIcon_TwoRadios();
771771

772772
// Do we have WiFi or ESP
773-
if (wifiState > WIFI_OFF)
773+
if (wifiState > WIFI_STATE_OFF)
774774
icons |= setWiFiIcon_TwoRadios();
775775
else if (espnowState > ESPNOW_OFF)
776776
icons |= setESPNowIcon_TwoRadios();
@@ -968,7 +968,7 @@ uint32_t setWiFiIcon_TwoRadios()
968968
{
969969
uint32_t icons = 0;
970970

971-
if (wifiState == WIFI_CONNECTED)
971+
if (wifiState == WIFI_STATE_CONNECTED)
972972
{
973973
// Limit how often we update this spot
974974
if (millis() - firstRadioSpotTimer > 2000)
@@ -1055,7 +1055,7 @@ uint32_t setWiFiIcon_ThreeRadios()
10551055
{
10561056
uint32_t icons = 0;
10571057

1058-
if (wifiState == WIFI_CONNECTED)
1058+
if (wifiState == WIFI_STATE_CONNECTED)
10591059
{
10601060
// Limit how often we update this spot
10611061
if (millis() - thirdRadioSpotTimer > 2000)
@@ -1144,7 +1144,7 @@ uint32_t setWiFiIcon()
11441144

11451145
if (online.display == true)
11461146
{
1147-
if (wifiState == WIFI_CONNECTED)
1147+
if (wifiState == WIFI_STATE_CONNECTED)
11481148
{
11491149
icons |= ICON_WIFI_SYMBOL_3_RIGHT;
11501150
}
@@ -3384,7 +3384,7 @@ const uint8_t *getMacAddress()
33843384
return btMACAddress;
33853385
#endif // COMPILE_BT
33863386
#ifdef COMPILE_WIFI
3387-
if (wifiState != WIFI_OFF)
3387+
if (wifiState != WIFI_STATE_OFF)
33883388
return wifiMACAddress;
33893389
#endif // COMPILE_WIFI
33903390
#ifdef COMPILE_ETHERNET

Firmware/RTK_Surveyor/ESPNOW.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void espnowStart()
9898

9999
esp_err_t response;
100100

101-
if (wifiState == WIFI_OFF && espnowState == ESPNOW_OFF)
101+
if (wifiState == WIFI_STATE_OFF && espnowState == ESPNOW_OFF)
102102
{
103103
if (WiFi.getMode() != WIFI_STA)
104104
WiFi.mode(WIFI_STA);
@@ -112,7 +112,7 @@ void espnowStart()
112112
log_d("WiFi off, ESP-Now added to protocols");
113113
}
114114
// If WiFi is on but ESP NOW is off, then enable LR protocol
115-
else if (wifiState > WIFI_OFF && espnowState == ESPNOW_OFF)
115+
else if (wifiState > WIFI_STATE_OFF && espnowState == ESPNOW_OFF)
116116
{
117117
if (WiFi.getMode() != WIFI_STA)
118118
WiFi.mode(WIFI_STA);
@@ -239,15 +239,15 @@ void espnowStop()
239239

240240
espnowSetState(ESPNOW_OFF);
241241

242-
if (wifiState == WIFI_OFF)
242+
if (wifiState == WIFI_STATE_OFF)
243243
{
244244
// ESP Now was the only thing using the radio so turn WiFi radio off entirely
245245
WiFi.mode(WIFI_OFF);
246246

247247
log_d("WiFi Radio off entirely");
248248
}
249249
// If WiFi is on, then restart WiFi
250-
else if (wifiState > WIFI_OFF)
250+
else if (wifiState > WIFI_STATE_OFF)
251251
{
252252
log_d("ESP-Now starting WiFi");
253253
wifiStart(); // Force WiFi to restart

Firmware/RTK_Surveyor/NtripClient.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ NtripClient.ino
8282
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8383
NTRIP Client States:
8484
NTRIP_CLIENT_OFF: Network off or using NTRIP server
85-
NTRIP_CLIENT_ON: WIFI_START state
85+
NTRIP_CLIENT_ON: WIFI_STATE_START state
8686
NTRIP_CLIENT_NETWORK_STARTED: Connecting to the network
8787
NTRIP_CLIENT_NETWORK_CONNECTED: Connected to the network
8888
NTRIP_CLIENT_CONNECTING: Attempting a connection to the NTRIP caster
@@ -152,7 +152,7 @@ static const int NTRIP_CLIENT_CONNECTION_TIME = 5 * 60 * 1000;
152152
enum NTRIPClientState
153153
{
154154
NTRIP_CLIENT_OFF = 0, // Using Bluetooth or NTRIP server
155-
NTRIP_CLIENT_ON, // WIFI_START state
155+
NTRIP_CLIENT_ON, // WIFI_STATE_START state
156156
NTRIP_CLIENT_NETWORK_STARTED, // Connecting to WiFi access point or Ethernet
157157
NTRIP_CLIENT_NETWORK_CONNECTED, // Connected to an access point or Ethernet
158158
NTRIP_CLIENT_CONNECTING, // Attempting a connection to the NTRIP caster

Firmware/RTK_Surveyor/NtripServer.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ NtripServer.ino
8282
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8383
NTRIP Server States:
8484
NTRIP_SERVER_OFF: Network off or using NTRIP Client
85-
NTRIP_SERVER_ON: WIFI_START state
85+
NTRIP_SERVER_ON: WIFI_STATE_START state
8686
NTRIP_SERVER_NETWORK_STARTED: Connecting to the network
8787
NTRIP_SERVER_NETWORK_CONNECTED: Connected to the network
8888
NTRIP_SERVER_WAIT_GNSS_DATA: Waiting for correction data from GNSS
@@ -145,7 +145,7 @@ static const int NTRIP_SERVER_CONNECTION_TIME = 5 * 60 * 1000;
145145
enum NTRIPServerState
146146
{
147147
NTRIP_SERVER_OFF = 0, // Using Bluetooth or NTRIP client
148-
NTRIP_SERVER_ON, // WIFI_START state
148+
NTRIP_SERVER_ON, // WIFI_STATE_START state
149149
NTRIP_SERVER_NETWORK_STARTED, // Connecting to WiFi access point
150150
NTRIP_SERVER_NETWORK_CONNECTED, // WiFi connected to an access point
151151
NTRIP_SERVER_WAIT_GNSS_DATA, // Waiting for correction data from GNSS

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ void updateBTled()
10171017
ledcWrite(ledBTChannel, 255);
10181018

10191019
// Pulse LED while no BT and we wait for WiFi connection
1020-
else if (wifiState == WIFI_CONNECTING || wifiState == WIFI_CONNECTED)
1020+
else if (wifiState == WIFI_STATE_CONNECTING || wifiState == WIFI_STATE_CONNECTED)
10211021
{
10221022
// Fade in/out the BT LED during WiFi AP mode
10231023
btFadeLevel += pwmFadeAmount;

Firmware/RTK_Surveyor/WiFi.ino

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
1515
WiFi Station States:
1616
17-
WIFI_OFF<--------------------.
17+
WIFI_STATE_OFF<-------------------.
1818
| |
1919
wifiStart() | |
2020
| | WL_CONNECT_FAILED (Bad password)
2121
| | WL_NO_SSID_AVAIL (Out of range)
2222
v Fail |
23-
WIFI_CONNECTING------------->+
23+
WIFI_STATE_CONNECTING------------->+
2424
| ^ ^
2525
wifiConnect() | | | wifiShutdown()
2626
| | WL_CONNECTION_LOST |
2727
| | WL_DISCONNECTED |
2828
v | |
29-
WIFI_CONNECTED --------------'
29+
WIFI_STATE_CONNECTED -------------'
3030
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3131

3232
//----------------------------------------
@@ -196,17 +196,17 @@ void wifiSetState(byte newState)
196196
default:
197197
systemPrintf("Unknown WiFi state: %d\r\n", newState);
198198
break;
199-
case WIFI_OFF:
200-
systemPrintln("WIFI_OFF");
199+
case WIFI_STATE_OFF:
200+
systemPrintln("WIFI_STATE_OFF");
201201
break;
202-
case WIFI_START:
203-
systemPrintln("WIFI_START");
202+
case WIFI_STATE_START:
203+
systemPrintln("WIFI_STATE_START");
204204
break;
205-
case WIFI_CONNECTING:
206-
systemPrintln("WIFI_CONNECTING");
205+
case WIFI_STATE_CONNECTING:
206+
systemPrintln("WIFI_STATE_CONNECTING");
207207
break;
208-
case WIFI_CONNECTED:
209-
systemPrintln("WIFI_CONNECTED");
208+
case WIFI_STATE_CONNECTED:
209+
systemPrintln("WIFI_STATE_CONNECTED");
210210
break;
211211
}
212212
}
@@ -322,11 +322,11 @@ void wifiUpdate()
322322
systemPrintf("Unknown wifiState: %d\r\n", wifiState);
323323
break;
324324

325-
case WIFI_OFF:
325+
case WIFI_STATE_OFF:
326326
// Any service that needs WiFi will call wifiStart()
327327
break;
328328

329-
case WIFI_CONNECTING:
329+
case WIFI_STATE_CONNECTING:
330330
// Pause until connection timeout has passed
331331
if (millis() - wifiLastConnectionAttempt > wifiConnectionAttemptTimeout)
332332
{
@@ -337,7 +337,7 @@ void wifiUpdate()
337337
if (espnowState > ESPNOW_OFF)
338338
espnowStart();
339339

340-
wifiSetState(WIFI_CONNECTED);
340+
wifiSetState(WIFI_STATE_CONNECTED);
341341
}
342342
else
343343
{
@@ -353,20 +353,20 @@ void wifiUpdate()
353353
{
354354
systemPrintln("WiFi connection failed. Giving up.");
355355
displayNoWiFi(2000);
356-
WIFI_STOP(); // Move back to WIFI_OFF
356+
WIFI_STOP(); // Move back to WIFI_STATE_OFF
357357
}
358358
}
359359
}
360360

361361
break;
362362

363-
case WIFI_CONNECTED:
363+
case WIFI_STATE_CONNECTED:
364364
// Verify link is still up
365365
if (wifiIsConnected() == false)
366366
{
367367
systemPrintln("WiFi link lost");
368368
wifiConnectionAttempts = 0; // Reset the timeout
369-
wifiSetState(WIFI_CONNECTING);
369+
wifiSetState(WIFI_STATE_CONNECTING);
370370
}
371371

372372
// If WiFi is connected, and no services require WiFi, shut it off
@@ -383,7 +383,7 @@ void wifiUpdate()
383383
}
384384
}
385385

386-
// Starts the WiFi connection state machine (moves from WIFI_OFF to WIFI_CONNECTING)
386+
// Starts the WiFi connection state machine (moves from WIFI_STATE_OFF to WIFI_STATE_CONNECTING)
387387
// Sets the appropriate protocols (WiFi + ESP-Now)
388388
// If radio is off entirely, start WiFi
389389
// If ESP-Now is active, only add the LR protocol
@@ -400,12 +400,12 @@ void wifiStart()
400400
if (wifiIsConnected() == true)
401401
return; // We don't need to do anything
402402

403-
if (wifiState > WIFI_OFF)
403+
if (wifiState > WIFI_STATE_OFF)
404404
return; // We're in the midst of connecting
405405

406406
log_d("Starting WiFi");
407407

408-
wifiSetState(WIFI_CONNECTING); // This starts the state machine running
408+
wifiSetState(WIFI_STATE_CONNECTING); // This starts the state machine running
409409

410410
// Display the heap state
411411
reportHeapNow(settings.debugWifiState);
@@ -433,7 +433,7 @@ void wifiStop()
433433
// If ESP NOW is active, leave WiFi on enough for ESP NOW
434434
void wifiShutdown()
435435
{
436-
wifiSetState(WIFI_OFF);
436+
wifiSetState(WIFI_STATE_OFF);
437437

438438
wifiConnectionAttempts = 0; // Reset the timeout
439439

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void menuSystem()
8080
systemPrint("WiFi MAC Address: ");
8181
systemPrintf("%02X:%02X:%02X:%02X:%02X:%02X\r\n", wifiMACAddress[0], wifiMACAddress[1], wifiMACAddress[2],
8282
wifiMACAddress[3], wifiMACAddress[4], wifiMACAddress[5]);
83-
if (wifiState == WIFI_CONNECTED)
83+
if (wifiState == WIFI_STATE_CONNECTED)
8484
wifiDisplayIpAddress();
8585
#endif // COMPILE_WIFI
8686

Firmware/RTK_Surveyor/settings.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ typedef struct _NETWORK_DATA
267267
// either WiFi or ESP-Now are active
268268
enum WiFiState
269269
{
270-
WIFI_OFF = 0,
271-
WIFI_START,
272-
WIFI_CONNECTING,
273-
WIFI_CONNECTED,
270+
WIFI_STATE_OFF = 0,
271+
WIFI_STATE_START,
272+
WIFI_STATE_CONNECTING,
273+
WIFI_STATE_CONNECTED,
274274
};
275-
volatile byte wifiState = WIFI_OFF;
275+
volatile byte wifiState = WIFI_STATE_OFF;
276276

277277
typedef enum
278278
{

0 commit comments

Comments
 (0)