Skip to content

Commit 5ee9995

Browse files
committed
2 parents 86b335b + b98dc49 commit 5ee9995

16 files changed

+373
-305
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ bool configureUbloxModuleBase()
3434
}
3535
}
3636

37+
#define OUTPUT_SETTING 14
38+
39+
//Turn on RTCM so that we can harvest RTCM over I2C and send out over WiFi
40+
//This is easier than parsing over UART because the library handles the frame detection
41+
getPortSettings(COM_PORT_I2C); //Load the settingPayload with this port's settings
42+
if (settingPayload[OUTPUT_SETTING] != (COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3))
43+
response &= i2cGNSS.setPortOutput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); //Set the I2C port to output UBX (config), and RTCM3 (casting)
44+
//response &= i2cGNSS.setPortOutput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_RTCM3); //Not a valid state. Goes to UBX+NMEA+RTCM3 -
45+
3746
//In base mode the Surveyor should output RTCM over UART2 and I2C ports:
3847
//(Primary) UART2 in case the Surveyor is connected via radio to rover
3948
//(Optional) I2C in case user wants base to connect to WiFi and NTRIP Serve to Caster
@@ -90,10 +99,10 @@ bool beginSurveyIn()
9099
//Wait until active becomes true
91100
long maxTime = 5000;
92101
long startTime = millis();
93-
while(i2cGNSS.getSurveyInActive(100) == false)
102+
while (i2cGNSS.getSurveyInActive(100) == false)
94103
{
95104
delay(100);
96-
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
105+
if (millis() - startTime > maxTime) return (false); //Reset of survey failed
97106
}
98107

99108
return (true);
@@ -110,19 +119,19 @@ bool resetSurvey()
110119
delay(1000);
111120
response &= i2cGNSS.disableSurveyMode(maxWait); //Disable survey
112121

113-
if(response == false)
114-
return(response);
122+
if (response == false)
123+
return (response);
115124

116125
//Wait until active and valid becomes false
117126
long maxTime = 5000;
118127
long startTime = millis();
119-
while(i2cGNSS.getSurveyInActive(100) == true || i2cGNSS.getSurveyInValid(100) == true)
128+
while (i2cGNSS.getSurveyInActive(100) == true || i2cGNSS.getSurveyInValid(100) == true)
120129
{
121130
delay(100);
122-
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
131+
if (millis() - startTime > maxTime) return (false); //Reset of survey failed
123132
}
124133

125-
return(true);
134+
return (true);
126135
}
127136

128137
//Start the base using fixed coordinates
@@ -203,7 +212,11 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
203212
}
204213

205214
//Check for too many digits
206-
if (logIncreasing == true)
215+
if (settings.enableResetDisplay == true)
216+
{
217+
if (rtcmPacketsSent > 99) rtcmPacketsSent = 1; //Trim to two digits to avoid overlap
218+
}
219+
else if (logIncreasing == true)
207220
{
208221
if (rtcmPacketsSent > 999) rtcmPacketsSent = 1; //Trim to three digits to avoid log icon
209222
}

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void beginBoard()
3838

3939
//Bug in ZED-F9P v1.13 firmware causes RTK LED to not light when RTK Floating with SBAS on.
4040
//The following changes the POR default but will be overwritten by settings in NVM or settings file
41-
ubxConstellations[1].enabled = false;
41+
settings.ubxConstellations[1].enabled = false;
4242

4343
strcpy(platformFilePrefix, "SFE_Surveyor");
4444
strcpy(platformPrefix, "Surveyor");
@@ -112,14 +112,25 @@ void beginBoard()
112112
if (esp_reset_reason() == ESP_RST_POWERON)
113113
{
114114
reuseLastLog = false; //Start new log
115-
settings.resetCount = 0;
116-
recordSystemSettings(); //Record to NVM
115+
116+
loadSettingsPartial();
117+
if (settings.enableResetDisplay == true)
118+
{
119+
settings.resetCount = 0;
120+
recordSystemSettings(); //Record to NVM
121+
}
117122
}
118123
else
119124
{
120125
reuseLastLog = true; //Attempt to reuse previous log
121-
settings.resetCount++;
122-
recordSystemSettings(); //Record to NVM
126+
127+
loadSettingsPartial();
128+
if (settings.enableResetDisplay == true)
129+
{
130+
settings.resetCount++;
131+
recordSystemSettings(); //Record to NVM
132+
Serial.printf("resetCount: %d\n\r", settings.resetCount);
133+
}
123134

124135
Serial.print("Reset reason: ");
125136
switch (esp_reset_reason())
@@ -196,6 +207,9 @@ void beginSD()
196207
}
197208

