Skip to content

Commit dbbe733

Browse files
committed
Allow more states to keep WiFi turned on.
1 parent 1261afc commit dbbe733

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Firmware/RTK_Surveyor/WiFi.ino

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,14 @@ void wifiUpdate()
209209

210210
if (wifiConnect(10000) == true) //Attempt to connect to any SSID on settings list
211211
{
212-
213212
if (espnowState > ESPNOW_OFF)
214-
{
215-
//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.
216213
espnowStart();
217-
}
218214

219215
wifiSetState(WIFI_CONNECTED);
220216
}
221217
else
222218
{
223219
//We failed to connect
224-
225220
if (wifiConnectLimitReached() == false) //Increases wifiConnectionAttemptTimeout
226221
{
227222
if (wifiConnectionAttemptTimeout / 1000 < 120)
@@ -409,19 +404,26 @@ bool wifiIsNeeded()
409404
{
410405
bool needed = false;
411406

412-
if (settings.enableNtripClient == true
413-
&& systemState <= STATE_ROVER_RTK_FIX
407+
if (settings.enableTcpClient == true) needed = true;
408+
if (settings.enableTcpServer == true) needed = true;
409+
410+
//Handle WiFi within systemStates
411+
if (systemState <= STATE_ROVER_RTK_FIX
412+
&& settings.enableNtripClient == true
414413
)
415414
needed = true;
416415

417-
if (settings.enableNtripServer == true
418-
&& systemState >= STATE_BASE_NOT_STARTED
419-
&& systemState <= STATE_BASE_FIXED_TRANSMITTING
416+
if (systemState >= STATE_BASE_NOT_STARTED && systemState <= STATE_BASE_FIXED_TRANSMITTING
417+
&& settings.enableNtripServer == true
420418
)
421419
needed = true;
422420

423-
if (settings.enableTcpClient == true) needed = true;
424-
if (settings.enableTcpServer == true) needed = true;
421+
//If WiFi is on while we are in the following states, allow WiFi to continue to operate
422+
if (systemState >= STATE_BUBBLE_LEVEL && systemState <= STATE_PROFILE)
423+
{
424+
//Keep WiFi on if user presses setup button, enters bubble level, is in AP config mode, etc
425+
needed = true;
426+
}
425427

426428
if (systemState == STATE_KEYS_WIFI_STARTED || systemState == STATE_KEYS_WIFI_CONNECTED) needed = true;
427429
if (systemState == STATE_KEYS_PROVISION_WIFI_STARTED || systemState == STATE_KEYS_PROVISION_WIFI_CONNECTED) needed = true;
@@ -636,7 +638,7 @@ void tcpUpdate()
636638
void wifiPrintNetworkInfo()
637639
{
638640
#ifdef COMPILE_WIFI
639-
systemPrintln("\n\nNetwork Configuration:");
641+
systemPrintln("\nNetwork Configuration:");
640642
systemPrintln("----------------------");
641643
systemPrint(" SSID: "); systemPrintln(WiFi.SSID());
642644
systemPrint(" WiFi Status: "); systemPrintln(WiFi.status());

0 commit comments

Comments
 (0)