Skip to content

Commit 11fff83

Browse files
committed
Add SBAS configure. Remove ZED module reset.
Resetting only the module but not the various NVM settings doesn't make sense. Better to only allow full factory reset (which includes ZED-F9P reset) via main menu.
1 parent 8514674 commit 11fff83

File tree

7 files changed

+226
-61
lines changed

7 files changed

+226
-61
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323
Text menu interactions
2424
2525
Main Menu (Display MAC address / broadcast name):
26-
(Done) GNSS - Configure measurement rate, reset module
27-
(Done) Log - Log to SD, enable/disable RAWX
26+
(Done) GNSS - Configure measurement rate, enable/disable common NMEA sentences, RAWX, SBAS
27+
(Done) Log - Log to SD
2828
(Done) Base - Enter fixed coordinates, survey-in settings
29+
(Done) Ports - Configure Radio and Data port baud rates
2930
(Done) Test menu
3031
31-
Configure baud rates of Radio and Data ports
32-
Move RAWX to GNSS menu
33-
Enable/disable NMEA setences
34-
Disable/enable SBAS
3532
Enable various debug outputs sent over BT
3633
3734
*/

Firmware/RTK_Surveyor/Rover.ino

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ bool configureUbloxModuleRover()
106106

107107
response &= setNMEASettings(); //Enable high precision NMEA and extended sentences
108108

109-
response &= setSBAS(false); //Disable SBAS. Work around for RTK LED not working in v1.13 firmware.
110-
109+
if (settings.enableSBAS == true)
110+
response &= setSBAS(true); //Enable SBAS
111+
else
112+
response &= setSBAS(false); //Disable SBAS. Work around for RTK LED not working in v1.13 firmware.
113+
111114
return (response);
112115
}
113116

@@ -144,6 +147,30 @@ bool setNMEASettings()
144147
return (true);
145148
}
146149

150+
//Returns true if SBAS is enabled
151+
bool getSBAS()
152+
{
153+
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
154+
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
155+
156+
customCfg.cls = UBX_CLASS_CFG; // This is the message Class
157+
customCfg.id = UBX_CFG_GNSS; // This is the message ID
158+
customCfg.len = 0; // Setting the len (length) to zero lets us poll the current settings
159+
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
160+
161+
uint16_t maxWait = 250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
162+
163+
// Read the current setting. The results will be loaded into customCfg.
164+
if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
165+
{
166+
Serial.println(F("Get SBAS failed!"));
167+
return (false);
168+
}
169+
170+
if (customPayload[8 + 8 * 1] & (1 << 0)) return true; //Check if bit 0 is set
171+
return false;
172+
}
173+
147174
//The u-blox library doesn't directly support SBAS control so let's do it manually
148175
bool setSBAS(bool enableSBAS)
149176
{
@@ -166,15 +193,13 @@ bool setSBAS(bool enableSBAS)
166193

167194
if (enableSBAS)
168195
{
169-
if (customPayload[8 + 1 * 8] & (1 << 0)) return true; //If we want the bit set, and it already is, simply return
170-
171-
customPayload[8 + 1 * 8] |= (1 << 0); //Set the enable bit
196+
customPayload[8 + 8 * 1] |= (1 << 0); //Set the enable bit
197+
//We must enable the gnssID as well
198+
customPayload[8 + 8 * 1 + 2] |= (1 << 0); //Set the enable bit (16) for SBAS L1C/A
172199
}
173200
else
174201
{
175-
if (customPayload[8 + 1 * 8] & (1 << 0) == 0) return true; //If we want the bit cleared, and it already is, simply return
176-
177-
customPayload[8 + 1 * 8] &= ~(1 << 0); //Clear the enable bit
202+
customPayload[8 + 8 * 1] &= ~(1 << 0); //Clear the enable bit
178203
}
179204

180205
// Now we write the custom packet back again to change the setting

Firmware/RTK_Surveyor/System.ino

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,43 @@ bool configureUbloxModule()
178178
}
179179