198209
online.microSD = true;
210+
211+
Serial.println(F("microSD online"));
212+
scanForFirmware(); //See if SD card contains new firmware that should be loaded at startup
199213
}
200214
else
201215
{
@@ -214,7 +228,7 @@ void beginUART2()
214228
"UARTStart", //Just for humans
215229
2000, //Stack Size
216230
NULL, //Task input parameter
217-
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
231+
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
218232
&pinUART2TaskHandle, //Task handle
219233
0); //Core where task should run, 0=core, 1=Arduino
220234

@@ -225,9 +239,9 @@ void beginUART2()
225239
//Assign UART2 interrupts to the core 0. See: https://github.com/espressif/arduino-esp32/issues/3386
226240
void pinUART2Task( void *pvParameters )
227241
{
228-
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
229242
serialGNSS.setRxBufferSize(SERIAL_SIZE_RX);
230243
serialGNSS.setTimeout(50);
244+
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
231245

232246
uart2pinned = true;
233247

@@ -336,6 +350,7 @@ void beginGNSS()
336350

337351
printModuleInfo(); //Print module type and firmware version
338352
}
353+
339354
online.gnss = true;
340355
}
341356

@@ -460,6 +475,6 @@ void beginSystemState()
460475
"BtnCheck", //Just for humans
461476
buttonTaskStackSize, //Stack Size
462477
NULL, //Task input parameter
463-
ButtonCheckTaskPriority, //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
478+
ButtonCheckTaskPriority,
464479
&ButtonCheckTaskHandle); //Task handle
465480
}

Firmware/RTK_Surveyor/Display.ino

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void updateDisplay()
8686
displayWiFiConfig(); //Display SSID and IP
8787
break;
8888
case (STATE_TEST):
89-
//Do nothing
89+
paintSystemTest();
9090
break;
9191
case (STATE_TESTING):
9292
paintSystemTest();
@@ -445,12 +445,7 @@ void paintSIV()
445445
oled.print(i2cGNSS.getSIV());
446446
}
447447

448-
if (settings.enableResetDisplay == true)
449-
{
450-
oled.setFontType(0); //Small font
451-
oled.setCursor(16 + (8 * 3) + 6, 38); //x, y
452-
oled.print(settings.resetCount);
453-
}
448+
paintResets();
454449
}
455450
}
456451

@@ -646,6 +641,8 @@ void paintBaseTempTransmitting()
646641
oled.setFontType(1); //Set font to type 1: 8x16
647642
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
648643

644+
paintResets();
645+
649646
paintLogging();
650647
}
651648
}
@@ -680,6 +677,8 @@ void paintBaseTempWiFiStarted()
680677
oled.setFontType(1); //Set font to type 1: 8x16
681678
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
682679

680+
paintResets();
681+
683682
paintLogging();
684683
}
685684
}
@@ -715,6 +714,8 @@ void paintBaseTempWiFiConnected()
715714
oled.setFontType(1); //Set font to type 1: 8x16
716715
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
717716

717+
paintResets();
718+
718719
paintLogging();
719720
}
720721
}
@@ -776,6 +777,8 @@ void paintBaseTempCasterConnected()
776777
oled.setFontType(1); //Set font to type 1: 8x16
777778
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
778779

780+
paintResets();
781+
779782
paintLogging();
780783
}
781784
}
@@ -822,6 +825,8 @@ void paintBaseFixedTransmitting()
822825
oled.setFontType(1); //Set font to type 1: 8x16
823826
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
824827

828+
paintResets();
829+
825830
paintLogging();
826831
}
827832
}
@@ -856,6 +861,8 @@ void paintBaseFixedWiFiStarted()
856861
oled.setFontType(1); //Set font to type 1: 8x16
857862
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
858863

864+
paintResets();
865+
859866
paintLogging();
860867
}
861868
}
@@ -891,6 +898,8 @@ void paintBaseFixedWiFiConnected()
891898
oled.setFontType(1); //Set font to type 1: 8x16
892899
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
893900

901+
paintResets();
902+
894903
paintLogging();
895904
}
896905
}
@@ -952,6 +961,8 @@ void paintBaseFixedCasterConnected()
952961
oled.setFontType(1); //Set font to type 1: 8x16
953962
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
954963

