@@ -34,12 +34,6 @@ bool configureUbloxModuleRover()
34
34
Serial.println (F (" setNMEASettings failed" ));
35
35
36
36
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" ));
43
37
44
38
// The last thing we do is set output rate.
45
39
response = true ; // Reset
@@ -90,8 +84,8 @@ bool setNMEASettings()
90
84
return (true );
91
85
}
92
86
93
- // Returns true if SBAS is enabled
94
- bool getSBAS ( )
87
+ // Returns true if constellation is enabled
88
+ bool getConstellation ( uint8_t constellation )
95
89
{
96
90
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
97
91
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()
106
100
// Read the current setting. The results will be loaded into customCfg.
107
101
if (i2cGNSS.sendCommand (&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
108
102
{
109
- Serial.println (F (" Get SBAS failed" ));
103
+ Serial.println (F (" Get Constellation failed" ));
110
104
return (false );
111
105
}
112
106
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
114
108
return false ;
115
109
}
116
110
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)
119
114
{
120
115
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
121
116
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)
130
125
// Read the current setting. The results will be loaded into customCfg.
131
126
if (i2cGNSS.sendCommand (&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
132
127
{
133
- Serial.println (F (" Set SBAS failed" ));
128
+ Serial.println (F (" Set Constellation failed" ));
134
129
return (false );
135
130
}
136
131
137
- if (enableSBAS )
132
+ if (enable )
138
133
{
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
+ }
142
170
}
143
- else
171
+ else // Disable
144
172
{
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
+
146
185
}
147
186
148
187
// Now we write the custom packet back again to change the setting
149
188
if (i2cGNSS.sendCommand (&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT) // This time we are only expecting an ACK
150
189
{
151
- Serial.println (F (" SBAS setting failed" ));
190
+ Serial.println (F (" Constellation setting failed" ));
152
191
return (false );
153
192
}
154
193
155
194
return (true );
156
195
}
157
196
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
+
158
212
// Turn on the three accuracy LEDs depending on our current HPA (horizontal positional accuracy)
159
213
void updateAccuracyLEDs ()
160
214
{
0 commit comments