|
| 1 | +//Wait for survey in to complete |
| 2 | +bool updateSurveyInStatus() |
| 3 | +{ |
| 4 | + //Update the LEDs only every second or so |
| 5 | + if (millis() - lastBaseUpdate > 1000) |
| 6 | + { |
| 7 | + lastBaseUpdate = millis(); |
| 8 | + |
| 9 | + bool response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time) |
| 10 | + if (response == true) |
| 11 | + { |
| 12 | + if (myGPS.svin.valid == true) |
| 13 | + { |
| 14 | + Serial.println(F("Base survey complete! RTCM now broadcasting.")); |
| 15 | + baseState = BASE_TRANSMITTING; |
| 16 | + |
| 17 | + digitalWrite(baseStatusLED, HIGH); //Turn on LED |
| 18 | + } |
| 19 | + else |
| 20 | + { |
| 21 | + byte SIV = myGPS.getSIV(); |
| 22 | + |
| 23 | + Serial.print(F("Time elapsed: ")); |
| 24 | + Serial.print((String)myGPS.svin.observationTime); |
| 25 | + Serial.print(F(" Accuracy: ")); |
| 26 | + Serial.print((String)myGPS.svin.meanAccuracy); |
| 27 | + Serial.print(F(" SIV: ")); |
| 28 | + Serial.print(SIV); |
| 29 | + Serial.println(); |
| 30 | + |
| 31 | + SerialBT.print(F("Time elapsed: ")); |
| 32 | + SerialBT.print((String)myGPS.svin.observationTime); |
| 33 | + SerialBT.print(F(" Accuracy: ")); |
| 34 | + SerialBT.print((String)myGPS.svin.meanAccuracy); |
| 35 | + SerialBT.print(F(" SIV: ")); |
| 36 | + SerialBT.print(SIV); |
| 37 | + SerialBT.println(); |
| 38 | + |
| 39 | + if (myGPS.svin.meanAccuracy > 6.0) |
| 40 | + baseState = BASE_SURVEYING_IN_SLOW; |
| 41 | + else |
| 42 | + baseState = BASE_SURVEYING_IN_FAST; |
| 43 | + |
| 44 | + if (myGPS.svin.observationTime > maxSurveyInWait_s) |
| 45 | + { |
| 46 | + Serial.println(F("Survey-In took more than 5 minutes. Restarting survey in.")); |
| 47 | + |
| 48 | + resetSurvey(); |
| 49 | + |
| 50 | + surveyIn(); |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + else |
| 55 | + { |
| 56 | + Serial.println(F("SVIN request failed")); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + //Update the Base LED accordingly |
| 61 | + if (baseState == BASE_SURVEYING_IN_SLOW) |
| 62 | + { |
| 63 | + if (millis() - baseStateBlinkTime > 500) |
| 64 | + { |
| 65 | + baseStateBlinkTime += 500; |
| 66 | + Serial.println(F("Slow blink")); |
| 67 | + |
| 68 | + if (digitalRead(baseStatusLED) == LOW) |
| 69 | + digitalWrite(baseStatusLED, HIGH); |
| 70 | + else |
| 71 | + digitalWrite(baseStatusLED, LOW); |
| 72 | + } |
| 73 | + } |
| 74 | + else if (baseState == BASE_SURVEYING_IN_FAST) |
| 75 | + { |
| 76 | + if (millis() - baseStateBlinkTime > 100) |
| 77 | + { |
| 78 | + baseStateBlinkTime += 100; |
| 79 | + Serial.println(F("Fast blink")); |
| 80 | + |
| 81 | + if (digitalRead(baseStatusLED) == LOW) |
| 82 | + digitalWrite(baseStatusLED, HIGH); |
| 83 | + else |
| 84 | + digitalWrite(baseStatusLED, LOW); |
| 85 | + } |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +//Configure specific aspects of the receiver for base mode |
| 90 | +bool configureUbloxModuleBase() |
| 91 | +{ |
| 92 | + bool response = true; |
| 93 | + |
| 94 | + digitalWrite(positionAccuracyLED_20mm, LOW); |
| 95 | + digitalWrite(positionAccuracyLED_100mm, LOW); |
| 96 | + digitalWrite(positionAccuracyLED_1000mm, LOW); |
| 97 | + |
| 98 | + // Set dynamic model |
| 99 | + if (myGPS.getDynamicModel() != DYN_MODEL_STATIONARY) |
| 100 | + { |
| 101 | + if (myGPS.setDynamicModel(DYN_MODEL_STATIONARY) == false) |
| 102 | + { |
| 103 | + Serial.println(F("setDynamicModel failed!")); |
| 104 | + return (false); |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | + if (getRTCMSettings(UBX_RTCM_1005, COM_PORT_UART2) != 1) |
| 109 | + response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_UART2, 1); //Enable message 1005 to output through UART2, message every second |
| 110 | + if (getRTCMSettings(UBX_RTCM_1074, COM_PORT_UART2) != 1) |
| 111 | + response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_UART2, 1); |
| 112 | + if (getRTCMSettings(UBX_RTCM_1084, COM_PORT_UART2) != 1) |
| 113 | + response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_UART2, 1); |
| 114 | + if (getRTCMSettings(UBX_RTCM_1094, COM_PORT_UART2) != 1) |
| 115 | + response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_UART2, 1); |
| 116 | + if (getRTCMSettings(UBX_RTCM_1124, COM_PORT_UART2) != 1) |
| 117 | + response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_UART2, 1); |
| 118 | + if (getRTCMSettings(UBX_RTCM_1230, COM_PORT_UART2) != 10) |
| 119 | + response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 10); //Enable message every 10 seconds |
| 120 | + |
| 121 | + if (response == false) |
| 122 | + { |
| 123 | + Serial.println(F("RTCM failed to enable.")); |
| 124 | + return (false); |
| 125 | + } |
| 126 | + |
| 127 | + return (response); |
| 128 | +} |
| 129 | + |
| 130 | +//Start survey |
| 131 | +//The ZED-F9P is slightly different than the NEO-M8P. See the Integration manual 3.5.8 for more info. |
| 132 | +void surveyIn() |
| 133 | +{ |
| 134 | + resetSurvey(); |
| 135 | + |
| 136 | + bool response = myGPS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m |
| 137 | + if (response == false) |
| 138 | + { |
| 139 | + Serial.println(F("Survey start failed")); |
| 140 | + return; |
| 141 | + } |
| 142 | + Serial.println(F("Survey started. This will run until 60s has passed and less than 5m accuracy is achieved.")); |
| 143 | + |
| 144 | + baseState = BASE_SURVEYING_IN_SLOW; |
| 145 | +} |
| 146 | + |
| 147 | +void resetSurvey() |
| 148 | +{ |
| 149 | + //Slightly modified method for restarting survey-in from: https://portal.u-blox.com/s/question/0D52p00009IsVoMCAV/restarting-surveyin-on-an-f9p |
| 150 | + bool response = myGPS.disableSurveyMode(); //Disable survey |
| 151 | + delay(500); |
| 152 | + response &= myGPS.enableSurveyMode(1000, 400.000); //Enable Survey in with bogus values |
| 153 | + delay(500); |
| 154 | + response &= myGPS.disableSurveyMode(); //Disable survey |
| 155 | + delay(500); |
| 156 | +} |
0 commit comments