180180
//Make sure the appropriate NMEA sentences are enabled
181-
if (getNMEASettings(UBX_NMEA_GGA, COM_PORT_UART1) != 1)
182-
response &= myGPS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1);
183-
if (getNMEASettings(UBX_NMEA_GSA, COM_PORT_UART1) != 1)
184-
response &= myGPS.enableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1);
181+
if (settings.outputSentenceGGA == true)
182+
if (getNMEASettings(UBX_NMEA_GGA, COM_PORT_UART1) != 1)
183+
response &= myGPS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1);
184+
else if (settings.outputSentenceGGA == false)
185+
if (getNMEASettings(UBX_NMEA_GGA, COM_PORT_UART1) != 0)
186+
response &= myGPS.disableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1);
187+
188+
if (settings.outputSentenceGSA == true)
189+
if (getNMEASettings(UBX_NMEA_GSA, COM_PORT_UART1) != 1)
190+
response &= myGPS.enableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1);
191+
else if (settings.outputSentenceGSA == false)
192+
if (getNMEASettings(UBX_NMEA_GSA, COM_PORT_UART1) != 0)
193+
response &= myGPS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1);
185194

186195
//When receiving 15+ satellite information, the GxGSV sentences can be a large amount of data
187196
//If the update rate is >1Hz then this data can overcome the BT capabilities causing timeouts and lag
188197
//So we set the GSV sentence to 1Hz regardless of update rate
189-
if (getNMEASettings(UBX_NMEA_GSV, COM_PORT_UART1) != settings.gnssMeasurementFrequency)
190-
response &= myGPS.enableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1, settings.gnssMeasurementFrequency);
191-
192-
if (getNMEASettings(UBX_NMEA_RMC, COM_PORT_UART1) != 1)
193-
response &= myGPS.enableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1);
194-
if (getNMEASettings(UBX_NMEA_GST, COM_PORT_UART1) != 1)
195-
response &= myGPS.enableNMEAMessage(UBX_NMEA_GST, COM_PORT_UART1);
198+
if (settings.outputSentenceGSV == true)
199+
if (getNMEASettings(UBX_NMEA_GSV, COM_PORT_UART1) != settings.gnssMeasurementFrequency)
200+
response &= myGPS.enableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1, settings.gnssMeasurementFrequency);
201+
else if (settings.outputSentenceGSV == false)
202+
if (getNMEASettings(UBX_NMEA_GSV, COM_PORT_UART1) != 0)
203+
response &= myGPS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1);
204+
205+
if (settings.outputSentenceRMC == true)
206+
if (getNMEASettings(UBX_NMEA_RMC, COM_PORT_UART1) != 1)
207+
response &= myGPS.enableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1);
208+
else if (settings.outputSentenceRMC == false)
209+
if (getNMEASettings(UBX_NMEA_RMC, COM_PORT_UART1) != 0)
210+
response &= myGPS.disableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1);
211+
212+
if (settings.outputSentenceGST == true)
213+
if (getNMEASettings(UBX_NMEA_GST, COM_PORT_UART1) != 1)
214+
response &= myGPS.enableNMEAMessage(UBX_NMEA_GST, COM_PORT_UART1);
215+
else if (settings.outputSentenceGST == false)
216+
if (getNMEASettings(UBX_NMEA_GST, COM_PORT_UART1) != 0)
217+
response &= myGPS.disableNMEAMessage(UBX_NMEA_GST, COM_PORT_UART1);
196218

