Skip to content

Commit d7c19b2

Browse files
committed
Add support for constellation configuration (NVM, menu, etc)
1 parent a85daf0 commit d7c19b2

File tree

6 files changed

+225
-61
lines changed

6 files changed

+225
-61
lines changed

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void recordSystemSettings()
4848
if (settings.sizeOfSettings > EEPROM_SIZE)
4949
{
5050
displayError((char*)"EEPROM");
51-
51+
5252
while (1) //Hard freeze
5353
{
5454
Serial.printf("Size of settings is %d bytes\n\r", sizeof(settings));
@@ -119,7 +119,6 @@ void recordSystemSettingsToFile()
119119

120120
settingsFile.println("dataPortBaud=" + (String)settings.dataPortBaud);
121121
settingsFile.println("radioPortBaud=" + (String)settings.radioPortBaud);
122-
settingsFile.println("enableSBAS=" + (String)settings.enableSBAS);
123122
settingsFile.println("enableNtripServer=" + (String)settings.enableNtripServer);
124123
settingsFile.println("casterHost=" + (String)settings.casterHost);
125124
settingsFile.println("casterPort=" + (String)settings.casterPort);
@@ -141,6 +140,14 @@ void recordSystemSettingsToFile()
141140
settingsFile.println("lastState=" + (String)settings.lastState);
142141
settingsFile.println("throttleDuringSPPCongestion=" + (String)settings.throttleDuringSPPCongestion);
143142

143+
//Record constellation settings
144+
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
145+
{
146+
char tempString[50]; //constellation.BeiDou=1
147+
sprintf(tempString, "constellation.%s=%d", ubxConstellations[x].textName, ubxConstellations[x].enabled);
148+
settingsFile.println(tempString);
149+
}
150+
144151
//Record message settings
145152
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
146153
{
@@ -350,8 +357,6 @@ bool parseLine(char* str) {
350357
settings.dataPortBaud = d;
351358
else if (strcmp(settingName, "radioPortBaud") == 0)
352359
settings.radioPortBaud = d;
353-
else if (strcmp(settingName, "enableSBAS") == 0)
354-
settings.enableSBAS = d;
355360
else if (strcmp(settingName, "enableNtripServer") == 0)
356361
settings.enableNtripServer = d;
357362
else if (strcmp(settingName, "casterHost") == 0)
@@ -395,23 +400,43 @@ bool parseLine(char* str) {
395400
else if (strcmp(settingName, "throttleDuringSPPCongestion") == 0)
396401
settings.throttleDuringSPPCongestion = d;
397402

398-
//Check for message rates
403+
//Check for bulk settings (constellations and message rates)
399404
//Must be last on else list
400405
else
401406
{
402407
bool knownSetting = false;
403408

404-
//Scan for message settings
405-
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
409+
//Scan for constellation settings
410+
if (knownSetting == false)
406411
{
407-
char tempString[50]; //message.nmea_dtm.msgRate=5
408-
sprintf(tempString, "message.%s.msgRate", ubxMessages[x].msgTextName);
412+
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
413+
{
414+
char tempString[50]; //constellation.GPS=1
415+
sprintf(tempString, "constellation.%s", ubxConstellations[x].textName);
409416

410-
if (strcmp(settingName, tempString) == 0)
417+
if (strcmp(settingName, tempString) == 0)
418+
{
419+
ubxConstellations[x].enabled = d;
420+
knownSetting = true;
421+
break;
422+
}
423+
}
424+
}
425+
426+
//Scan for message settings
427+
if (knownSetting == false)
428+
{
429+
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
411430
{
412-
ubxMessages[x].msgRate = d;
413-
knownSetting = true;
414-
break;
431+
char tempString[50]; //message.nmea_dtm.msgRate=5
432+
sprintf(tempString, "message.%s.msgRate", ubxMessages[x].msgTextName);
433+
434+
if (strcmp(settingName, tempString) == 0)
435+
{
436+
ubxMessages[x].msgRate = d;
437+
knownSetting = true;
438+
break;
439+
}
415440
}
416441
}
417442

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/Rover.ino

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ bool configureUbloxModuleRover()
3434
Serial.println(F("setNMEASettings failed"));
3535

3636
response = true; //Reset
37-
if (settings.enableSBAS == true)
38-
response &= setSBAS(true); //Enable SBAS
39-
else
40-
response &= setSBAS(false); //Disable SBAS. Work around for RTK LED not working in v1.13 firmware.
41-
if (response == false)
42-
Serial.println(F("Set SBAS failed"));
4337

4438
//The last thing we do is set output rate.
4539
response = true; //Reset
@@ -90,8 +84,8 @@ bool setNMEASettings()
9084
return (true);
9185
}
9286

93-
//Returns true if SBAS is enabled
94-
bool getSBAS()
87+
//Returns true if constellation is enabled
88+
bool getConstellation(uint8_t constellation)
9589
{
9690
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
9791
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
@@ -106,16 +100,17 @@ bool getSBAS()
106100
// Read the current setting. The results will be loaded into customCfg.
107101
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
108102
{
109-
Serial.println(F("Get SBAS failed"));
103+
Serial.println(F("Get Constellation failed"));
110104
return (false);
111105
}
112106

113-
if (customPayload[8 + 8 * 1] & (1 << 0)) return true; //Check if bit 0 is set
107+
if (customPayload[8 + 8 * constellation] & (1 << 0)) return true; //Check if bit 0 is set
114108
return false;
115109
}
116110

117-
//The u-blox library doesn't directly support SBAS control so let's do it manually
118-
bool setSBAS(bool enableSBAS)
111+
//The u-blox library doesn't directly support constellation control so let's do it manually
112+
//Also allows the enable/disable of any constellation (BeiDou, Galileo, etc)
113+
bool setConstellation(uint8_t constellation, bool enable)
119114
{
120115
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
121116
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
@@ -130,31 +125,90 @@ bool setSBAS(bool enableSBAS)
130125
// Read the current setting. The results will be loaded into customCfg.
131126
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
132127
{
133-
Serial.println(F("Set SBAS failed"));
128+
Serial.println(F("Set Constellation failed"));
134129
return (false);
135130
}
136131

137-
if (enableSBAS)
132+
if (enable)
138133
{
139-
customPayload[8 + 8 * 1] |= (1 << 0); //Set the enable bit
140-
//We must enable the gnssID as well
141-
customPayload[8 + 8 * 1 + 2] |= (1 << 0); //Set the enable bit (16) for SBAS L1C/A
134+
if (constellation == SFE_UBLOX_GNSS_ID_GPS || constellation == SFE_UBLOX_GNSS_ID_QZSS)
135+
{
136+
//QZSS must follow GPS
137+
customPayload[locateGNSSID(customPayload, SFE_UBLOX_GNSS_ID_GPS) + 4] |= (1 << 0); //Set the enable bit
138+
customPayload[locateGNSSID(customPayload, SFE_UBLOX_GNSS_ID_QZSS) + 4] |= (1 << 0); //Set the enable bit
139+
}
140+
else
141+
{
142+
customPayload[locateGNSSID(customPayload, constellation) + 4] |= (1 << 0); //Set the enable bit
143+
}
144+
145+
//Set sigCfgMask as well
146+
if (constellation == SFE_UBLOX_GNSS_ID_GPS || constellation == SFE_UBLOX_GNSS_ID_QZSS)
147+
{
148+
customPayload[locateGNSSID(customPayload, SFE_UBLOX_GNSS_ID_GPS) + 6] |= 0x11; //Enable GPS L1C/A, and L2C
149+
150+
//QZSS must follow GPS
151+
customPayload[locateGNSSID(customPayload, SFE_UBLOX_GNSS_ID_QZSS) + 6] = 0x11; //Enable QZSS L1C/A, and L2C - Follow u-center
152+
//customPayload[locateGNSSID(customPayload, SFE_UBLOX_GNSS_ID_QZSS) + 6] = 0x15; //Enable QZSS L1C/A, L1S, and L2C
153+
}
154+
else if (constellation == SFE_UBLOX_GNSS_ID_SBAS)
155+
{
156+
customPayload[locateGNSSID(customPayload, constellation) + 6] |= 0x01; //Enable SBAS L1C/A
157+
}
158+
else if (constellation == SFE_UBLOX_GNSS_ID_GALILEO)
159+
{
160+
customPayload[locateGNSSID(customPayload, constellation) + 6] |= 0x21; //Enable Galileo E1/E5b
161+
}
162+
else if (constellation == SFE_UBLOX_GNSS_ID_BEIDOU)
163+
{
164+
customPayload[locateGNSSID(customPayload, constellation) + 6] |= 0x11; //Enable BeiDou B1I/B2I
165+
}
166+
else if (constellation == SFE_UBLOX_GNSS_ID_GLONASS)
167+
{
168+
customPayload[locateGNSSID(customPayload, constellation) + 6] |= 0x11; //Enable GLONASS L1 and L2
169+
}
142170
}
143-
else
171+
else //Disable
144172
{
145-
customPayload[8 + 8 * 1] &= ~(1 << 0); //Clear the enable bit
173+
//QZSS must follow GPS
174+
if (constellation == SFE_UBLOX_GNSS_ID_GPS || constellation == SFE_UBLOX_GNSS_ID_QZSS)
175+
{
176+
customPayload[locateGNSSID(customPayload, SFE_UBLOX_GNSS_ID_GPS) + 4] &= ~(1 << 0); //Clear the enable bit
177+
178+
customPayload[locateGNSSID(customPayload, SFE_UBLOX_GNSS_ID_QZSS) + 4] &= ~(1 << 0); //Clear the enable bit
179+
}
180+
else
181+
{
182+
customPayload[locateGNSSID(customPayload, constellation) + 4] &= ~(1 << 0); //Clear the enable bit
183+
}
184+
146185
}
147186

148187
// Now we write the custom packet back again to change the setting
149188
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT) // This time we are only expecting an ACK
150189
{
151-
Serial.println(F("SBAS setting failed"));
190+
Serial.println(F("Constellation setting failed"));
152191
return (false);
153192
}
154193

155194
return (true);
156195
}
157196

197+
//Given a payload, return the location of a given constellation
198+
//This is needed because IMES is not currently returned in the query packet
199+
//so QZSS and GLONAS are offset by -8 bytes.
200+
uint8_t locateGNSSID(uint8_t *customPayload, uint8_t constellation)
201+
{
202+
for (int x = 0 ; x < 7 ; x++) //Assume max of 7 constellations
203+
{
204+
if (customPayload[4 + 8 * x] == constellation) //Test gnssid
205+
return (4 + x * 8);
206+
}
207+
208+
Serial.println(F("locateGNSSID failed"));
209+
return (0);
210+
}
211+
158212
//Turn on the three accuracy LEDs depending on our current HPA (horizontal positional accuracy)
159213
void updateAccuracyLEDs()
160214
{

Firmware/RTK_Surveyor/System.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ bool configureUbloxModule()
242242
response &= i2cGNSS.setPortInput(COM_PORT_USB, (COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3)); //Set the USB port to everything
243243
}
244244

245+
response &= configureConstellations(); //Enable the constellations the user has set
246+
245247
response &= configureGNSSMessageRates(COM_PORT_UART1, ubxMessages); //Make sure the appropriate messages are enabled
246248

247249
response &= i2cGNSS.setAutoPVT(true, false); //Tell the GPS to "send" each solution, but do not update stale data when accessed

0 commit comments

Comments
 (0)