Update ZED-F9P callback examples

This commit is contained in:
PaulZC
2022-02-06 17:36:40 +00:00
parent 7395c25af5
commit 9a486f9cd7
2 changed files with 28 additions and 28 deletions
@@ -41,27 +41,27 @@ SFE_UBLOX_GNSS myGNSS;
// | / _____ You can use any name you like for the struct // | / _____ You can use any name you like for the struct
// | | / // | | /
// | | | // | | |
void printHPdata(UBX_NAV_HPPOSLLH_data_t ubxDataStruct) void printHPdata(UBX_NAV_HPPOSLLH_data_t *ubxDataStruct)
{ {
Serial.println(); Serial.println();
long highResLatitude = ubxDataStruct.lat; long highResLatitude = ubxDataStruct->lat;
Serial.print(F("Hi Res Lat: ")); Serial.print(F("Hi Res Lat: "));
Serial.print(highResLatitude); Serial.print(highResLatitude);
int highResLatitudeHp = ubxDataStruct.latHp; int highResLatitudeHp = ubxDataStruct->latHp;
Serial.print(F(" ")); Serial.print(F(" "));
Serial.print(highResLatitudeHp); Serial.print(highResLatitudeHp);
long highResLongitude = ubxDataStruct.lon; long highResLongitude = ubxDataStruct->lon;
Serial.print(F(" Hi Res Long: ")); Serial.print(F(" Hi Res Long: "));
Serial.print(highResLongitude); Serial.print(highResLongitude);
int highResLongitudeHp = ubxDataStruct.lonHp; int highResLongitudeHp = ubxDataStruct->lonHp;
Serial.print(F(" ")); Serial.print(F(" "));
Serial.print(highResLongitudeHp); Serial.print(highResLongitudeHp);
float horizAccuracy = ((float)ubxDataStruct.hAcc) / 10000.0; // Convert hAcc from mm*0.1 to m float horizAccuracy = ((float)ubxDataStruct->hAcc) / 10000.0; // Convert hAcc from mm*0.1 to m
Serial.print(F(" Horiz accuracy: ")); Serial.print(F(" Horiz accuracy: "));
Serial.println(horizAccuracy); Serial.println(horizAccuracy);
} }
@@ -73,38 +73,38 @@ void printHPdata(UBX_NAV_HPPOSLLH_data_t ubxDataStruct)
// | / _____ You can use any name you like for the struct // | / _____ You can use any name you like for the struct
// | | / // | | /
// | | | // | | |
void printPVTdata(UBX_NAV_PVT_data_t ubxDataStruct) void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct)
{ {
Serial.println(); Serial.println();
Serial.print(F("Time: ")); // Print the time Serial.print(F("Time: ")); // Print the time
uint8_t hms = ubxDataStruct.hour; // Print the hours uint8_t hms = ubxDataStruct->hour; // Print the hours
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
Serial.print(hms); Serial.print(hms);
Serial.print(F(":")); Serial.print(F(":"));
hms = ubxDataStruct.min; // Print the minutes hms = ubxDataStruct->min; // Print the minutes
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
Serial.print(hms); Serial.print(hms);
Serial.print(F(":")); Serial.print(F(":"));
hms = ubxDataStruct.sec; // Print the seconds hms = ubxDataStruct->sec; // Print the seconds
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
Serial.print(hms); Serial.print(hms);
Serial.print(F(".")); Serial.print(F("."));
unsigned long millisecs = ubxDataStruct.iTOW % 1000; // Print the milliseconds unsigned long millisecs = ubxDataStruct->iTOW % 1000; // Print the milliseconds
if (millisecs < 100) Serial.print(F("0")); // Print the trailing zeros correctly if (millisecs < 100) Serial.print(F("0")); // Print the trailing zeros correctly
if (millisecs < 10) Serial.print(F("0")); if (millisecs < 10) Serial.print(F("0"));
Serial.print(millisecs); Serial.print(millisecs);
long latitude = ubxDataStruct.lat; // Print the latitude long latitude = ubxDataStruct->lat; // Print the latitude
Serial.print(F(" Lat: ")); Serial.print(F(" Lat: "));
Serial.print(latitude); Serial.print(latitude);
long longitude = ubxDataStruct.lon; // Print the longitude long longitude = ubxDataStruct->lon; // Print the longitude
Serial.print(F(" Long: ")); Serial.print(F(" Long: "));
Serial.print(longitude); Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)")); Serial.print(F(" (degrees * 10^-7)"));
long altitude = ubxDataStruct.hMSL; // Print the height above mean sea level long altitude = ubxDataStruct->hMSL; // Print the height above mean sea level
Serial.print(F(" Height above MSL: ")); Serial.print(F(" Height above MSL: "));
Serial.print(altitude); Serial.print(altitude);
Serial.println(F(" (mm)")); Serial.println(F(" (mm)"));
@@ -135,9 +135,9 @@ void setup()
myGNSS.setNavigationFrequency(2); //Produce two solutions per second myGNSS.setNavigationFrequency(2); //Produce two solutions per second
myGNSS.setAutoPVTcallback(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata
myGNSS.setAutoHPPOSLLHcallback(&printHPdata); // Enable automatic NAV HPPOSLLH messages with callback to printHPdata myGNSS.setAutoHPPOSLLHcallbackPtr(&printHPdata); // Enable automatic NAV HPPOSLLH messages with callback to printHPdata
} }
void loop() void loop()
@@ -69,16 +69,16 @@ WiFiClient ntripClient; // The WiFi connection to the NTRIP server. This is glob
// | / _____ You can use any name you like for the struct // | / _____ You can use any name you like for the struct
// | | / // | | /
// | | | // | | |
void pushGPGGA(NMEA_GGA_data_t nmeaData) void pushGPGGA(NMEA_GGA_data_t *nmeaData)
{ {
//Provide the caster with our current position as needed //Provide the caster with our current position as needed
if ((ntripClient.connected() == true) && (transmitLocation == true)) if ((ntripClient.connected() == true) && (transmitLocation == true))
{ {
Serial.print(F("Pushing GGA to server: ")); Serial.print(F("Pushing GGA to server: "));
Serial.print((const char *)nmeaData.nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end
//Push our current GGA sentence to caster //Push our current GGA sentence to caster
ntripClient.print((const char *)nmeaData.nmea); ntripClient.print((const char *)nmeaData->nmea);
} }
} }
@@ -91,26 +91,26 @@ void pushGPGGA(NMEA_GGA_data_t nmeaData)
// | / _____ You can use any name you like for the struct // | / _____ You can use any name you like for the struct
// | | / // | | /
// | | | // | | |
void printPVTdata(UBX_NAV_PVT_data_t ubxDataStruct) void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct)
{ {
long latitude = ubxDataStruct.lat; // Print the latitude long latitude = ubxDataStruct->lat; // Print the latitude
Serial.print(F("Lat: ")); Serial.print(F("Lat: "));
Serial.print(latitude / 10000000L); Serial.print(latitude / 10000000L);
Serial.print(F(".")); Serial.print(F("."));
Serial.print(abs(latitude % 10000000L)); Serial.print(abs(latitude % 10000000L));
long longitude = ubxDataStruct.lon; // Print the longitude long longitude = ubxDataStruct->lon; // Print the longitude
Serial.print(F(" Long: ")); Serial.print(F(" Long: "));
Serial.print(longitude / 10000000L); Serial.print(longitude / 10000000L);
Serial.print(F(".")); Serial.print(F("."));
Serial.print(abs(longitude % 10000000L)); Serial.print(abs(longitude % 10000000L));
long altitude = ubxDataStruct.hMSL; // Print the height above mean sea level long altitude = ubxDataStruct->hMSL; // Print the height above mean sea level
Serial.print(F(" Height: ")); Serial.print(F(" Height: "));
Serial.print(altitude); Serial.print(altitude);
Serial.print(F(" (mm)")); Serial.print(F(" (mm)"));
uint8_t fixType = ubxDataStruct.fixType; // Print the fix type uint8_t fixType = ubxDataStruct->fixType; // Print the fix type
Serial.print(F(" Fix: ")); Serial.print(F(" Fix: "));
Serial.print(fixType); Serial.print(fixType);
if (fixType == 0) if (fixType == 0)
@@ -128,7 +128,7 @@ void printPVTdata(UBX_NAV_PVT_data_t ubxDataStruct)
else else
Serial.print(F(" (UNKNOWN)")); Serial.print(F(" (UNKNOWN)"));
uint8_t carrSoln = ubxDataStruct.flags.bits.carrSoln; // Print the carrier solution uint8_t carrSoln = ubxDataStruct->flags.bits.carrSoln; // Print the carrier solution
Serial.print(F(" Carrier Solution: ")); Serial.print(F(" Carrier Solution: "));
Serial.print(carrSoln); Serial.print(carrSoln);
if (carrSoln == 0) if (carrSoln == 0)
@@ -140,7 +140,7 @@ void printPVTdata(UBX_NAV_PVT_data_t ubxDataStruct)
else else
Serial.print(F(" (UNKNOWN)")); Serial.print(F(" (UNKNOWN)"));
uint32_t hAcc = ubxDataStruct.hAcc; // Print the horizontal accuracy estimate uint32_t hAcc = ubxDataStruct->hAcc; // Print the horizontal accuracy estimate
Serial.print(F(" Horizontal Accuracy Estimate: ")); Serial.print(F(" Horizontal Accuracy Estimate: "));
Serial.print(hAcc); Serial.print(hAcc);
Serial.print(F(" (mm)")); Serial.print(F(" (mm)"));
@@ -175,11 +175,11 @@ void setup()
// Set the Main Talker ID to "GP". The NMEA GGA messages will be GPGGA instead of GNGGA // Set the Main Talker ID to "GP". The NMEA GGA messages will be GPGGA instead of GNGGA
myGNSS.setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP); myGNSS.setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP);
myGNSS.setNMEAGPGGAcallback(&pushGPGGA); // Set up the callback for GPGGA myGNSS.setNMEAGPGGAcallbackPtr(&pushGPGGA); // Set up the callback for GPGGA
myGNSS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C, 10); // Tell the module to output GGA every 10 seconds myGNSS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C, 10); // Tell the module to output GGA every 10 seconds
myGNSS.setAutoPVTcallback(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata so we can watch the carrier solution go to fixed myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata so we can watch the carrier solution go to fixed
//myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save the ioPort and message settings to NVM //myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save the ioPort and message settings to NVM