@@ -4,7 +4,7 @@ bool updateRoverStatus()
4
4
// Update the horizontal accuracy LEDs only every second or so
5
5
if (millis () - lastRoverUpdate > 2000 )
6
6
{
7
- lastRoverUpdate += 2000 ;
7
+ lastRoverUpdate = millis () ;
8
8
9
9
uint32_t accuracy = myGPS.getHorizontalAccuracy (250 );
10
10
@@ -14,33 +14,33 @@ bool updateRoverStatus()
14
14
float f_accuracy = accuracy;
15
15
f_accuracy = f_accuracy / 10000.0 ; // Convert from mm * 10^-1 to m
16
16
17
- Serial.print (" Rover Accuracy (m): " );
17
+ Serial.print (F ( " Rover Accuracy (m): " ) );
18
18
Serial.print (f_accuracy, 4 ); // Print the accuracy with 4 decimal places
19
19
20
20
if (f_accuracy <= 0.02 )
21
21
{
22
- Serial.print (" 0.01m LED" );
22
+ Serial.print (F ( " 0.01m LED" ) );
23
23
digitalWrite (positionAccuracyLED_1cm, HIGH);
24
24
digitalWrite (positionAccuracyLED_10cm, HIGH);
25
25
digitalWrite (positionAccuracyLED_100cm, HIGH);
26
26
}
27
27
else if (f_accuracy <= 0.100 )
28
28
{
29
- Serial.print (" 0.1m LED" );
29
+ Serial.print (F ( " 0.1m LED" ) );
30
30
digitalWrite (positionAccuracyLED_1cm, LOW);
31
31
digitalWrite (positionAccuracyLED_10cm, HIGH);
32
32
digitalWrite (positionAccuracyLED_100cm, HIGH);
33
33
}
34
34
else if (f_accuracy <= 1.0000 )
35
35
{
36
- Serial.print (" 1m LED" );
36
+ Serial.print (F ( " 1m LED" ) );
37
37
digitalWrite (positionAccuracyLED_1cm, LOW);
38
38
digitalWrite (positionAccuracyLED_10cm, LOW);
39
39
digitalWrite (positionAccuracyLED_100cm, HIGH);
40
40
}
41
41
else if (f_accuracy > 1.0 )
42
42
{
43
- Serial.print (" No LEDs" );
43
+ Serial.print (F ( " No LEDs" ) );
44
44
digitalWrite (positionAccuracyLED_1cm, LOW);
45
45
digitalWrite (positionAccuracyLED_10cm, LOW);
46
46
digitalWrite (positionAccuracyLED_100cm, LOW);
@@ -49,10 +49,10 @@ bool updateRoverStatus()
49
49
}
50
50
else
51
51
{
52
- Serial.print (" Rover Accuracy: " );
52
+ Serial.print (F ( " Rover Accuracy: " ) );
53
53
Serial.print (accuracy);
54
54
Serial.print (" " );
55
- Serial.print (" No lock. SIV: " );
55
+ Serial.print (F ( " No lock. SIV: " ) );
56
56
Serial.print (myGPS.getSIV ());
57
57
Serial.println ();
58
58
}
@@ -64,51 +64,35 @@ bool configureUbloxModuleRover()
64
64
{
65
65
bool response = myGPS.disableSurveyMode (); // Disable survey
66
66
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
+
67
81
// 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" ));
106
88
107
89
response &= setNMEASettings (); // Enable high precision NMEA and extended sentences
108
90
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
+
112
96
return (response);
113
97
}
114
98
@@ -145,6 +129,30 @@ bool setNMEASettings()
145
129
return (true );
146
130
}
147
131
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
+
148
156
// The u-blox library doesn't directly support SBAS control so let's do it manually
149
157
bool setSBAS (bool enableSBAS)
150
158
{
@@ -167,15 +175,13 @@ bool setSBAS(bool enableSBAS)
167
175
168
176
if (enableSBAS)
169
177
{
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
173
181
}
174
182
else
175
183
{
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
179
185
}
180
186
181
187
// Now we write the custom packet back again to change the setting
0 commit comments