964+
paintResets();
965+
955966
paintLogging();
956967
}
957968
}
@@ -1558,3 +1569,16 @@ void displayMessage(const char* message, uint16_t displayTime)
15581569
delay(displayTime);
15591570
}
15601571
}
1572+
1573+
void paintResets()
1574+
{
1575+
if (online.display == true)
1576+
{
1577+
if (settings.enableResetDisplay == true)
1578+
{
1579+
oled.setFontType(0); //Small font
1580+
oled.setCursor(16 + (8 * 3) + 6, 38); //x, y
1581+
oled.print(settings.resetCount);
1582+
}
1583+
}
1584+
}

Firmware/RTK_Surveyor/Form.ino

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ void startConfigAP()
142142
#ifdef COMPILE_WIFI
143143
static void handleFirmwareFileUpload(AsyncWebServerRequest *request, String fileName, size_t index, uint8_t *data, size_t len, bool final)
144144
{
145+
if(online.microSD == false)
146+
{
147+
Serial.println(F("No SD card available"));
148+
return;
149+
}
150+
145151
//Attempt to write to file system. This avoids collisions with file writing in F9PSerialReadTask()
146152
if (xSemaphoreTake(xFATSemaphore, fatSemaphore_longWait_ms) != pdPASS) {
147153
Serial.println(F("Failed to get file system lock on firmware file"));
@@ -243,13 +249,13 @@ void createSettingsString(char* settingsCSV)
243249
//GNSS Config
244250
stringRecord(settingsCSV, "measurementRateHz", 1000.0 / settings.measurementRate, 2); //2 = decimals to print
245251
stringRecord(settingsCSV, "dynamicModel", settings.dynamicModel);
246-
stringRecord(settingsCSV, "ubxConstellationsGPS", ubxConstellations[0].enabled); //GPS
247-
stringRecord(settingsCSV, "ubxConstellationsSBAS", ubxConstellations[1].enabled); //SBAS
248-
stringRecord(settingsCSV, "ubxConstellationsGalileo", ubxConstellations[2].enabled); //Galileo
249-
stringRecord(settingsCSV, "ubxConstellationsBeiDou", ubxConstellations[3].enabled); //BeiDou
250-
stringRecord(settingsCSV, "ubxConstellationsGLONASS", ubxConstellations[5].enabled); //GLONASS
252+
stringRecord(settingsCSV, "ubxConstellationsGPS", settings.ubxConstellations[0].enabled); //GPS
253+
stringRecord(settingsCSV, "ubxConstellationsSBAS", settings.ubxConstellations[1].enabled); //SBAS
254+
stringRecord(settingsCSV, "ubxConstellationsGalileo", settings.ubxConstellations[2].enabled); //Galileo
255+
stringRecord(settingsCSV, "ubxConstellationsBeiDou", settings.ubxConstellations[3].enabled); //BeiDou
256+
stringRecord(settingsCSV, "ubxConstellationsGLONASS", settings.ubxConstellations[5].enabled); //GLONASS
251257
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
252-
stringRecord(settingsCSV, ubxMessages[x].msgTextName, ubxMessages[x].msgRate);
258+
stringRecord(settingsCSV, settings.ubxMessages[x].msgTextName, settings.ubxMessages[x].msgRate);
253259

254260
//Base Config
255261
stringRecord(settingsCSV, "baseTypeSurveyIn", !settings.fixedBase);
@@ -394,11 +400,11 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
394400
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
395401
{
396402
char tempString[50]; //ubxConstellationsSBAS
397-
sprintf(tempString, "ubxConstellations%s", ubxConstellations[x].textName);
403+
sprintf(tempString, "ubxConstellations%s", settings.ubxConstellations[x].textName);
398404

399405
if (strcmp(settingName, tempString) == 0)
400406
{
401-
ubxConstellations[x].enabled = settingValueBool;
407+
settings.ubxConstellations[x].enabled = settingValueBool;
402408
knownSetting = true;
403409
break;
404410
}
@@ -410,9 +416,9 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
410416
{
411417
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
412418
{
413-
if (strcmp(settingName, ubxMessages[x].msgTextName) == 0)
419+
if (strcmp(settingName, settings.ubxMessages[x].msgTextName) == 0)
414420
{
415-
ubxMessages[x].msgRate = settingValue;
421+
settings.ubxMessages[x].msgRate = settingValue;
416422
knownSetting = true;
417423
break;
418424
}

0 commit comments

Comments
 (0)