Skip to content

Commit da552c9

Browse files
committed
Change the way statemachine times are updated
1 parent d3b8332 commit da552c9

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bool updateSurveyInStatus()
1919
//Update the LEDs only every second or so
2020
if (millis() - lastBaseUpdate > 1000)
2121
{
22-
lastBaseUpdate += 1000;
22+
lastBaseUpdate = millis();
2323

2424
if (baseState == BASE_SURVEYING_IN_NOTSTARTED)
2525
{
@@ -101,7 +101,7 @@ bool updateSurveyInStatus()
101101
{
102102
if (millis() - baseStateBlinkTime > 2000)
103103
{
104-
baseStateBlinkTime += 2000;
104+
baseStateBlinkTime = millis();
105105
Serial.println(F("Slow blink"));
106106

107107
if (digitalRead(baseStatusLED) == LOW)
@@ -114,7 +114,7 @@ bool updateSurveyInStatus()
114114
{
115115
if (millis() - baseStateBlinkTime > 500)
116116
{
117-
baseStateBlinkTime += 500;
117+
baseStateBlinkTime = millis();
118118
Serial.println(F("Fast blink"));
119119

120120
if (digitalRead(baseStatusLED) == LOW)
@@ -280,7 +280,7 @@ bool startFixedBase()
280280
return (response);
281281
}
282282

283-
//Call regularly to get data from u-blox module and send out over local WiFi
283+
//Call regularly to push latest u-blox data out over local WiFi
284284
//We make sure we are connected to WiFi, then
285285
bool updateNtripServer()
286286
{
@@ -293,8 +293,6 @@ bool updateNtripServer()
293293
Serial.printf("Connecting to local WiFi: %s\n", settings.wifiSSID);
294294
WiFi.begin(settings.wifiSSID, settings.wifiPW);
295295

296-
//while(1) delay(10);
297-
298296
int maxTime = 10000;
299297
long startTime = millis();
300298
while (WiFi.status() != WL_CONNECTED) {
@@ -303,12 +301,13 @@ bool updateNtripServer()
303301

304302
if (millis() - startTime > maxTime)
305303
{
306-
Serial.println(F("Failed to connect to WiFi. Are you sure your WiFi credentials are correct?"));
304+
Serial.println(F("\nFailed to connect to WiFi. Are you sure your WiFi credentials are correct?"));
307305
return (false);
308306
}
309307
}
310308
delay(10);
311309

310+
radioState = WIFI_CONNECTED;
312311
} //End WiFi connect check
313312

314313
//Are we connected to caster?
@@ -383,10 +382,6 @@ bool updateNtripServer()
383382
} //End connected == false
384383

385384

386-
//Poll module for any new I2C data including RTCM
387-
//These bytes will automatically be parsed by processRTCM() function
388-
myGPS.checkUblox();
389-
390385
//Close socket if we don't have new data for 10s
391386
//RTK2Go will ban your IP address if you abuse it. See http://www.rtk2go.com/how-to-get-your-ip-banned/
392387
//So let's not leave the socket open/hanging without data
@@ -400,7 +395,7 @@ bool updateNtripServer()
400395
//Report some statistics every 250
401396
if (millis() - lastServerReport_ms > 250)
402397
{
403-
lastServerReport_ms += 250;
398+
lastServerReport_ms = millis();
404399
Serial.printf("Total bytes sent to caster: %d\n", serverBytesSent);
405400
}
406401

0 commit comments

Comments
 (0)