@@ -4,7 +4,7 @@ bool updateRoverStatus()
44 // Update the horizontal accuracy LEDs only every second or so
55 if (millis () - lastRoverUpdate > 2000 )
66 {
7- lastRoverUpdate += 2000 ;
7+ lastRoverUpdate = millis () ;
88
99 uint32_t accuracy = myGPS.getHorizontalAccuracy (250 );
1010
@@ -14,33 +14,33 @@ bool updateRoverStatus()
1414 float f_accuracy = accuracy;
1515 f_accuracy = f_accuracy / 10000.0 ; // Convert from mm * 10^-1 to m
1616
17- Serial.print (" Rover Accuracy (m): " );
17+ Serial.print (F ( " Rover Accuracy (m): " ) );
1818 Serial.print (f_accuracy, 4 ); // Print the accuracy with 4 decimal places
1919
2020 if (f_accuracy <= 0.02 )
2121 {
22- Serial.print (" 0.01m LED" );
22+ Serial.print (F ( " 0.01m LED" ) );
2323 digitalWrite (positionAccuracyLED_1cm, HIGH);
2424 digitalWrite (positionAccuracyLED_10cm, HIGH);
2525 digitalWrite (positionAccuracyLED_100cm, HIGH);
2626 }
2727 else if (f_accuracy <= 0.100 )
2828 {
29- Serial.print (" 0.1m LED" );
29+ Serial.print (F ( " 0.1m LED" ) );
3030 digitalWrite (positionAccuracyLED_1cm, LOW);
3131 digitalWrite (positionAccuracyLED_10cm, HIGH);
3232 digitalWrite (positionAccuracyLED_100cm, HIGH);
3333 }
3434 else if (f_accuracy <= 1.0000 )
3535 {
36- Serial.print (" 1m LED" );
36+ Serial.print (F ( " 1m LED" ) );
3737 digitalWrite (positionAccuracyLED_1cm, LOW);
3838 digitalWrite (positionAccuracyLED_10cm, LOW);
3939 digitalWrite (positionAccuracyLED_100cm, HIGH);
4040 }
4141 else if (f_accuracy > 1.0 )
4242 {
43- Serial.print (" No LEDs" );
43+ Serial.print (F ( " No LEDs" ) );
4444 digitalWrite (positionAccuracyLED_1cm, LOW);
4545 digitalWrite (positionAccuracyLED_10cm, LOW);
4646 digitalWrite (positionAccuracyLED_100cm, LOW);
@@ -49,10 +49,10 @@ bool updateRoverStatus()
4949 }
5050 else
5151 {
52- Serial.print (" Rover Accuracy: " );
52+ Serial.print (F ( " Rover Accuracy: " ) );
5353 Serial.print (accuracy);
5454 Serial.print (" " );
55- Serial.print (" No lock. SIV: " );
55+ Serial.print (F ( " No lock. SIV: " ) );
5656 Serial.print (myGPS.getSIV ());
5757 Serial.println ();
5858 }
@@ -64,51 +64,35 @@ bool configureUbloxModuleRover()
6464{
6565 bool response = myGPS.disableSurveyMode (); // Disable survey
6666
67+ // Set output rate
68+ if (myGPS.getNavigationFrequency () != settings.gnssMeasurementFrequency )
69+ {
70+ response &= myGPS.setNavigationFrequency (settings.gnssMeasurementFrequency ); // Set output in Hz
71+ }
72+
73+ // Set dynamic model
74+ if (myGPS.getDynamicModel () != DYN_MODEL_PORTABLE)
75+ {
76+ response &= myGPS.setDynamicModel (DYN_MODEL_PORTABLE);
77+ if (response == false )
78+ Serial.println (F (" setDynamicModel failed!" ));
79+ }
80+
6781 // Disable RTCM sentences
68- if (getRTCMSettings (UBX_RTCM_1005, COM_PORT_UART2) != 0 )
69- response &= myGPS.enableRTCMmessage (UBX_RTCM_1005, COM_PORT_UART2, 0 );
70- if (getRTCMSettings (UBX_RTCM_1074, COM_PORT_UART2) != 0 )
71- response &= myGPS.enableRTCMmessage (UBX_RTCM_1074, COM_PORT_UART2, 0 );
72- if (getRTCMSettings (UBX_RTCM_1084, COM_PORT_UART2) != 0 )
73- response &= myGPS.enableRTCMmessage (UBX_RTCM_1084, COM_PORT_UART2, 0 );
74- if (getRTCMSettings (UBX_RTCM_1094, COM_PORT_UART2) != 0 )
75- response &= myGPS.enableRTCMmessage (UBX_RTCM_1094, COM_PORT_UART2, 0 );
76- if (getRTCMSettings (UBX_RTCM_1124, COM_PORT_UART2) != 0 )
77- response &= myGPS.enableRTCMmessage (UBX_RTCM_1124, COM_PORT_UART2, 0 );
78- if (getRTCMSettings (UBX_RTCM_1230, COM_PORT_UART2) != 0 )
79- response &= myGPS.enableRTCMmessage (UBX_RTCM_1230, COM_PORT_UART2, 0 );
80-
81- if (getRTCMSettings (UBX_RTCM_1005, COM_PORT_UART1) != 0 )
82- response &= myGPS.enableRTCMmessage (UBX_RTCM_1005, COM_PORT_UART1, 0 );
83- if (getRTCMSettings (UBX_RTCM_1074, COM_PORT_UART1) != 0 )
84- response &= myGPS.enableRTCMmessage (UBX_RTCM_1074, COM_PORT_UART1, 0 );
85- if (getRTCMSettings (UBX_RTCM_1084, COM_PORT_UART1) != 0 )
86- response &= myGPS.enableRTCMmessage (UBX_RTCM_1084, COM_PORT_UART1, 0 );
87- if (getRTCMSettings (UBX_RTCM_1094, COM_PORT_UART1) != 0 )
88- response &= myGPS.enableRTCMmessage (UBX_RTCM_1094, COM_PORT_UART1, 0 );
89- if (getRTCMSettings (UBX_RTCM_1124, COM_PORT_UART1) != 0 )
90- response &= myGPS.enableRTCMmessage (UBX_RTCM_1124, COM_PORT_UART1, 0 );
91- if (getRTCMSettings (UBX_RTCM_1230, COM_PORT_UART1) != 0 )
92- response &= myGPS.enableRTCMmessage (UBX_RTCM_1230, COM_PORT_UART1, 0 );
93-
94- if (getRTCMSettings (UBX_RTCM_1005, COM_PORT_USB) != 0 )
95- response &= myGPS.enableRTCMmessage (UBX_RTCM_1005, COM_PORT_USB, 0 );
96- if (getRTCMSettings (UBX_RTCM_1074, COM_PORT_USB) != 0 )
97- response &= myGPS.enableRTCMmessage (UBX_RTCM_1074, COM_PORT_USB, 0 );
98- if (getRTCMSettings (UBX_RTCM_1084, COM_PORT_USB) != 0 )
99- response &= myGPS.enableRTCMmessage (UBX_RTCM_1084, COM_PORT_USB, 0 );
100- if (getRTCMSettings (UBX_RTCM_1094, COM_PORT_USB) != 0 )
101- response &= myGPS.enableRTCMmessage (UBX_RTCM_1094, COM_PORT_USB, 0 );
102- if (getRTCMSettings (UBX_RTCM_1124, COM_PORT_USB) != 0 )
103- response &= myGPS.enableRTCMmessage (UBX_RTCM_1124, COM_PORT_USB, 0 );
104- if (getRTCMSettings (UBX_RTCM_1230, COM_PORT_USB) != 0 )
105- response &= myGPS.enableRTCMmessage (UBX_RTCM_1230, COM_PORT_USB, 0 );
82+ response &= disableRTCMSentences (COM_PORT_I2C);
83+ response &= disableRTCMSentences (COM_PORT_UART2);
84+ response &= disableRTCMSentences (COM_PORT_UART1);
85+ response &= disableRTCMSentences (COM_PORT_USB);
86+ if (response == false )
87+ Serial.println (F (" Disable RTCM failed" ));
10688
10789 response &= setNMEASettings (); // Enable high precision NMEA and extended sentences
10890
109- // Is SBAS causing weird NMEA failures once we are in RTK mode?
110- // response &= setSBAS(false); //Disable SBAS. Work around for RTK LED not working in v1.13 firmware.
111-
91+ if (settings.enableSBAS == true )
92+ response &= setSBAS (true ); // Enable SBAS
93+ else
94+ response &= setSBAS (false ); // Disable SBAS. Work around for RTK LED not working in v1.13 firmware.
95+
11296 return (response);
11397}
11498
@@ -145,6 +129,30 @@ bool setNMEASettings()
145129 return (true );
146130}
147131
132+ // Returns true if SBAS is enabled
133+ bool getSBAS ()
134+ {
135+ uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
136+ ubxPacket customCfg = {0 , 0 , 0 , 0 , 0 , customPayload, 0 , 0 , SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
137+
138+ customCfg.cls = UBX_CLASS_CFG; // This is the message Class
139+ customCfg.id = UBX_CFG_GNSS; // This is the message ID
140+ customCfg.len = 0 ; // Setting the len (length) to zero lets us poll the current settings
141+ customCfg.startingSpot = 0 ; // Always set the startingSpot to zero (unless you really know what you are doing)
142+
143+ uint16_t maxWait = 250 ; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
144+
145+ // Read the current setting. The results will be loaded into customCfg.
146+ if (myGPS.sendCommand (&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
147+ {
148+ Serial.println (F (" Get SBAS failed!" ));
149+ return (false );
150+ }
151+
152+ if (customPayload[8 + 8 * 1 ] & (1 << 0 )) return true ; // Check if bit 0 is set
153+ return false ;
154+ }
155+
148156// The u-blox library doesn't directly support SBAS control so let's do it manually
149157bool setSBAS (bool enableSBAS)
150158{
@@ -167,15 +175,13 @@ bool setSBAS(bool enableSBAS)
167175
168176 if (enableSBAS)
169177 {
170- if ( customPayload[8 + 1 * 8 ] & (1 << 0 )) return true ; // If we want the bit set, and it already is, simply return
171-
172- customPayload[8 + 1 * 8 ] |= (1 << 0 ); // Set the enable bit
178+ customPayload[8 + 8 * 1 ] |= (1 << 0 ); // Set the enable bit
179+ // We must enable the gnssID as well
180+ customPayload[8 + 8 * 1 + 2 ] |= (1 << 0 ); // Set the enable bit (16) for SBAS L1C/A
173181 }
174182 else
175183 {
176- if (customPayload[8 + 1 * 8 ] & (1 << 0 ) == 0 ) return true ; // If we want the bit cleared, and it already is, simply return
177-
178- customPayload[8 + 1 * 8 ] &= ~(1 << 0 ); // Clear the enable bit
184+ customPayload[8 + 8 * 1 ] &= ~(1 << 0 ); // Clear the enable bit
179185 }
180186
181187 // Now we write the custom packet back again to change the setting
0 commit comments