|
1 | | -//Wait for survey in to complete |
2 | | -bool updateSurveyInStatus() |
3 | | -{ |
4 | | - //If user wants to use fixed coordinates, do so immediately |
5 | | - if (settings.fixedBase == true) |
6 | | - { |
7 | | - bool response = startFixedBase(); |
8 | | - if (response == true) |
9 | | - { |
10 | | - baseState = BASE_TRANSMITTING; |
11 | | - return (true); |
12 | | - } |
13 | | - else |
14 | | - { |
15 | | - return (false); |
16 | | - } |
17 | | - } |
18 | | - |
19 | | - //Update the LEDs only every second or so |
20 | | - if (millis() - lastBaseUpdate > 1000) |
21 | | - { |
22 | | - lastBaseUpdate = millis(); |
23 | | - |
24 | | - if (baseState == BASE_SURVEYING_IN_NOTSTARTED) |
25 | | - { |
26 | | - //Check for <5m horz accuracy |
27 | | - uint32_t accuracy = i2cGNSS.getHorizontalAccuracy(250); //This call defaults to 1100ms and can cause the core to crash with WDT timeout |
28 | | - |
29 | | - float f_accuracy = accuracy; |
30 | | - f_accuracy = f_accuracy / 10000.0; // Convert the horizontal accuracy (mm * 10^-1) to a float |
31 | | - |
32 | | - if (f_accuracy > 0.0 && f_accuracy < 5.0) |
33 | | - { |
34 | | - //Current positional accuracy is within 5m so start survey |
35 | | - surveyIn(); |
36 | | - } |
37 | | - else |
38 | | - { |
39 | | - Serial.print(F("Waiting for Horz Accuracy < 5 meters: ")); |
40 | | - Serial.print(f_accuracy, 2); // Print the accuracy with 2 decimal places |
41 | | - Serial.println(); |
42 | | - } |
43 | | - } //baseState = Surveying In Not started |
44 | | - else |
45 | | - { |
46 | | - bool response = i2cGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time) |
47 | | - if (response == true) |
48 | | - { |
49 | | - if (i2cGNSS.getSurveyInValid() == true) |
50 | | - { |
51 | | - Serial.println(F("Base survey complete! RTCM now broadcasting.")); |
52 | | - baseState = BASE_TRANSMITTING; |
53 | | - |
54 | | - digitalWrite(baseStatusLED, HIGH); //Turn on LED |
55 | | - } |
56 | | - else |
57 | | - { |
58 | | - byte SIV = i2cGNSS.getSIV(); |
59 | | - |
60 | | - Serial.print(F("Time elapsed: ")); |
61 | | - Serial.print((String)i2cGNSS.getSurveyInObservationTime()); |
62 | | - Serial.print(F(" Accuracy: ")); |
63 | | - Serial.print((String)i2cGNSS.getSurveyInMeanAccuracy()); |
64 | | - Serial.print(F(" SIV: ")); |
65 | | - Serial.print(SIV); |
66 | | - Serial.println(); |
67 | | - |
68 | | - SerialBT.print(F("Time elapsed: ")); |
69 | | - SerialBT.print((String)i2cGNSS.getSurveyInObservationTime()); |
70 | | - SerialBT.print(F(" Accuracy: ")); |
71 | | - SerialBT.print((String)i2cGNSS.getSurveyInMeanAccuracy()); |
72 | | - SerialBT.print(F(" SIV: ")); |
73 | | - SerialBT.print(SIV); |
74 | | - SerialBT.println(); |
75 | | - |
76 | | - //If we are greater than a meter out of our objective, blink slow |
77 | | - if (i2cGNSS.getSurveyInMeanAccuracy() > (settings.observationPositionAccuracy + 1.0)) |
78 | | - baseState = BASE_SURVEYING_IN_SLOW; |
79 | | - else |
80 | | - baseState = BASE_SURVEYING_IN_FAST; |
81 | | - |
82 | | - if (i2cGNSS.getSurveyInObservationTime() > maxSurveyInWait_s) |
83 | | - { |
84 | | - Serial.printf("Survey-In took more than %d minutes. Restarting survey-in process.\n", maxSurveyInWait_s / 60); |
85 | | - |
86 | | - resetSurvey(); |
87 | | - |
88 | | - surveyIn(); |
89 | | - } |
90 | | - } |
91 | | - } |
92 | | - else |
93 | | - { |
94 | | - Serial.println(F("SVIN request failed")); |
95 | | - } |
96 | | - } //baseState = Surveying In Slow or fast |
97 | | - } //Check every second |
98 | | - |
99 | | - //Update the Base LED accordingly |
100 | | - if (baseState == BASE_SURVEYING_IN_NOTSTARTED || baseState == BASE_SURVEYING_IN_SLOW) |
101 | | - { |
102 | | - if (millis() - baseStateBlinkTime > 2000) |
103 | | - { |
104 | | - baseStateBlinkTime = millis(); |
105 | | - Serial.println(F("Slow blink")); |
106 | | - |
107 | | - if (digitalRead(baseStatusLED) == LOW) |
108 | | - digitalWrite(baseStatusLED, HIGH); |
109 | | - else |
110 | | - digitalWrite(baseStatusLED, LOW); |
111 | | - } |
112 | | - } |
113 | | - else if (baseState == BASE_SURVEYING_IN_FAST) |
114 | | - { |
115 | | - if (millis() - baseStateBlinkTime > 500) |
116 | | - { |
117 | | - baseStateBlinkTime = millis(); |
118 | | - Serial.println(F("Fast blink")); |
119 | | - |
120 | | - if (digitalRead(baseStatusLED) == LOW) |
121 | | - digitalWrite(baseStatusLED, HIGH); |
122 | | - else |
123 | | - digitalWrite(baseStatusLED, LOW); |
124 | | - } |
125 | | - } |
126 | | -} |
127 | 1 |
|
128 | 2 | //Configure specific aspects of the receiver for base mode |
129 | 3 | bool configureUbloxModuleBase() |
@@ -186,22 +60,23 @@ bool configureUbloxModuleBase() |
186 | 60 |
|
187 | 61 | //Start survey |
188 | 62 | //The ZED-F9P is slightly different than the NEO-M8P. See the Integration manual 3.5.8 for more info. |
189 | | -void surveyIn() |
| 63 | +bool surveyIn() |
190 | 64 | { |
191 | 65 | resetSurvey(); |
192 | 66 |
|
193 | 67 | bool response = i2cGNSS.enableSurveyMode(settings.observationSeconds, settings.observationPositionAccuracy); //Enable Survey in, with user parameters |
194 | 68 | if (response == false) |
195 | 69 | { |
196 | 70 | Serial.println(F("Survey start failed")); |
197 | | - return; |
| 71 | + return(false); |
198 | 72 | } |
| 73 | + |
199 | 74 | Serial.printf("Survey started. This will run until %d seconds have passed and less than %0.03f meter accuracy is achieved.\n", |
200 | 75 | settings.observationSeconds, |
201 | 76 | settings.observationPositionAccuracy |
202 | 77 | ); |
203 | 78 |
|
204 | | - baseState = BASE_SURVEYING_IN_SLOW; |
| 79 | + return(true); |
205 | 80 | } |
206 | 81 |
|
207 | 82 | void resetSurvey() |
|
0 commit comments