2
2
sendCustomCommand
3
3
By: Paul Clark (PaulZC)
4
4
Date: April 18th, 2020
5
-
5
+
6
6
License: MIT. See license file for more information but you can
7
7
basically do whatever you want with this code.
8
8
@@ -61,7 +61,7 @@ void setup()
61
61
62
62
// Let's configure the module's dynamic platform model as if we were using setDynamicModel
63
63
// Possible values are:
64
- // 0 (PORTABLE), 2 (STATIONARY), 3 (PEDESTRIAN), 4 (AUTOMOTIVE), 5 (SEA),
64
+ // 0 (PORTABLE), 2 (STATIONARY), 3 (PEDESTRIAN), 4 (AUTOMOTIVE), 5 (SEA),
65
65
// 6 (AIRBORNE1g), 7 (AIRBORNE2g), 8 (AIRBORNE4g), 9 (WRIST), 10 (BIKE)
66
66
67
67
// Let's create our custom packet
@@ -85,6 +85,7 @@ void setup()
85
85
// SFE_UBLOX_STATUS_DATA_RECEIVED if the data we requested was read / polled successfully
86
86
// SFE_UBLOX_STATUS_DATA_SENT if the data we sent was writted successfully (ACK'd)
87
87
// Other values indicate errors. Please see the sfe_ublox_status_e enum for further details.
88
+ // If you see a failure you can of course simply try sending the same command again.
88
89
89
90
// Referring to the u-blox M8 Receiver Description and Protocol Specification we see that
90
91
// the dynamic model is configured using the UBX-CFG-NAV5 message. So let's load our
@@ -101,9 +102,18 @@ void setup()
101
102
// Now let's read the current navigation model settings. The results will be loaded into customCfg.
102
103
if (myGPS.sendCustomCommand (&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
103
104
{
104
- Serial.println (F (" sendCustomCommand (poll) failed! Freezing." ));
105
- while (1 )
106
- ;
105
+ Serial.println (F (" sendCustomCommand (poll) failed! Trying again..." ));
106
+ // We need to reset the packet before we try again as the values could have changed
107
+ customCfg.cls = UBX_CLASS_CFG;
108
+ customCfg.id = UBX_CFG_NAV5;
109
+ customCfg.len = 0 ;
110
+ customCfg.startingSpot = 0 ;
111
+ if (myGPS.sendCustomCommand (&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
112
+ {
113
+ Serial.println (F (" sendCustomCommand (poll) failed again! Freezing." ));
114
+ while (1 )
115
+ ;
116
+ }
107
117
}
108
118
109
119
// Referring to the message definition for UBX-CFG-NAV5 we see that we need to change
@@ -133,7 +143,7 @@ void setup()
133
143
{
134
144
Serial.println (F (" sendCustomCommand (set) failed! Freezing." ));
135
145
while (1 )
136
- ;
146
+ ;
137
147
}
138
148
else
139
149
{
0 commit comments