Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 927b9cb

Browse files
committed
Added NOTACKNOWLEDGED
1 parent 12b48f9 commit 927b9cb

File tree

3 files changed

+161
-79
lines changed

3 files changed

+161
-79
lines changed

examples/Example20_SendCustomCommand/Example20_SendCustomCommand.ino

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sendCustomCommand
33
By: Paul Clark (PaulZC)
44
Date: April 18th, 2020
5-
5+
66
License: MIT. See license file for more information but you can
77
basically do whatever you want with this code.
88
@@ -61,7 +61,7 @@ void setup()
6161

6262
// Let's configure the module's dynamic platform model as if we were using setDynamicModel
6363
// 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),
6565
// 6 (AIRBORNE1g), 7 (AIRBORNE2g), 8 (AIRBORNE4g), 9 (WRIST), 10 (BIKE)
6666

6767
// Let's create our custom packet
@@ -85,6 +85,7 @@ void setup()
8585
// SFE_UBLOX_STATUS_DATA_RECEIVED if the data we requested was read / polled successfully
8686
// SFE_UBLOX_STATUS_DATA_SENT if the data we sent was writted successfully (ACK'd)
8787
// 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.
8889

8990
// Referring to the u-blox M8 Receiver Description and Protocol Specification we see that
9091
// the dynamic model is configured using the UBX-CFG-NAV5 message. So let's load our
@@ -101,9 +102,18 @@ void setup()
101102
// Now let's read the current navigation model settings. The results will be loaded into customCfg.
102103
if (myGPS.sendCustomCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
103104
{
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+
}
107117
}
108118

109119
// Referring to the message definition for UBX-CFG-NAV5 we see that we need to change
@@ -133,7 +143,7 @@ void setup()
133143
{
134144
Serial.println(F("sendCustomCommand (set) failed! Freezing."));
135145
while (1)
136-
;
146+
;
137147
}
138148
else
139149
{

0 commit comments

Comments
 (0)