197219
response &= myGPS.setAutoPVT(true); //Tell the GPS to "send" each solution
198220
//response &= myGPS.setAutoPVT(true, false); //Tell the GPS to "send" each solution and the lib not to update stale data implicitly
@@ -201,7 +223,6 @@ bool configureUbloxModule()
201223
if (getSerialRate(COM_PORT_UART1) != settings.dataPortBaud)
202224
{
203225
Serial.println("Updating UART1 rate");
204-
205226
myGPS.setSerialRate(settings.dataPortBaud, COM_PORT_UART1); //Set UART1 to 115200
206227
}
207228
if (getSerialRate(COM_PORT_UART2) != settings.radioPortBaud)

Firmware/RTK_Surveyor/menuGNSS.ino

Lines changed: 130 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,33 @@ void menuGNSS()
1010
Serial.print(F("1) Set measurement frequency: "));
1111
Serial.println(settings.gnssMeasurementFrequency);
1212

13-
Serial.println(F("r) Reset GNSS Receiver"));
13+
Serial.print(F("2) Toggle GxGGA sentence: "));
14+
if (getNMEASettings(UBX_NMEA_GGA, COM_PORT_UART1) == 1) Serial.println(F("Enabled"));
15+
else Serial.println(F("Disabled"));
16+
17+
Serial.print(F("3) Toggle GxGSA sentence: "));
18+
if (getNMEASettings(UBX_NMEA_GSA, COM_PORT_UART1) == 1) Serial.println(F("Enabled"));
19+
else Serial.println(F("Disabled"));
20+
21+
Serial.print(F("4) Toggle GxGSV sentence: "));
22+
if (getNMEASettings(UBX_NMEA_GSV, COM_PORT_UART1) == settings.gnssMeasurementFrequency) Serial.println(F("Enabled"));
23+
else Serial.println(F("Disabled"));
24+
25+
Serial.print(F("5) Toggle GxRMC sentence: "));
26+
if (getNMEASettings(UBX_NMEA_RMC, COM_PORT_UART1) == 1) Serial.println(F("Enabled"));
27+
else Serial.println(F("Disabled"));
28+
29+
Serial.print(F("6) Toggle GxGST sentence: "));
30+
if (getNMEASettings(UBX_NMEA_GST, COM_PORT_UART1) == 1) Serial.println(F("Enabled"));
31+
else Serial.println(F("Disabled"));
32+
33+
Serial.print(F("7) Toggle GNSS RAWX sentence: "));
34+
if (getRAWXSettings(COM_PORT_UART1) == 1) Serial.println(F("Enabled"));
35+
else Serial.println(F("Disabled"));
36+
37+
Serial.print(F("8) Toggle SBAS: "));
38+
if (getSBAS() == true) Serial.println(F("Enabled"));
39+
else Serial.println(F("Disabled"));
1440

1541
Serial.println(F("x) Exit"));
1642

