Skip to content

Add callbacks for RTCM 1005 and 1006 Input #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,62 @@ void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct)

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

// Callback: printRTCMdata1005 will be called when new RTCM 1005 data has been parsed from pushRawData
// See u-blox_structs.h for the full definition of RTCM_1005_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setRTCM1005InputcallbackPtr
// / _____ This _must_ be RTCM_1005_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void printRTCMdata1005(RTCM_1005_data_t *rtcmData1005)
{
double x = rtcmData1005->AntennaReferencePointECEFX;
x /= 10000.0; // Convert to m
double y = rtcmData1005->AntennaReferencePointECEFY;
y /= 10000.0; // Convert to m
double z = rtcmData1005->AntennaReferencePointECEFZ;
z /= 10000.0; // Convert to m

Serial.print(F("NTRIP Server RTCM 1005: ARP ECEF-X: "));
Serial.print(x, 4); // 4 decimal places
Serial.print(F(" Y: "));
Serial.print(y, 4); // 4 decimal places
Serial.print(F(" Z: "));
Serial.println(z, 4); // 4 decimal places
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

// Callback: printRTCMdata1006 will be called when new RTCM 1006 data has been parsed from pushRawData
// See u-blox_structs.h for the full definition of RTCM_1006_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setRTCM1006InputcallbackPtr
// / _____ This _must_ be RTCM_1006_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void printRTCMdata1006(RTCM_1006_data_t *rtcmData1006)
{
double x = rtcmData1006->AntennaReferencePointECEFX;
x /= 10000.0; // Convert to m
double y = rtcmData1006->AntennaReferencePointECEFY;
y /= 10000.0; // Convert to m
double z = rtcmData1006->AntennaReferencePointECEFZ;
z /= 10000.0; // Convert to m
double h = rtcmData1006->AntennaHeight;
h /= 10000.0; // Convert to m

Serial.print(F("NTRIP Server RTCM 1006: ARP ECEF-X: "));
Serial.print(x, 4); // 4 decimal places
Serial.print(F(" Y: "));
Serial.print(y, 4); // 4 decimal places
Serial.print(F(" Z: "));
Serial.print(z, 4); // 4 decimal places
Serial.print(F(" Height: "));
Serial.println(h, 4); // 4 decimal places
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

void setup()
{
delay(1000);
Expand Down Expand Up @@ -176,6 +232,9 @@ void setup()

myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata so we can watch the carrier solution go to fixed

myGNSS.setRTCM1005InputcallbackPtr(&printRTCMdata1005); // Set up a callback to print the RTCM 1005 Antenna Reference Position from the correction data
myGNSS.setRTCM1006InputcallbackPtr(&printRTCMdata1006); // Set up a callback to print the RTCM 1006 Antenna Reference Position from the correction data

//myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save the ioPort and message settings to NVM

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand Down Expand Up @@ -230,54 +289,6 @@ void loop()

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

// Check if the library has been able to extract the Antenna Reference Position from an RTCM 1005 message

RTCM_1005_data_t rtcmData1005;

if (myGNSS.getLatestRTCM1005Input(&rtcmData1005) == 2) // RTCM 1005 data received? 0 = no data, 1 = stale data, 2 = fresh data
{
double x = rtcmData1005.AntennaReferencePointECEFX;
x /= 10000.0; // Convert to m
double y = rtcmData1005.AntennaReferencePointECEFY;
y /= 10000.0; // Convert to m
double z = rtcmData1005.AntennaReferencePointECEFZ;
z /= 10000.0; // Convert to m

Serial.print(F("NTRIP Server RTCM 1005: ARP ECEF-X: "));
Serial.print(x, 4); // 4 decimal places
Serial.print(F(" Y: "));
Serial.print(y, 4); // 4 decimal places
Serial.print(F(" Z: "));
Serial.println(z, 4); // 4 decimal places
}

// Check if the library has been able to extract the Antenna Reference Position from an RTCM 1006 message

RTCM_1006_data_t rtcmData1006;

if (myGNSS.getLatestRTCM1006Input(&rtcmData1006) == 2) // RTCM 1006 data received? 0 = no data, 1 = stale data, 2 = fresh data
{
double x = rtcmData1006.AntennaReferencePointECEFX;
x /= 10000.0; // Convert to m
double y = rtcmData1006.AntennaReferencePointECEFY;
y /= 10000.0; // Convert to m
double z = rtcmData1006.AntennaReferencePointECEFZ;
z /= 10000.0; // Convert to m
double h = rtcmData1006.AntennaHeight;
h /= 10000.0; // Convert to m

Serial.print(F("NTRIP Server RTCM 1006: ARP ECEF-X: "));
Serial.print(x, 4); // 4 decimal places
Serial.print(F(" Y: "));
Serial.print(y, 4); // 4 decimal places
Serial.print(F(" Z: "));
Serial.print(z, 4); // 4 decimal places
Serial.print(F(" Height: "));
Serial.println(h, 4); // 4 decimal places
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

switch (state)
{
case open_connection:
Expand Down
2 changes: 2 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,9 @@ crc24q KEYWORD2
getLatestRTCM1005 KEYWORD2
setRTCM1005callbackPtr KEYWORD2
getLatestRTCM1005Input KEYWORD2
setRTCM1005InputcallbackPtr KEYWORD2
getLatestRTCM1006Input KEYWORD2
setRTCM1006InputcallbackPtr KEYWORD2
extractRTCM1005 KEYWORD2
extractRTCM1006 KEYWORD2

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS v3
version=3.0.11
version=3.0.12
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
Expand Down
Loading