@@ -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)
159213void updateAccuracyLEDs ()
160214{
0 commit comments