Skip to content

Commit 1aa043c

Browse files
committed
Update Example19. Add setRXMPMPmessageCallbackPtr. Add const char versions of setDynamicSPARTNKey + setDynamicSPARTNKeys
1 parent 213d29c commit 1aa043c

File tree

7 files changed

+388
-285
lines changed

7 files changed

+388
-285
lines changed

examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback/Example17_NTRIPClient_With_GGA_Callback.ino

+7-13
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,17 @@ void pushGPGGA(NMEA_GGA_data_t *nmeaData)
9393
// | | |
9494
void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct)
9595
{
96-
long latitude = ubxDataStruct->lat; // Print the latitude
96+
double latitude = ubxDataStruct->lat; // Print the latitude
9797
Serial.print(F("Lat: "));
98-
Serial.print(latitude / 10000000L);
99-
Serial.print(F("."));
100-
Serial.print(abs(latitude % 10000000L));
98+
Serial.print(latitude / 10000000.0, 7);
10199

102-
long longitude = ubxDataStruct->lon; // Print the longitude
100+
double longitude = ubxDataStruct->lon; // Print the longitude
103101
Serial.print(F(" Long: "));
104-
Serial.print(longitude / 10000000L);
105-
Serial.print(F("."));
106-
Serial.print(abs(longitude % 10000000L));
102+
Serial.print(longitude / 10000000.0, 7);
107103

108-
long altitude = ubxDataStruct->hMSL; // Print the height above mean sea level
104+
double altitude = ubxDataStruct->hMSL; // Print the height above mean sea level
109105
Serial.print(F(" Height: "));
110-
Serial.print(altitude);
111-
Serial.print(F(" (mm)"));
106+
Serial.print(altitude / 1000.0, 3);
112107

113108
uint8_t fixType = ubxDataStruct->fixType; // Print the fix type
114109
Serial.print(F(" Fix: "));
@@ -159,9 +154,8 @@ void setup()
159154

160155
while (myGNSS.begin() == false) //Connect to the Ublox module using Wire port
161156
{
162-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
157+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring."));
163158
delay(2000);
164-
//while (1);
165159
}
166160
Serial.println(F("u-blox module connected"));
167161

examples/ZED-F9P/Example19_LBand_Corrections_with_NEO-D9S/Example19_LBand_Corrections_with_NEO-D9S.ino

+21-27
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,24 @@ const uint32_t myLBandFreq = 1556290000; // Uncomment this line to use the US SP
3838
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3939

4040
// Callback: pushRXMPMP will be called when new PMP data arrives
41-
// See u-blox_structs.h for the full definition of UBX_RXM_PMP_data_t
42-
// _____ You can use any name you like for the callback. Use the same name when you call setAutoRXMPMPcallbackPtr
43-
// / _____ This _must_ be UBX_RXM_PMP_data_t
41+
// See u-blox_structs.h for the full definition of UBX_RXM_PMP_message_data_t
42+
// _____ You can use any name you like for the callback. Use the same name when you call setRXMPMPmessageCallbackPtr
43+
// / _____ This _must_ be UBX_RXM_PMP_message_data_t
4444
// | / _____ You can use any name you like for the struct
4545
// | | /
4646
// | | |
47-
void pushRXMPMP(UBX_RXM_PMP_data_t *pmpData)
47+
void pushRXMPMP(UBX_RXM_PMP_message_data_t *pmpData)
4848
{
49+
//Extract the raw message payload length
50+
uint16_t payloadLen = ((uint16_t)pmpData->lengthMSB << 8) | (uint16_t)pmpData->lengthLSB;
51+
Serial.print(F("New RXM-PMP data received. Message payload length is "));
52+
Serial.print(payloadLen);
53+
Serial.println(F(" Bytes. Pushing it to the GNSS..."));
54+
4955
//Push the PMP data to the GNSS
50-
Serial.print(F("New RXM-PMP data received. Message version is 0x0"));
51-
Serial.print(pmpData->version, HEX);
52-
Serial.print(F(". numBytesUserData is "));
53-
size_t numDataBytes = 504; // Version 0x00 messages always contain 504 bytes of userData
54-
if (pmpData->version == 0x01)
55-
numDataBytes = pmpData->numBytesUserData;
56-
Serial.print(numDataBytes);
57-
Serial.println(F(". Pushing them to the GNSS..."));
58-
59-
myGNSS.pushRawData(pmpData->userData, numDataBytes);
56+
//The payload length could be variable, so we need to push the header and payload, then checksum
57+
myGNSS.pushRawData(&pmpData->sync1, (size_t)payloadLen + 6); // Push the sync chars, class, ID, length and payload
58+
myGNSS.pushRawData(&pmpData->checksumA, (size_t)2); // Push the checksum bytes
6059
}
6160

6261
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -70,22 +69,17 @@ void pushRXMPMP(UBX_RXM_PMP_data_t *pmpData)
7069
// | | |
7170
void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct)
7271
{
73-
long latitude = ubxDataStruct->lat; // Print the latitude
72+
double latitude = ubxDataStruct->lat; // Print the latitude
7473
Serial.print(F("Lat: "));
75-
Serial.print(latitude / 10000000L);
76-
Serial.print(F("."));
77-
Serial.print(abs(latitude % 10000000L));
74+
Serial.print(latitude / 10000000.0, 7);
7875

79-
long longitude = ubxDataStruct->lon; // Print the longitude
76+
double longitude = ubxDataStruct->lon; // Print the longitude
8077
Serial.print(F(" Long: "));
81-
Serial.print(longitude / 10000000L);
82-
Serial.print(F("."));
83-
Serial.print(abs(longitude % 10000000L));
78+
Serial.print(longitude / 10000000.0, 7);
8479

85-
long altitude = ubxDataStruct->hMSL; // Print the height above mean sea level
80+
double altitude = ubxDataStruct->hMSL; // Print the height above mean sea level
8681
Serial.print(F(" Height: "));
87-
Serial.print(altitude);
88-
Serial.print(F(" (mm)"));
82+
Serial.print(altitude / 1000.0, 3);
8983

9084
uint8_t fixType = ubxDataStruct->fixType; // Print the fix type
9185
Serial.print(F(" Fix: "));
@@ -157,7 +151,7 @@ void setup()
157151
//"When the receiver boots, the host should send 'current' and 'next' keys in one message." - Use setDynamicSPARTNKeys for this.
158152
//"Every time the 'current' key is expired, 'next' takes its place."
159153
//"Therefore the host should then retrieve the new 'next' key and send only that." - Use setDynamicSPARTNKey for this.
160-
// The key can be provided in binary format or in ASCII Hex format, but in both cases keyLengthBytes _must_ represent the binary key length in bytes.
154+
// The key can be provided in binary (uint8_t) format or in ASCII Hex (char) format, but in both cases keyLengthBytes _must_ represent the binary key length in bytes.
161155
if (ok) ok = myGNSS.setDynamicSPARTNKeys(currentKeyLengthBytes, currentKeyGPSWeek, currentKeyGPSToW, currentDynamicKey,
162156
nextKeyLengthBytes, nextKeyGPSWeek, nextKeyGPSToW, nextDynamicKey);
163157

@@ -200,7 +194,7 @@ void setup()
200194

201195
myLBand.softwareResetGNSSOnly(); // Do a restart
202196

203-
myLBand.setAutoRXMPMPcallbackPtr(&pushRXMPMP); // Call pushRXMPMP when new PMP data arrives. Push it to the GNSS
197+
myLBand.setRXMPMPmessageCallbackPtr(&pushRXMPMP); // Call pushRXMPMP when new PMP data arrives. Push it to the GNSS
204198

205199
}
206200