@@ -29,22 +55,113 @@ void menuGNSS()
2955
settings.gnssMeasurementFrequency = rate; //Recorded to NVM and file at main menu exit
3056
}
3157
}
32-
33-
else if (incoming == 'r')
58+
else if (incoming == '2')
3459
{
35-
Serial.println(F("\r\nResetting ZED-F9P to factory defaults. Press 'y' to confirm:"));
36-
byte bContinue = getByteChoice(menuTimeout);
37-
if (bContinue == 'y')
60+
if (getNMEASettings(UBX_NMEA_GGA, COM_PORT_UART1) == 1)
3861
{
39-
myGPS.factoryReset(); //Reset everything: baud rate, I2C address, update rate, everything.
40-
41-
Serial.println(F("ZED-F9P settings reset. Please reset RTK Surveyor. Freezing."));
42-
while (1)
43-
delay(1); //Prevent CPU freakout
62+
//Disable the sentence
63+
if (myGPS.disableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1) == true)
64+
settings.outputSentenceGGA = false;
65+
}
66+
else
67+
{
68+
//Enable the sentence
69+
if (myGPS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1) == true)
70+
settings.outputSentenceGGA = true;
71+
}
72+
}
73+
else if (incoming == '3')
74+
{
75+
if (getNMEASettings(UBX_NMEA_GSA, COM_PORT_UART1) == 1)
76+
{
77+
//Disable the sentence
78+
if (myGPS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1) == true)
79+
settings.outputSentenceGSA = false;
80+
}
81+
else
82+
{
83+
//Enable the sentence
84+
if (myGPS.enableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1) == true)
85+
settings.outputSentenceGSA = true;
86+
}
87+
}
88+
else if (incoming == '4')
89+
{
90+
if (getNMEASettings(UBX_NMEA_GSV, COM_PORT_UART1) == settings.gnssMeasurementFrequency)
91+
{
92+
//Disable the sentence
93+
if (myGPS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1) == true)
94+
settings.outputSentenceGSV = false;
95+
}
96+
else
97+
{
98+
//Enable the sentence at measurement rate to make sentence transmit at 1Hz to avoid stressing BT SPP buffers with 25+ SIV
99+
if (myGPS.enableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1, settings.gnssMeasurementFrequency) == true)
100+
settings.outputSentenceGSV = true;
101+
}
102+
}
103+
else if (incoming == '5')
104+
{
105+
if (getNMEASettings(UBX_NMEA_RMC, COM_PORT_UART1) == 1)
106+
{
107+
//Disable the sentence
108+
if (myGPS.disableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1) == true)
109+
settings.outputSentenceRMC = false;
110+
}
111+
else
112+
{
113+
//Enable the sentence
114+
if (myGPS.enableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1) == true)
115+
settings.outputSentenceRMC = true;
116+
}
117+
}
118+
else if (incoming == '6')
119+
{
120+
if (getNMEASettings(UBX_NMEA_GST, COM_PORT_UART1) == 1)
121+
{
122+
//Disable the sentence
123+
if (myGPS.disableNMEAMessage(UBX_NMEA_GST, COM_PORT_UART1) == true)
124+
settings.outputSentenceGST = false;
44125
}
45126
else
46-
Serial.println(F("Reset aborted"));
127+
{
128+
//Enable the sentence
129+
if (myGPS.enableNMEAMessage(UBX_NMEA_GST, COM_PORT_UART1) == true)
130+
settings.outputSentenceGST = true;
131+
}
47132
}
133+
else if (incoming == '7')
134+
{
135+
if (getRAWXSettings(COM_PORT_UART1) == 1)
136+
{
137+
//Disable
138+
if (myGPS.disableMessage(UBX_CLASS_RXM, UBX_RXM_RAWX, COM_PORT_UART1) == true)
139+
settings.gnssRAWOutput = false;
140+
}
141+
else
142+
{
143+
//Enable
144+
if (myGPS.enableMessage(UBX_CLASS_RXM, UBX_RXM_RAWX, COM_PORT_UART1) == true)
145+
settings.gnssRAWOutput = true;
146+
}
147+
}
148+
else if (incoming == '8')
149+
{
150+
if (getSBAS() == true)
151+
{
152+
//Disable it
153+
if (setSBAS(false) == true)
154+
settings.enableSBAS = false;
155+
}
156+
else
157+
{
158+
//Enable it
159+
if (setSBAS(true) == true)
160+
settings.enableSBAS = true;
161+
}
162+
163+
}
164+
48165
else if (incoming == 'x')
49166
break;
50167
else if (incoming == STATUS_GETBYTE_TIMEOUT)
@@ -53,6 +170,7 @@ void menuGNSS()
53170
printUnknown(incoming);
54171
}
55172

173+
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
56174
beginGNSS(); //Push any new settings to GNSS module
57175

58176
while (Serial.available()) Serial.read(); //Empty buffer of any newline chars

Firmware/RTK_Surveyor/menuLog.ino

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ void menuLog()
2525

