Skip to content

Commit 7f6d596

Browse files
committed
Fix #111 - BT if no WiFi NTRIP Client
1 parent d40dcc6 commit 7f6d596

File tree

4 files changed

+57
-18
lines changed

4 files changed

+57
-18
lines changed
1.91 MB
Binary file not shown.

Firmware/RTK_Surveyor/Display.ino

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,50 @@ void paintKeyWiFiFail(uint16_t displayTime)
20872087
}
20882088
}
20892089

2090+
void paintNClientWiFiFail(uint16_t displayTime)
2091+
{
2092+
//NTRIP
2093+
//Client
2094+
//Failed
2095+
//No WiFi
2096+
2097+
if (online.display == true)
2098+
{
2099+
oled.erase();
2100+
2101+
oled.setFont(QW_FONT_8X16);
2102+
2103+
int x = (oled.getWidth() / 2); //Center point for x coord
2104+
int y = 0;
2105+
int fontHeight = 13;
2106+
int textX;
2107+
2108+
textX = x - (oled.getStringWidth("NTRIP") / 2); //Starting point of text
2109+
oled.setCursor(textX, y);
2110+
oled.print("NTRIP");
2111+
2112+
y += fontHeight;
2113+
textX = x - (oled.getStringWidth("Client") / 2);
2114+
oled.setCursor(textX, y);
2115+
oled.print("Client");
2116+
2117+
y += fontHeight;
2118+
textX = x - (oled.getStringWidth("Failed") / 2);
2119+
oled.setCursor(textX, y);
2120+
oled.print("Failed");
2121+
2122+
oled.setFont(QW_FONT_5X7);
2123+
y += fontHeight + 1;
2124+
textX = x - (oled.getStringWidth("No WiFi") / 2);
2125+
oled.setCursor(textX, y);
2126+
oled.print("No WiFi");
2127+
2128+
oled.display();
2129+
2130+
delay(displayTime);
2131+
}
2132+
}
2133+
20902134
void paintKeysExpired()
20912135
{
20922136
displayMessage("Keys Expired", 4000);

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ unsigned long wifiStartTime = 0; //If we cannot connect to local wifi for NTRIP
462462
bool restartRover = false; //If user modifies any NTRIP Client settings, we need to restart the rover
463463
int ntripClientConnectionAttempts = 0;
464464
int maxNtripClientConnectionAttempts = 3; //Give up connecting after this number of attempts
465+
bool ntripClientAttempted = false; //Goes true once we attempt WiFi. Allows graceful failure.
465466

466467
unsigned long startTime = 0; //Used for checking longest running functions
467468
bool lbandCorrectionsDecrypted = false; //Used to display LBand SIV icon when corrections are successfully decrypted

Firmware/RTK_Surveyor/States.ino

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,19 @@ void updateSystemState()
6565

6666
displayRoverSuccess(500);
6767

68-
if (settings.enableNtripClient == false)
69-
changeState(STATE_ROVER_NO_FIX);
70-
else
68+
if (settings.enableNtripClient == true && ntripClientAttempted == false)
7169
{
7270
//Turn off Bluetooth and turn on WiFi
7371
stopBluetooth();
7472
startClientWiFi();
7573
wifiStartTime = millis();
7674

75+
ntripClientAttempted = true; //Do not allow re-entry into STATE_ROVER_CLIENT_WIFI_STARTED
76+
7777
changeState(STATE_ROVER_CLIENT_WIFI_STARTED);
7878
}
79+
else
80+
changeState(STATE_ROVER_NO_FIX);
7981

8082
firstRoverStart = false; //Do not allow entry into test menu again
8183
}
@@ -124,7 +126,7 @@ void updateSystemState()
124126
case (STATE_ROVER_CLIENT_WIFI_STARTED):
125127
{
126128
if (millis() - wifiStartTime > 8000)
127-
changeState(STATE_ROVER_NO_FIX); //Give up and move to normal Rover mode
129+
changeState(STATE_ROVER_NOT_STARTED); //Give up and move to normal Rover mode
128130

129131
#ifdef COMPILE_WIFI
130132
byte wifiStatus = WiFi.status();
@@ -143,21 +145,14 @@ void updateSystemState()
143145

144146
changeState(STATE_ROVER_CLIENT_WIFI_CONNECTED);
145147
}
148+
else if (wifiStatus == WL_NO_SSID_AVAIL)
149+
{
150+
paintNClientWiFiFail(4000);
151+
changeState(STATE_ROVER_NOT_STARTED); //Give up and return to Bluetooth
152+
}
146153
else
147154
{
148-
Serial.print(F("WiFi Status: "));
149-
switch (wifiStatus) {
150-
case WL_NO_SSID_AVAIL:
151-
Serial.printf("SSID '%s' not detected\n\r", settings.ntripClient_wifiSSID);
152-
break;
153-
case WL_NO_SHIELD: Serial.println(F("WL_NO_SHIELD")); break;
154-
case WL_IDLE_STATUS: Serial.println(F("WL_IDLE_STATUS")); break;
155-
case WL_SCAN_COMPLETED: Serial.println(F("WL_SCAN_COMPLETED")); break;
156-
case WL_CONNECTED: Serial.println(F("WL_CONNECTED")); break;
157-
case WL_CONNECT_FAILED: Serial.println(F("WL_CONNECT_FAILED")); break;
158-
case WL_CONNECTION_LOST: Serial.println(F("WL_CONNECTION_LOST")); break;
159-
case WL_DISCONNECTED: Serial.println(F("WL_DISCONNECTED")); break;
160-
}
155+
Serial.print(".");
161156
}
162157
#endif
163158
}
@@ -651,7 +646,6 @@ void updateSystemState()
651646
case WL_CONNECTION_LOST: Serial.println(F("WL_CONNECTION_LOST")); break;
652647
case WL_DISCONNECTED: Serial.println(F("WL_DISCONNECTED")); break;
653648
}
654-
delay(500);
655649
}
656650
#endif
657651
}

0 commit comments

Comments
 (0)