Skip to content

Commit b26872d

Browse files
committed
Add polling check to start of survey in.
1 parent 3385a5d commit b26872d

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ bool configureUbloxModuleBase()
6565
bool beginSurveyIn()
6666
{
6767
bool needSurveyReset = false;
68-
if (i2cGNSS.getSurveyInActive() == true) needSurveyReset = true;
69-
if (i2cGNSS.getSurveyInValid() == true) needSurveyReset = true;
68+
if (i2cGNSS.getSurveyInActive(100) == true) needSurveyReset = true;
69+
if (i2cGNSS.getSurveyInValid(100) == true) needSurveyReset = true;
7070

7171
if (needSurveyReset == true)
7272
{
73+
Serial.println("Resetting survey");
74+
7375
if (resetSurvey() == false)
7476
{
7577
Serial.println(F("Survey reset failed"));
@@ -80,7 +82,7 @@ bool beginSurveyIn()
8082
}
8183
}
8284

83-
bool response = i2cGNSS.enableSurveyMode(settings.observationSeconds, settings.observationPositionAccuracy); //Enable Survey in, with user parameters
85+
bool response = i2cGNSS.enableSurveyMode(settings.observationSeconds, settings.observationPositionAccuracy, 5000); //Enable Survey in, with user parameters. Wait up to 5s.
8486
if (response == false)
8587
{
8688
Serial.println(F("Survey start failed"));
@@ -92,6 +94,15 @@ bool beginSurveyIn()
9294
settings.observationPositionAccuracy
9395
);
9496

97+
//Wait until active becomes true
98+
long maxTime = 5000;
99+
long startTime = millis();
100+
while(i2cGNSS.getSurveyInActive(100) == false)
101+
{
102+
delay(100);
103+
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
104+
}
105+
95106
return (true);
96107
}
97108

@@ -105,8 +116,20 @@ bool resetSurvey()
105116
response &= i2cGNSS.enableSurveyMode(1000, 400.000, maxWait); //Enable Survey in with bogus values
106117
delay(1000);
107118
response &= i2cGNSS.disableSurveyMode(maxWait); //Disable survey
108-
delay(1000);
109-
return (response);
119+
120+
if(response == false)
121+
return(response);
122+
123+
//Wait until active and valid becomes false
124+
long maxTime = 5000;
125+
long startTime = millis();
126+
while(i2cGNSS.getSurveyInActive(100) == true || i2cGNSS.getSurveyInValid(100) == true)
127+
{
128+
delay(100);
129+
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
130+
}
131+
132+
return(true);
110133
}
111134

112135
//Start the base using fixed coordinates
@@ -126,9 +149,9 @@ bool startFixedBase()
126149
long majorEcefZ = floor((settings.fixedEcefZ * 100) + 0.5);
127150
long minorEcefZ = floor((((settings.fixedEcefZ * 100.0) - majorEcefZ) * 100.0) + 0.5);
128151

129-
// Serial.printf("fixedEcefY (should be -4716808.5807): %0.04f\n\r", settings.fixedEcefY);
130-
// Serial.printf("major (should be -471680858): %ld\n\r", majorEcefY);
131-
// Serial.printf("minor (should be -7): %ld\n\r", minorEcefY);
152+
// Serial.printf("fixedEcefY (should be -4716808.5807): %0.04f\n\r", settings.fixedEcefY);
153+
// Serial.printf("major (should be -471680858): %ld\n\r", majorEcefY);
154+
// Serial.printf("minor (should be -7): %ld\n\r", minorEcefY);
132155

133156
//Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78)
134157
//-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so...

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ float battChangeRate = 0.0;
190190
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
191191
//We use a local copy of the BluetoothSerial library so that we can increase the RX buffer. See issue: https://github.com/sparkfun/SparkFun_RTK_Surveyor/issues/18
192192

193-
//#define COMPILE_BT 1 //Comment out to disable all Bluetooth
193+
#define COMPILE_BT 1 //Comment out to disable all Bluetooth
194194

195195
#ifdef COMPILE_BT
196196
#include "src/BluetoothSerial/BluetoothSerial.h"

Firmware/RTK_Surveyor/States.ino

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,13 @@ void updateSystemState()
172172
digitalWrite(pin_baseStatusLED, !digitalRead(pin_baseStatusLED));
173173
}
174174

175-
if (i2cGNSS.getSurveyInValid() == true) //Survey in complete
175+
//Get the data once to avoid duplicate slow responses
176+
svinObservationTime = i2cGNSS.getSurveyInObservationTime(100);
177+
svinMeanAccuracy = i2cGNSS.getSurveyInMeanAccuracy(100);
178+
179+
if (i2cGNSS.getSurveyInValid(100) == true) //Survey in complete
176180
{
181+
Serial.printf("obs time: %d\n\r", svinObservationTime);
177182
Serial.println(F("Base survey complete! RTCM now broadcasting."));
178183

179184
if (productVariant == RTK_SURVEYOR)
@@ -184,10 +189,6 @@ void updateSystemState()
184189
}
185190
else
186191
{
187-
//Get the data once to avoid duplicate slow responses
188-
svinObservationTime = i2cGNSS.getSurveyInObservationTime(100);
189-
svinMeanAccuracy = i2cGNSS.getSurveyInMeanAccuracy(100);
190-
191192
Serial.print(F("Time elapsed: "));
192193
Serial.print(svinObservationTime);
193194
Serial.print(F(" Accuracy: "));
@@ -250,7 +251,7 @@ void updateSystemState()
250251
}
251252
delay(1000);
252253
}
253-
#endif
254+
#endif
254255
}
255256
break;
256257

@@ -425,7 +426,7 @@ void updateSystemState()
425426
}
426427
delay(1000);
427428
}
428-
#endif
429+
#endif
429430
}
430431
break;
431432

@@ -529,7 +530,7 @@ void updateSystemState()
529530
{
530531
changeState(STATE_BASE_FIXED_WIFI_CONNECTED);
531532
}
532-
#endif
533+
#endif
533534
}
534535
break;
535536

0 commit comments

Comments
 (0)