examples/ZED-F9P/Example19_LBand_Corrections_with_NEO-D9S/secrets.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
// The keys are given as: 32 hexadecimal digits = 128 bits = 16 Bytes
1515

1616
const uint8_t currentKeyLengthBytes = 16;
17-
const uint8_t currentDynamicKey[] = "f742bd6b7248043177dd649141d8fb0b";
17+
const char currentDynamicKey[] = "f742bd6b7248043177dd649141d8fb0b";
1818
const uint16_t currentKeyGPSWeek = 2192;
1919
const uint32_t currentKeyGPSToW = 518418;
2020

2121
const uint8_t nextKeyLengthBytes = 16;
22-
const uint8_t nextDynamicKey[] = "8206........................29f4";
22+
const char nextDynamicKey[] = "8206........................29f4";
2323
const uint16_t nextKeyGPSWeek = 2196;
2424
const uint32_t nextKeyGPSToW = 518418;

keywords.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ UBX_NAV_VELECEF_data_t KEYWORD1
2626
UBX_NAV_VELNED_data_t KEYWORD1
2727
UBX_NAV_HPPOSECEF_data_t KEYWORD1
2828
UBX_NAV_HPPOSLLH_data_t KEYWORD1
29+
UBX_NAV_PVAT_data_t KEYWORD1
2930
UBX_NAV_CLOCK_data_t KEYWORD1
31+
UBX_NAV_SAT_data_t KEYWORD1
3032
UBX_NAV_RELPOSNED_data_t KEYWORD1
3133
UBX_NAV_TIMELS_data_t KEYWORD1
34+
UBX_NAV_AOPSTATUS_data_t KEYWORD1
3235

36+
UBX_RXM_PMP_data_t KEYWORD1
37+
UBX_RXM_PMP_message_data_t KEYWORD1
3338
UBX_RXM_SFRBX_data_t KEYWORD1
3439
UBX_RXM_RAWX_data_t KEYWORD1
3540

@@ -45,6 +50,8 @@ UBX_HNR_PVT_data_t KEYWORD1
4550
UBX_HNR_ATT_data_t KEYWORD1
4651
UBX_HNR_INS_data_t KEYWORD1
4752

53+
NMEA_GGA_data_t KEYWORD1
54+
4855
#######################################
4956
# Methods and Functions (KEYWORD2)
5057
#######################################
@@ -364,7 +371,8 @@ initPacketUBXAOPSTATUS KEYWORD2
364371
flushAOPSTATUS KEYWORD2
365372
logAOPSTATUS KEYWORD2
366373

367-
setAutoRXMPMPcallbackPtr KEYWORD2
374+
setRXMPMPcallbackPtr KEYWORD2
375+
setRXMPMPmessageCallbackPtr KEYWORD2
368376

369377
getRXMSFRBX KEYWORD2
370378
setAutoRXMSFRBX KEYWORD2

0 commit comments

Comments
 (0)