2626
if (settings.zedOutputLogging == true)
2727
{
28-
Serial.print(F("2) Toggle GNSS RAWX logging: "));
29-
if (getRAWXSettings(COM_PORT_UART1) == 1) Serial.println(F("Enabled"));
30-
else Serial.println(F("Disabled"));
31-
32-
Serial.print(F("3) Update file timestamp with each write: "));
28+
Serial.print(F("2) Update file timestamp with each write: "));
3329
if (settings.frequentFileAccessTimestamps == true) Serial.println(F("Enabled"));
3430
else Serial.println(F("Disabled"));
3531

36-
Serial.print(F("4) Set max logging time: "));
32+
Serial.print(F("3) Set max logging time: "));
3733
Serial.print(settings.maxLogTime_minutes);
3834
Serial.println(F(" minutes"));
3935
}
@@ -52,24 +48,8 @@ void menuLog()
5248
else if (settings.zedOutputLogging == true)
5349
{
5450
if (incoming == '2')
55-
{
56-
if (getRAWXSettings(COM_PORT_UART1) == 1)
57-
{
58-
//Disable
59-
settings.gnssRAWOutput = false;
60-
myGPS.disableMessage(UBX_CLASS_RXM, UBX_RXM_RAWX, COM_PORT_UART1);
61-
}
62-
else
63-
{
64-
//Enable
65-
settings.gnssRAWOutput = true;
66-
myGPS.enableMessage(UBX_CLASS_RXM, UBX_RXM_RAWX, COM_PORT_UART1);
67-
}
68-
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
69-
}
70-
else if (incoming == '3')
7151
settings.frequentFileAccessTimestamps ^= 1;
72-
else if (incoming == '4')
52+
else if (incoming == '3')
7353
{
7454
Serial.print(F("Enter max minutes to log data: "));
7555
int maxMinutes = getNumber(menuTimeout); //Timeout after x seconds

Firmware/RTK_Surveyor/nvm.ino

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ void recordSystemSettingsToFile()
8888
settingsFile.println("fixedAltitude=" + (String)settings.fixedAltitude);
8989
settingsFile.println("dataPortBaud=" + (String)settings.dataPortBaud);
9090
settingsFile.println("radioPortBaud=" + (String)settings.radioPortBaud);
91+
settingsFile.println("outputSentenceGGA=" + (String)settings.outputSentenceGGA);
92+
settingsFile.println("outputSentenceGSA=" + (String)settings.outputSentenceGSA);
93+
settingsFile.println("outputSentenceGSV=" + (String)settings.outputSentenceGSV);
94+
settingsFile.println("outputSentenceRMC=" + (String)settings.outputSentenceRMC);
95+
settingsFile.println("outputSentenceGST=" + (String)settings.outputSentenceGST);
96+
settingsFile.println("enableSBAS=" + (String)settings.enableSBAS);
9197

9298
updateDataFileAccess(&settingsFile); // Update the file access time & date
9399

@@ -257,6 +263,18 @@ bool parseLine(char* str) {
257263
settings.dataPortBaud = d;
258264
else if (strcmp(settingName, "radioPortBaud") == 0)
259265
settings.radioPortBaud = d;
266+
else if (strcmp(settingName, "outputSentenceGGA") == 0)
267+
settings.outputSentenceGGA = d;
268+
else if (strcmp(settingName, "outputSentenceGSA") == 0)
269+
settings.outputSentenceGSA = d;
270+
else if (strcmp(settingName, "outputSentenceGSV") == 0)
271+
settings.outputSentenceGSV = d;
272+
else if (strcmp(settingName, "outputSentenceRMC") == 0)
273+
settings.outputSentenceRMC = d;
274+
else if (strcmp(settingName, "outputSentenceGST") == 0)
275+
settings.outputSentenceGST = d;
276+
else if (strcmp(settingName, "enableSBAS") == 0)
277+
settings.enableSBAS = d;
260278

261279
else
262280
Serial.printf("Unknown setting %s on line: %s\r\n", settingName, str);

0 commit comments

Comments
 (0)