diff --git a/examples/Automatic_NMEA/Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA/Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA.ino b/examples/Automatic_NMEA/Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA/Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA.ino new file mode 100644 index 0000000..9f6991d --- /dev/null +++ b/examples/Automatic_NMEA/Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA/Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA.ino @@ -0,0 +1,181 @@ +/* + Get the NMEA sentence using getLatestNMEAGPxxx (GGA, VTG, RMC, ZDA) + By: Paul Clark + SparkFun Electronics + Date: March 2nd, 2021 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + This example shows how to turn on/off the NMEA sentences being output over I2C. + It then demonstrates how to use the new getLatestNMEAGPxxx function to retrieve the latest GPGGA message. + getLatestNMEAGPxxx returns immediately - it is not blocking. + It returns: + 0 if no data is available + 1 if the data is valid but is stale (you have read it before) + 2 if the data is valid and fresh + + If the module is using multiple GNSS constellations, the GGA message will be prefixed with Talker ID "GN" instead of "GP". + The library includes getLatestNMEAGNxxx functions too. + This example shows how to use both functions - and how to change the Talker ID so the GNGGA messages become GPGGA etc.. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 + NEO-M8P RTK: https://www.sparkfun.com/products/15005 + SAM-M8Q: https://www.sparkfun.com/products/15106 + + Hardware Connections: + Plug a Qwiic cable into the GNSS and a RedBoard + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include //Needed for I2C to GNSS + +#include //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS +SFE_UBLOX_GNSS myGNSS; + +void setup() +{ + + Serial.begin(115200); + Serial.println(F("SparkFun u-blox GNSS Example")); + + Wire.begin(); + + //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial + + if (myGNSS.begin() == false) + { + Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); + while (1) + ; + } + + //Disable or enable various NMEA sentences over the I2C interface + myGNSS.setI2COutput(COM_TYPE_NMEA | COM_TYPE_UBX); // Turn on both UBX and NMEA sentences on I2C. (Turn off RTCM and SPARTN) + myGNSS.disableNMEAMessage(UBX_NMEA_GLL, COM_PORT_I2C); + myGNSS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_I2C); + myGNSS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_RMC, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_VTG, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_ZDA, COM_PORT_I2C); + + // 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_DEFAULT); // Uncomment this line to restore the default main talker ID + + myGNSS.setHighPrecisionMode(true); // Enable High Precision Mode - include extra decimal places in the GGA messages + + //myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save only the ioPort and message settings to NVM + + Serial.println(F("Messages configured")); + + //myGNSS.setNMEAOutputPort(Serial); // Uncomment this line to echo all NMEA data to Serial for debugging +} + +void loop() +{ + // getLatestNMEAGPGGA calls checkUblox for us. We don't need to do it here + + NMEA_GGA_data_t dataGGA; // Storage for the GPGGA data + uint8_t result = myGNSS.getLatestNMEAGPGGA(&dataGGA); // Get the latest GPGGA data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GPGGA: Length: ")); + Serial.print(dataGGA.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataGGA.nmea); // .nmea is printable (NULL-terminated) + } + + result = myGNSS.getLatestNMEAGNGGA(&dataGGA); // Get the latest GNGGA data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GNGGA: Length: ")); + Serial.print(dataGGA.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataGGA.nmea); // .nmea is printable (NULL-terminated) + } + + // getLatestNMEAGPVTG calls checkUblox for us. We don't need to do it here + + NMEA_VTG_data_t dataVTG; // Storage for the GPVTG data + result = myGNSS.getLatestNMEAGPVTG(&dataVTG); // Get the latest GPVTG data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GPVTG: Length: ")); + Serial.print(dataVTG.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataVTG.nmea); // .nmea is printable (NULL-terminated) + } + + result = myGNSS.getLatestNMEAGNVTG(&dataVTG); // Get the latest GNVTG data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GNVTG: Length: ")); + Serial.print(dataVTG.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataVTG.nmea); // .nmea is printable (NULL-terminated) + } + + // getLatestNMEAGPRMC calls checkUblox for us. We don't need to do it here + + NMEA_RMC_data_t dataRMC; // Storage for the GPRMC data + result = myGNSS.getLatestNMEAGPRMC(&dataRMC); // Get the latest GPRMC data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GPRMC: Length: ")); + Serial.print(dataRMC.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataRMC.nmea); // .nmea is printable (NULL-terminated) + } + + result = myGNSS.getLatestNMEAGNRMC(&dataRMC); // Get the latest GNRMC data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GNRMC: Length: ")); + Serial.print(dataRMC.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataRMC.nmea); // .nmea is printable (NULL-terminated) + } + + // getLatestNMEAGPZDA calls checkUblox for us. We don't need to do it here + + NMEA_ZDA_data_t dataZDA; // Storage for the GPZDA data + result = myGNSS.getLatestNMEAGPZDA(&dataZDA); // Get the latest GPZDA data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GPZDA: Length: ")); + Serial.print(dataZDA.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataZDA.nmea); // .nmea is printable (NULL-terminated) + } + + result = myGNSS.getLatestNMEAGNZDA(&dataZDA); // Get the latest GNZDA data (if any) + + if (result == 2) + { + // Data contains .length and .nmea + Serial.print(F("Latest GNZDA: Length: ")); + Serial.print(dataZDA.length); + Serial.print(F("\tData: ")); + Serial.print((const char *)dataZDA.nmea); // .nmea is printable (NULL-terminated) + } + + delay(250); +} diff --git a/examples/Automatic_NMEA/Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks/Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks.ino b/examples/Automatic_NMEA/Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks/Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks.ino new file mode 100644 index 0000000..22daf09 --- /dev/null +++ b/examples/Automatic_NMEA/Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks/Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks.ino @@ -0,0 +1,224 @@ +/* + Get the latest GGA, VTG, RMC, ZDA NMEA sentence using callbacks + By: Paul Clark + SparkFun Electronics + Date: March 2nd, 2021 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + This example shows how to turn on/off the NMEA sentences being output over I2C. + It then demonstrates how to get the latest GGA, VTG, RMC or ZDA message autonomously using callbacks. + + If the module is using multiple GNSS constellations, the GGA message will be prefixed with Talker ID "GN" instead of "GP". + This example shows how to change the Talker ID so the GNGGA messages become GPGGA. + It also shows how to enable "high precision mode" to include extra decimal places in the GGA messages. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 + NEO-M8P RTK: https://www.sparkfun.com/products/15005 + SAM-M8Q: https://www.sparkfun.com/products/15106 + + Hardware Connections: + Plug a Qwiic cable into the GNSS and a RedBoard + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include //Needed for I2C to GNSS + +#include //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS +SFE_UBLOX_GNSS myGNSS; + +// Callback: printGPGGA will be called when new GPGGA NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_GGA_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGPGGAcallback +// / _____ This _must_ be NMEA_GGA_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGPGGA(NMEA_GGA_data_t *nmeaData) +{ + Serial.print(F("\r\nGPGGA: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +// Callback: printGNGGA will be called if new GNGGA NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_GGA_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGNGGAcallback +// / _____ This _must_ be NMEA_GGA_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGNGGA(NMEA_GGA_data_t *nmeaData) +{ + Serial.print(F("\r\nGNGGA: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +// Callback: printGPVTG will be called when new GPVTG NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_VTG_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGPVTGcallback +// / _____ This _must_ be NMEA_VTG_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGPVTG(NMEA_VTG_data_t *nmeaData) +{ + Serial.print(F("\r\nGPVTG: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +// Callback: printGNVTG will be called if new GNVTG NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_VTG_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGNVTGcallback +// / _____ This _must_ be NMEA_VTG_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGNVTG(NMEA_VTG_data_t *nmeaData) +{ + Serial.print(F("\r\nGNVTG: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +// Callback: printGPRMC will be called when new GPRMC NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_RMC_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGPRMCcallback +// / _____ This _must_ be NMEA_RMC_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGPRMC(NMEA_RMC_data_t *nmeaData) +{ + Serial.print(F("\r\nGPRMC: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +// Callback: printGNRMC will be called if new GNRMC NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_RMC_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGNRMCcallback +// / _____ This _must_ be NMEA_RMC_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGNRMC(NMEA_RMC_data_t *nmeaData) +{ + Serial.print(F("\r\nGNRMC: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +// Callback: printGPZDA will be called when new GPZDA NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_ZDA_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGPZDAcallback +// / _____ This _must_ be NMEA_ZDA_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGPZDA(NMEA_ZDA_data_t *nmeaData) +{ + Serial.print(F("\r\nGPZDA: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +// Callback: printGNZDA will be called if new GNZDA NMEA data arrives +// See u-blox_structs.h for the full definition of NMEA_ZDA_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setNMEAGNZDAcallback +// / _____ This _must_ be NMEA_ZDA_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void printGNZDA(NMEA_ZDA_data_t *nmeaData) +{ + Serial.print(F("\r\nGNZDA: Length: ")); + Serial.print(nmeaData->length); + Serial.print(F("\tData: ")); + Serial.print((const char *)nmeaData->nmea); // .nmea is printable (NULL-terminated) and already has \r\n on the end +} + +void setup() +{ + + Serial.begin(115200); + Serial.println(F("SparkFun u-blox GNSS Example")); + + Wire.begin(); + + //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial + + if (myGNSS.begin() == false) + { + Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); + while (1) + ; + } + + // Disable or enable various NMEA sentences over the I2C interface + myGNSS.setI2COutput(COM_TYPE_NMEA | COM_TYPE_UBX); // Turn on both UBX and NMEA sentences on I2C. (Turn off RTCM and SPARTN) + myGNSS.disableNMEAMessage(UBX_NMEA_GLL, COM_PORT_I2C); + myGNSS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_I2C); + myGNSS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_RMC, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_VTG, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C); + myGNSS.enableNMEAMessage(UBX_NMEA_ZDA, COM_PORT_I2C); + + // 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_DEFAULT); // Uncomment this line to restore the default main talker ID + + myGNSS.setHighPrecisionMode(true); // Enable High Precision Mode - include extra decimal places in the GGA messages + + //myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save only the ioPort and message settings to NVM + + Serial.println(F("Messages configured")); + + //myGNSS.setNMEAOutputPort(Serial); // Uncomment this line to echo all NMEA data to Serial for debugging + + // Set up the callback for GPGGA + myGNSS.setNMEAGPGGAcallbackPtr(&printGPGGA); + + // Set up the callback for GNGGA + myGNSS.setNMEAGNGGAcallbackPtr(&printGNGGA); + + // Set up the callback for GPVTG + myGNSS.setNMEAGPVTGcallbackPtr(&printGPVTG); + + // Set up the callback for GNVTG + myGNSS.setNMEAGNVTGcallbackPtr(&printGNVTG); + + // Set up the callback for GPRMC + myGNSS.setNMEAGPRMCcallbackPtr(&printGPRMC); + + // Set up the callback for GNRMC + myGNSS.setNMEAGNRMCcallbackPtr(&printGNRMC); + + // Set up the callback for GPZDA + myGNSS.setNMEAGPZDAcallbackPtr(&printGPZDA); + + // Set up the callback for GNZDA + myGNSS.setNMEAGNZDAcallbackPtr(&printGNZDA); +} + +void loop() +{ + myGNSS.checkUblox(); // Check for the arrival of new data and process it. + myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed. + + Serial.print("."); + delay(50); +} diff --git a/examples/Example29_JammingInformation/Example29_JammingInformation.ino b/examples/Example29_JammingInformation/Example29_JammingInformation.ino new file mode 100644 index 0000000..e4fd89e --- /dev/null +++ b/examples/Example29_JammingInformation/Example29_JammingInformation.ino @@ -0,0 +1,144 @@ +/* + Get the jamming state and indication + By: Paul Clark + SparkFun Electronics + Date: March 2nd, 2021 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + This example shows how to enable the jamming / interference monitor and read the + jamming state and information. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 + NEO-M8P RTK: https://www.sparkfun.com/products/15005 + SAM-M8Q: https://www.sparkfun.com/products/15106 + + Hardware Connections: + Plug a Qwiic cable into the GNSS and a RedBoard + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include //Needed for I2C to GNSS + +#include //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS +SFE_UBLOX_GNSS myGNSS; + +void setup() +{ + + Serial.begin(115200); + Serial.println(F("SparkFun u-blox GNSS Example")); + + Wire.begin(); + + //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial + + if (myGNSS.begin() == false) + { + Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); + while (1) + ; + } + + // Enable the jamming / interference monitor + UBX_CFG_ITFM_data_t jammingConfig; // Create storage for the jamming configuration + if (myGNSS.getJammingConfiguration(&jammingConfig)) // Read the jamming configuration + { + Serial.print(F("The jamming / interference monitor is ")); + if (jammingConfig.config.bits.enable == 0) // Check if the monitor is already enabled + Serial.print(F("not ")); + Serial.println(F("enabled")); + + if (jammingConfig.config.bits.enable == 0) // Check if the monitor is already enabled + { + Serial.print(F("Enabling the jamming / interference monitor: ")); + (jammingConfig.config.bits.enable = 1); // Enable the monitor + if (myGNSS.setJammingConfiguration(&jammingConfig)) // Set the jamming configuration + Serial.println(F("success")); + else + Serial.println(F("failed!")); + } + } + +} + +void loop() +{ + // Create storage to hold the hardware status + // See the definition of UBX_MON_HW_data_t in u-blox_structs.h for more details + UBX_MON_HW_data_t hwStatus; + + if (myGNSS.getHWstatus(&hwStatus)) // Read the hardware status + { + Serial.println(F("Hardware status (UBX_MON_RF):")); + + Serial.print(F("Jamming state: ")); + Serial.print(hwStatus.flags.bits.jammingState); + if (hwStatus.flags.bits.jammingState == 0) + Serial.println(F(" = unknown / disabled")); + else if (hwStatus.flags.bits.jammingState == 1) + Serial.println(F(" = ok")); + else if (hwStatus.flags.bits.jammingState == 2) + Serial.println(F(" = warning")); + else // if (hwStatus.flags.bits.jammingState == 3) + Serial.println(F(" = critical!")); + + Serial.print(F("Noise level: ")); + Serial.println(hwStatus.noisePerMS); + + Serial.print(F("AGC monitor: ")); + Serial.println(hwStatus.agcCnt); + + Serial.print(F("CW jamming indicator: ")); + Serial.println(hwStatus.jamInd); + + Serial.println(); + } + + // Create storage to hold the RF information from a ZED-F9 + // See the definition of UBX_MON_RF_data_t in u-blox_structs.h for more details + UBX_MON_RF_data_t rfInformation; + + // Read the RF information from the ZED-F9n. Allow 2 seconds for the data to be returned. Will time out on M8 modules + if (myGNSS.getRFinformation(&rfInformation, 2000)) + { + Serial.print(F("The UBX_MON_RF message contains ")); + Serial.print(rfInformation.header.nBlocks); // Print how many information blocks were returned. Should be 0, 1 or 2 + Serial.println(F(" information blocks")); + + for (uint8_t block = 0; block < rfInformation.header.nBlocks; block++) + { + Serial.print(F("Block ID: ")); + Serial.print(rfInformation.blocks[block].blockId); + if (rfInformation.blocks[block].blockId == 0) + Serial.println(F(" = L1")); + else // if (rfInformation.blocks[block].blockId == 1) + Serial.println(F(" = L2 / L5")); + + Serial.print(F("Jamming state: ")); + Serial.print(rfInformation.blocks[block].flags.bits.jammingState); + if (rfInformation.blocks[block].flags.bits.jammingState == 0) + Serial.println(F(" = unknown / disabled")); + else if (rfInformation.blocks[block].flags.bits.jammingState == 1) + Serial.println(F(" = ok")); + else if (rfInformation.blocks[block].flags.bits.jammingState == 2) + Serial.println(F(" = warning")); + else // if (rfInformation.blocks[block].flags.bits.jammingState == 3) + Serial.println(F(" = critical!")); + + Serial.print(F("Noise level: ")); + Serial.println(rfInformation.blocks[block].noisePerMS); + + Serial.print(F("AGC monitor: ")); + Serial.println(rfInformation.blocks[block].agcCnt); + + Serial.print(F("CW jamming indicator: ")); + Serial.println(rfInformation.blocks[block].jamInd); + } + + Serial.println(); + } +} diff --git a/keywords.txt b/keywords.txt index 1aecd8b..a281a07 100644 --- a/keywords.txt +++ b/keywords.txt @@ -16,6 +16,10 @@ UBX_ESF_MEAS_sensorData_t KEYWORD1 UBX_ESF_RAW_sensorData_t KEYWORD1 UBX_ESF_STATUS_sensorStatus_t KEYWORD1 +UBX_CFG_ITFM_data_t KEYWORD1 +UBX_MON_RF_data_t KEYWORD1 +UBX_MON_HW_data_t KEYWORD1 + UBX_NAV_POSECEF_data_t KEYWORD1 UBX_NAV_STATUS_data_t KEYWORD1 UBX_NAV_DOP_data_t KEYWORD1 @@ -51,6 +55,9 @@ UBX_HNR_ATT_data_t KEYWORD1 UBX_HNR_INS_data_t KEYWORD1 NMEA_GGA_data_t KEYWORD1 +NMEA_VTG_data_t KEYWORD1 +NMEA_RMC_data_t KEYWORD1 +NMEA_ZDA_data_t KEYWORD1 ####################################### # Methods and Functions (KEYWORD2) @@ -182,6 +189,13 @@ setESFAutoAlignment KEYWORD2 getTimePulseParameters KEYWORD2 setTimePulseParameters KEYWORD2 +getJammingConfiguration KEYWORD2 +setJammingConfiguration KEYWORD2 + +getRFinformation KEYWORD2 + +getHWstatus KEYWORD2 + getAckAiding KEYWORD2 setAckAiding KEYWORD2 @@ -618,6 +632,27 @@ getLatestNMEAGNGGA KEYWORD2 setNMEAGNGGAcallback KEYWORD2 setNMEAGNGGAcallbackPtr KEYWORD2 +getLatestNMEAGPVTG KEYWORD2 +setNMEAGPVTGcallback KEYWORD2 +setNMEAGPVTGcallbackPtr KEYWORD2 +getLatestNMEAGNVTG KEYWORD2 +setNMEAGNVTGcallback KEYWORD2 +setNMEAGNVTGcallbackPtr KEYWORD2 + +getLatestNMEAGPRMC KEYWORD2 +setNMEAGPRMCcallback KEYWORD2 +setNMEAGPRMCcallbackPtr KEYWORD2 +getLatestNMEAGNRMC KEYWORD2 +setNMEAGNRMCcallback KEYWORD2 +setNMEAGNRMCcallbackPtr KEYWORD2 + +getLatestNMEAGPZDA KEYWORD2 +setNMEAGPZDAcallback KEYWORD2 +setNMEAGPZDAcallbackPtr KEYWORD2 +getLatestNMEAGNZDA KEYWORD2 +setNMEAGNZDAcallback KEYWORD2 +setNMEAGNZDAcallbackPtr KEYWORD2 + extractLong KEYWORD2 extractSignedLong KEYWORD2 extractInt KEYWORD2 diff --git a/library.properties b/library.properties index 5135837..7337c6b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.2.2 +version=2.2.3 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules

diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 0509893..aa2c340 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -422,6 +422,7 @@ void SFE_UBLOX_GNSS::end(void) packetUBXHNRPVT = NULL; // Redundant? } +#ifndef SFE_UBLOX_REDUCED_PROG_MEM if (storageNMEAGPGGA != NULL) { if (storageNMEAGPGGA->callbackCopy != NULL) @@ -441,6 +442,67 @@ void SFE_UBLOX_GNSS::end(void) delete storageNMEAGNGGA; storageNMEAGNGGA = NULL; // Redundant? } + + if (storageNMEAGPVTG != NULL) + { + if (storageNMEAGPVTG->callbackCopy != NULL) + { + delete storageNMEAGPVTG->callbackCopy; + } + delete storageNMEAGPVTG; + storageNMEAGPVTG = NULL; // Redundant? + } + + if (storageNMEAGNVTG != NULL) + { + if (storageNMEAGNVTG->callbackCopy != NULL) + { + delete storageNMEAGNVTG->callbackCopy; + } + delete storageNMEAGNVTG; + storageNMEAGNVTG = NULL; // Redundant? + } + + if (storageNMEAGPRMC != NULL) + { + if (storageNMEAGPRMC->callbackCopy != NULL) + { + delete storageNMEAGPRMC->callbackCopy; + } + delete storageNMEAGPRMC; + storageNMEAGPRMC = NULL; // Redundant? + } + + if (storageNMEAGNRMC != NULL) + { + if (storageNMEAGNRMC->callbackCopy != NULL) + { + delete storageNMEAGNRMC->callbackCopy; + } + delete storageNMEAGNRMC; + storageNMEAGNRMC = NULL; // Redundant? + } + + if (storageNMEAGPZDA != NULL) + { + if (storageNMEAGPZDA->callbackCopy != NULL) + { + delete storageNMEAGPZDA->callbackCopy; + } + delete storageNMEAGPZDA; + storageNMEAGPZDA = NULL; // Redundant? + } + + if (storageNMEAGNZDA != NULL) + { + if (storageNMEAGNZDA->callbackCopy != NULL) + { + delete storageNMEAGNZDA->callbackCopy; + } + delete storageNMEAGNZDA; + storageNMEAGNZDA = NULL; // Redundant? + } +#endif } // Allow the user to change packetCfgPayloadSize. Handy if you want to process big messages like RAWX @@ -1801,6 +1863,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r _signsOfLife = isNMEAHeaderValid(); } +#ifndef SFE_UBLOX_REDUCED_PROG_MEM // Check if we have automatic storage for this message if (isThisNMEAauto()) { @@ -1812,6 +1875,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r memcpy(nmeaPtr, &nmeaAddressField[0], 6); // Copy the start character and address field into the working copy } else +#endif { // if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging // { @@ -1838,6 +1902,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r if ((nmeaByteCounter > 5) || (nmeaByteCounter < 0)) // Should we add incoming to the file buffer and/or pass it to processNMEA? { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM if (isThisNMEAauto()) { uint8_t *lengthPtr = getNMEAWorkingLengthPtr(); // Get a pointer to the working copy length @@ -1849,15 +1914,14 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r *lengthPtr = *lengthPtr + 1; // Increment the length if (*lengthPtr == nmeaMaxLength) { -#ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging { _debugSerial->println(F("process: NMEA buffer is full!")); } -#endif } } } +#endif if (logThisNMEA()) storeFileBytes(&incoming, 1); // Add incoming to the file buffer if (processThisNMEA()) @@ -1874,6 +1938,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r if (nmeaByteCounter == 0) // Check if we are done { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM if (isThisNMEAauto()) { uint8_t *workingLengthPtr = getNMEAWorkingLengthPtr(); // Get a pointer to the working copy length @@ -1928,7 +1993,6 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r } else { -#ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging { _debugSerial->print(F("process: NMEA checksum fail (2)! Expected ")); @@ -1939,19 +2003,17 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r _debugSerial->write(*(workingNMEAPtr + charsChecked + 1)); _debugSerial->println(); } -#endif } } else { -#ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging { _debugSerial->println(F("process: NMEA checksum fail (1)!")); } -#endif } } +#endif currentSentence = NONE; // All done! } } @@ -2132,6 +2194,7 @@ void SFE_UBLOX_GNSS::processNMEA(char incoming) _nmeaOutputPort->write(incoming); // Echo this byte to the serial port } +#ifndef SFE_UBLOX_REDUCED_PROG_MEM // Check if the NMEA message (in nmeaAddressField) is "auto" (i.e. has RAM allocated for it) bool SFE_UBLOX_GNSS::isThisNMEAauto() { @@ -2149,6 +2212,48 @@ bool SFE_UBLOX_GNSS::isThisNMEAauto() return true; } + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGPVTG != NULL) + return true; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGNVTG != NULL) + return true; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGPRMC != NULL) + return true; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGNRMC != NULL) + return true; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGPZDA != NULL) + return true; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGNZDA != NULL) + return true; + } + return false; } @@ -2173,6 +2278,60 @@ bool SFE_UBLOX_GNSS::doesThisNMEAHaveCallback() return true; } + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGPVTG != NULL) + if (storageNMEAGPVTG->callbackCopy != NULL) + if ((storageNMEAGPVTG->callbackPointer != NULL) || (storageNMEAGPVTG->callbackPointerPtr != NULL)) + return true; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGNVTG != NULL) + if (storageNMEAGNVTG->callbackCopy != NULL) + if ((storageNMEAGNVTG->callbackPointer != NULL) || (storageNMEAGNVTG->callbackPointerPtr != NULL)) + return true; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGPRMC != NULL) + if (storageNMEAGPRMC->callbackCopy != NULL) + if ((storageNMEAGPRMC->callbackPointer != NULL) || (storageNMEAGPRMC->callbackPointerPtr != NULL)) + return true; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGNRMC != NULL) + if (storageNMEAGNRMC->callbackCopy != NULL) + if ((storageNMEAGNRMC->callbackPointer != NULL) || (storageNMEAGNRMC->callbackPointerPtr != NULL)) + return true; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGPZDA != NULL) + if (storageNMEAGPZDA->callbackCopy != NULL) + if ((storageNMEAGPZDA->callbackPointer != NULL) || (storageNMEAGPZDA->callbackPointerPtr != NULL)) + return true; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + if (storageNMEAGNZDA != NULL) + if (storageNMEAGNZDA->callbackCopy != NULL) + if ((storageNMEAGNZDA->callbackPointer != NULL) || (storageNMEAGNZDA->callbackPointerPtr != NULL)) + return true; + } + return false; } @@ -2191,6 +2350,42 @@ uint8_t *SFE_UBLOX_GNSS::getNMEAWorkingLengthPtr() return &storageNMEAGNGGA->workingCopy.length; } + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPVTG->workingCopy.length; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNVTG->workingCopy.length; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPRMC->workingCopy.length; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNRMC->workingCopy.length; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPZDA->workingCopy.length; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNZDA->workingCopy.length; + } + return NULL; } @@ -2209,6 +2404,42 @@ uint8_t *SFE_UBLOX_GNSS::getNMEAWorkingNMEAPtr() return &storageNMEAGNGGA->workingCopy.nmea[0]; } + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPVTG->workingCopy.nmea[0]; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNVTG->workingCopy.nmea[0]; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPRMC->workingCopy.nmea[0]; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNRMC->workingCopy.nmea[0]; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPZDA->workingCopy.nmea[0]; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNZDA->workingCopy.nmea[0]; + } + return NULL; } @@ -2227,6 +2458,42 @@ uint8_t *SFE_UBLOX_GNSS::getNMEACompleteLengthPtr() return &storageNMEAGNGGA->completeCopy.length; } + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPVTG->completeCopy.length; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNVTG->completeCopy.length; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPRMC->completeCopy.length; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNRMC->completeCopy.length; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPZDA->completeCopy.length; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNZDA->completeCopy.length; + } + return NULL; } @@ -2245,6 +2512,42 @@ uint8_t *SFE_UBLOX_GNSS::getNMEACompleteNMEAPtr() return &storageNMEAGNGGA->completeCopy.nmea[0]; } + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPVTG->completeCopy.nmea[0]; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNVTG->completeCopy.nmea[0]; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPRMC->completeCopy.nmea[0]; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNRMC->completeCopy.nmea[0]; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPZDA->completeCopy.nmea[0]; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNZDA->completeCopy.nmea[0]; + } + return NULL; } @@ -2263,6 +2566,42 @@ uint8_t *SFE_UBLOX_GNSS::getNMEACallbackLengthPtr() return &storageNMEAGNGGA->callbackCopy->length; } + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPVTG->callbackCopy->length; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNVTG->callbackCopy->length; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPRMC->callbackCopy->length; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNRMC->callbackCopy->length; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPZDA->callbackCopy->length; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNZDA->callbackCopy->length; + } + return NULL; } @@ -2281,52 +2620,161 @@ uint8_t *SFE_UBLOX_GNSS::getNMEACallbackNMEAPtr() return &storageNMEAGNGGA->callbackCopy->nmea[0]; } - return NULL; -} + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPVTG->callbackCopy->nmea[0]; + } -// Get the maximum length of this NMEA message -uint8_t SFE_UBLOX_GNSS::getNMEAMaxLength() -{ - char thisNMEA[] = "GPGGA"; + strcpy(thisNMEA, "GNVTG"); if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) { - return NMEA_GGA_MAX_LENGTH; + return &storageNMEAGNVTG->callbackCopy->nmea[0]; } - strcpy(thisNMEA, "GNGGA"); + strcpy(thisNMEA, "GPRMC"); if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) { - return NMEA_GGA_MAX_LENGTH; + return &storageNMEAGPRMC->callbackCopy->nmea[0]; } - return 0; -} + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNRMC->callbackCopy->nmea[0]; + } -// Get a pointer to the automatic NMEA flags -nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr() -{ - char thisNMEA[] = "GPGGA"; + strcpy(thisNMEA, "GPZDA"); if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) { - return &storageNMEAGPGGA->automaticFlags; + return &storageNMEAGPZDA->callbackCopy->nmea[0]; } - strcpy(thisNMEA, "GNGGA"); + strcpy(thisNMEA, "GNZDA"); if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) { - return &storageNMEAGNGGA->automaticFlags; + return &storageNMEAGNZDA->callbackCopy->nmea[0]; } return NULL; } -// We need to be able to identify an RTCM packet and then the length -// so that we know when the RTCM message is completely received and we then start -// listening for other sentences (like NMEA or UBX) -// RTCM packet structure is very odd. I never found RTCM STANDARD 10403.2 but -// http://d1.amobbs.com/bbs_upload782111/files_39/ourdev_635123CK0HJT.pdf is good -// https://dspace.cvut.cz/bitstream/handle/10467/65205/F3-BP-2016-Shkalikava-Anastasiya-Prenos%20polohove%20informace%20prostrednictvim%20datove%20site.pdf?sequence=-1 -// Lead me to: https://forum.u-blox.com/index.php/4348/how-to-read-rtcm-messages-from-neo-m8p +// Get the maximum length of this NMEA message +uint8_t SFE_UBLOX_GNSS::getNMEAMaxLength() +{ + char thisNMEA[] = "GPGGA"; + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_GGA_MAX_LENGTH; + } + + strcpy(thisNMEA, "GNGGA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_GGA_MAX_LENGTH; + } + + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_VTG_MAX_LENGTH; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_VTG_MAX_LENGTH; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_RMC_MAX_LENGTH; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_RMC_MAX_LENGTH; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_ZDA_MAX_LENGTH; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return NMEA_ZDA_MAX_LENGTH; + } + + return 0; +} + +// Get a pointer to the automatic NMEA flags +nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr() +{ + char thisNMEA[] = "GPGGA"; + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPGGA->automaticFlags; + } + + strcpy(thisNMEA, "GNGGA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNGGA->automaticFlags; + } + + strcpy(thisNMEA, "GPVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPVTG->automaticFlags; + } + + strcpy(thisNMEA, "GNVTG"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNVTG->automaticFlags; + } + + strcpy(thisNMEA, "GPRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPRMC->automaticFlags; + } + + strcpy(thisNMEA, "GNRMC"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNRMC->automaticFlags; + } + + strcpy(thisNMEA, "GPZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGPZDA->automaticFlags; + } + + strcpy(thisNMEA, "GNZDA"); + if (memcmp(thisNMEA, &nmeaAddressField[1], 5) == 0) + { + return &storageNMEAGNZDA->automaticFlags; + } + + return NULL; +} +#endif + +// We need to be able to identify an RTCM packet and then the length +// so that we know when the RTCM message is completely received and we then start +// listening for other sentences (like NMEA or UBX) +// RTCM packet structure is very odd. I never found RTCM STANDARD 10403.2 but +// http://d1.amobbs.com/bbs_upload782111/files_39/ourdev_635123CK0HJT.pdf is good +// https://dspace.cvut.cz/bitstream/handle/10467/65205/F3-BP-2016-Shkalikava-Anastasiya-Prenos%20polohove%20informace%20prostrednictvim%20datove%20site.pdf?sequence=-1 +// Lead me to: https://forum.u-blox.com/index.php/4348/how-to-read-rtcm-messages-from-neo-m8p // RTCM 3.2 bytes look like this: // Byte 0: Always 0xD3 // Byte 1: 6-bits of zero @@ -5120,6 +5568,7 @@ void SFE_UBLOX_GNSS::checkCallbacks(void) packetUBXHNRPVT->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale } +#ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((storageNMEAGPGGA != NULL) // If RAM has been allocated for message storage && (storageNMEAGPGGA->callbackCopy != NULL) // If RAM has been allocated for the copy of the data && (storageNMEAGPGGA->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid @@ -5158,6 +5607,121 @@ void SFE_UBLOX_GNSS::checkCallbacks(void) storageNMEAGNGGA->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale } + if ((storageNMEAGPVTG != NULL) // If RAM has been allocated for message storage + && (storageNMEAGPVTG->callbackCopy != NULL) // If RAM has been allocated for the copy of the data + && (storageNMEAGPVTG->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid + { + if (storageNMEAGPVTG->callbackPointer != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callback for GPVTG")); + storageNMEAGPVTG->callbackPointer(*storageNMEAGPVTG->callbackCopy); // Call the callback + } + if (storageNMEAGPVTG->callbackPointerPtr != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callbackPtr for GPVTG")); + storageNMEAGPVTG->callbackPointerPtr(storageNMEAGPVTG->callbackCopy); // Call the callback + } + storageNMEAGPVTG->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale + } + + if ((storageNMEAGNVTG != NULL) // If RAM has been allocated for message storage + && (storageNMEAGNVTG->callbackCopy != NULL) // If RAM has been allocated for the copy of the data + && (storageNMEAGNVTG->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid + { + if (storageNMEAGNVTG->callbackPointer != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callback for GNVTG")); + storageNMEAGNVTG->callbackPointer(*storageNMEAGNVTG->callbackCopy); // Call the callback + } + if (storageNMEAGNVTG->callbackPointerPtr != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callbackPtr for GNVTG")); + storageNMEAGNVTG->callbackPointerPtr(storageNMEAGNVTG->callbackCopy); // Call the callback + } + storageNMEAGNVTG->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale + } + + if ((storageNMEAGPRMC != NULL) // If RAM has been allocated for message storage + && (storageNMEAGPRMC->callbackCopy != NULL) // If RAM has been allocated for the copy of the data + && (storageNMEAGPRMC->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid + { + if (storageNMEAGPRMC->callbackPointer != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callback for GPRMC")); + storageNMEAGPRMC->callbackPointer(*storageNMEAGPRMC->callbackCopy); // Call the callback + } + if (storageNMEAGPRMC->callbackPointerPtr != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callbackPtr for GPRMC")); + storageNMEAGPRMC->callbackPointerPtr(storageNMEAGPRMC->callbackCopy); // Call the callback + } + storageNMEAGPRMC->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale + } + + if ((storageNMEAGNRMC != NULL) // If RAM has been allocated for message storage + && (storageNMEAGNRMC->callbackCopy != NULL) // If RAM has been allocated for the copy of the data + && (storageNMEAGNRMC->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid + { + if (storageNMEAGNRMC->callbackPointer != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callback for GNRMC")); + storageNMEAGNRMC->callbackPointer(*storageNMEAGNRMC->callbackCopy); // Call the callback + } + if (storageNMEAGNRMC->callbackPointerPtr != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callbackPtr for GNRMC")); + storageNMEAGNRMC->callbackPointerPtr(storageNMEAGNRMC->callbackCopy); // Call the callback + } + storageNMEAGNRMC->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale + } + + if ((storageNMEAGPZDA != NULL) // If RAM has been allocated for message storage + && (storageNMEAGPZDA->callbackCopy != NULL) // If RAM has been allocated for the copy of the data + && (storageNMEAGPZDA->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid + { + if (storageNMEAGPZDA->callbackPointer != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callback for GPZDA")); + storageNMEAGPZDA->callbackPointer(*storageNMEAGPZDA->callbackCopy); // Call the callback + } + if (storageNMEAGPZDA->callbackPointerPtr != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callbackPtr for GPZDA")); + storageNMEAGPZDA->callbackPointerPtr(storageNMEAGPZDA->callbackCopy); // Call the callback + } + storageNMEAGPZDA->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale + } + + if ((storageNMEAGNZDA != NULL) // If RAM has been allocated for message storage + && (storageNMEAGNZDA->callbackCopy != NULL) // If RAM has been allocated for the copy of the data + && (storageNMEAGNZDA->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid + { + if (storageNMEAGNZDA->callbackPointer != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callback for GNZDA")); + storageNMEAGNZDA->callbackPointer(*storageNMEAGNZDA->callbackCopy); // Call the callback + } + if (storageNMEAGNZDA->callbackPointerPtr != NULL) // If the pointer to the callback has been defined + { + // if (_printDebug == true) + // _debugSerial->println(F("checkCallbacks: calling callbackPtr for GNZDA")); + storageNMEAGNZDA->callbackPointerPtr(storageNMEAGNZDA->callbackCopy); // Call the callback + } + storageNMEAGNZDA->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale + } +#endif + checkCallbacksReentrant = false; } @@ -7549,6 +8113,125 @@ bool SFE_UBLOX_GNSS::setTimePulseParameters(UBX_CFG_TP5_data_t *data, uint16_t m return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK } +// Get the jamming/interference monitor configuration using UBX_CFG_ITFM +bool SFE_UBLOX_GNSS::getJammingConfiguration(UBX_CFG_ITFM_data_t *data, uint16_t maxWait) +{ + if (data == NULL) // Check if the user forgot to include the data pointer + return (false); // Bail + + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_ITFM; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return (false); + + // Extract the data + data->config.all = extractLong(&packetCfg, 0); + data->config2.all = extractLong(&packetCfg, 4); + + return (true); +} + +// Set the jamming/interference monitor configuration using UBX_CFG_ITFM +bool SFE_UBLOX_GNSS::setJammingConfiguration(UBX_CFG_ITFM_data_t *data, uint16_t maxWait) +{ + if (data == NULL) // Check if the user forgot to include the data pointer + return (false); // Bail + + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_ITFM; + packetCfg.len = UBX_CFG_ITFM_LEN; + packetCfg.startingSpot = 0; + + payloadCfg[0] = data->config.all & 0xFF; // Little Endian + payloadCfg[1] = (data->config.all >> 8) & 0xFF; + payloadCfg[2] = (data->config.all >> 16) & 0xFF; + payloadCfg[3] = (data->config.all >> 24) & 0xFF; + payloadCfg[4] = data->config2.all & 0xFF; // Little Endian + payloadCfg[5] = (data->config2.all >> 8) & 0xFF; + payloadCfg[6] = (data->config2.all >> 16) & 0xFF; + payloadCfg[7] = (data->config2.all >> 24) & 0xFF; + + return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK +} + +// Get the RF information using UBX_MON_RF +bool SFE_UBLOX_GNSS::getRFinformation(UBX_MON_RF_data_t *data, uint16_t maxWait) +{ + if (data == NULL) // Check if the user forgot to include the data pointer + return (false); // Bail + + packetCfg.cls = UBX_CLASS_MON; + packetCfg.id = UBX_MON_RF; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return (false); + + // Extract the data + data->header.version = extractByte(&packetCfg, 0); + data->header.nBlocks = extractByte(&packetCfg, 1); + + // Extract the RF information blocks + for (uint8_t block = 0; (block < data->header.nBlocks) && (block < UBX_MON_RF_MAX_BLOCKS); block++) + { + data->blocks[block].blockId = extractByte(&packetCfg, 4 + (block * 24)); + data->blocks[block].flags.all = extractByte(&packetCfg, 5 + (block * 24)); + data->blocks[block].antStatus = extractByte(&packetCfg, 6 + (block * 24)); + data->blocks[block].antPower = extractByte(&packetCfg, 7 + (block * 24)); + data->blocks[block].postStatus = extractLong(&packetCfg, 8 + (block * 24)); + data->blocks[block].noisePerMS = extractInt(&packetCfg, 16 + (block * 24)); + data->blocks[block].agcCnt = extractInt(&packetCfg, 18 + (block * 24)); + data->blocks[block].jamInd = extractByte(&packetCfg, 20 + (block * 24)); + data->blocks[block].ofsI = extractSignedChar(&packetCfg, 21 + (block * 24)); + data->blocks[block].magI = extractByte(&packetCfg, 22 + (block * 24)); + data->blocks[block].ofsQ = extractSignedChar(&packetCfg, 23 + (block * 24)); + data->blocks[block].magQ = extractByte(&packetCfg, 24 + (block * 24)); + } + + return (true); +} + +// Get the hardware status (including jamming) using UBX_MON_HW +bool SFE_UBLOX_GNSS::getHWstatus(UBX_MON_HW_data_t *data, uint16_t maxWait) +{ + if (data == NULL) // Check if the user forgot to include the data pointer + return (false); // Bail + + packetCfg.cls = UBX_CLASS_MON; + packetCfg.id = UBX_MON_HW; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return (false); + + // Extract the data + data->pinSel = extractLong(&packetCfg, 0); + data->pinBank = extractLong(&packetCfg, 4); + data->pinDir = extractLong(&packetCfg, 8); + data->pinVal = extractLong(&packetCfg, 12); + data->noisePerMS = extractInt(&packetCfg, 16); + data->agcCnt = extractInt(&packetCfg, 18); + data->aStatus = extractByte(&packetCfg, 20); + data->aPower = extractByte(&packetCfg, 21); + data->flags.all = extractByte(&packetCfg, 22); + data->usedMask = extractLong(&packetCfg, 24); + for (uint8_t pin = 0; pin < 17; pin++) + { + data->VP[pin] = extractByte(&packetCfg, 28 + pin); + } + data->jamInd = extractByte(&packetCfg, 45); + data->pinIrq = extractLong(&packetCfg, 48); + data->pullH = extractLong(&packetCfg, 52); + data->pullL = extractLong(&packetCfg, 56); + + return (true); +} + // UBX-CFG-NAVX5 - get/set the ackAiding byte. If ackAiding is 1, UBX-MGA-ACK messages will be sent by the module to acknowledge the MGA data uint8_t SFE_UBLOX_GNSS::getAckAiding(uint16_t maxWait) // Get the ackAiding byte - returns 255 if the sendCommand fails { @@ -14135,6 +14818,7 @@ uint32_t SFE_UBLOX_GNSS::getProcessNMEAMask() return (_processNMEA.all); } +#ifndef SFE_UBLOX_REDUCED_PROG_MEM // Initiate automatic storage of NMEA GPGGA messages // Get the most recent GPGGA message @@ -14346,6 +15030,640 @@ bool SFE_UBLOX_GNSS::initStorageNMEAGNGGA() return (true); } +// Initiate automatic storage of NMEA GPVTG messages + +// Get the most recent GPVTG message +// Return 0 if the message has not been received from the module +// Return 1 if the data is valid but has been read before +// Return 2 if the data is valid and is fresh/unread +uint8_t SFE_UBLOX_GNSS::getLatestNMEAGPVTG(NMEA_VTG_data_t *data) +{ + if (storageNMEAGPVTG == NULL) + initStorageNMEAGPVTG(); // Check that RAM has been allocated for the message + if (storageNMEAGPVTG == NULL) // Bail if the RAM allocation failed + return (false); + + checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Use a fake UBX class and ID. + + memcpy(data, &storageNMEAGPVTG->completeCopy, sizeof(NMEA_VTG_data_t)); // Copy the complete copy + + uint8_t result = 0; + if (storageNMEAGPVTG->automaticFlags.flags.bits.completeCopyValid == 1) // Is the complete copy valid? + { + result = 1; + if (storageNMEAGPVTG->automaticFlags.flags.bits.completeCopyRead == 0) // Has the data already been read? + { + result = 2; + storageNMEAGPVTG->automaticFlags.flags.bits.completeCopyRead = 1; // Mark the data as read + } + } + + return (result); +} + +// Enable a callback on the arrival of a GPVTG message +bool SFE_UBLOX_GNSS::setNMEAGPVTGcallback(void (*callbackPointer)(NMEA_VTG_data_t)) +{ + if (storageNMEAGPVTG == NULL) + initStorageNMEAGPVTG(); // Check that RAM has been allocated for the message + if (storageNMEAGPVTG == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGPVTG->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGPVTG->callbackCopy = new NMEA_VTG_data_t; + } + + if (storageNMEAGPVTG->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGPVTGcallback: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPVTG->callbackPointer = callbackPointer; + return (true); +} + +bool SFE_UBLOX_GNSS::setNMEAGPVTGcallbackPtr(void (*callbackPointerPtr)(NMEA_VTG_data_t *)) +{ + if (storageNMEAGPVTG == NULL) + initStorageNMEAGPVTG(); // Check that RAM has been allocated for the message + if (storageNMEAGPVTG == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGPVTG->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGPVTG->callbackCopy = new NMEA_VTG_data_t; + } + + if (storageNMEAGPVTG->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGPVTGcallbackPtr: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPVTG->callbackPointerPtr = callbackPointerPtr; + return (true); +} + +// Private: allocate RAM for incoming NMEA GPVTG messages and initialize it +bool SFE_UBLOX_GNSS::initStorageNMEAGPVTG() +{ + storageNMEAGPVTG = new NMEA_GPVTG_t; // Allocate RAM for the main struct + if (storageNMEAGPVTG == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("initStorageNMEAGPVTG: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPVTG->workingCopy.length = 0; // Clear the data length + memset(storageNMEAGPVTG->workingCopy.nmea, 0, NMEA_VTG_MAX_LENGTH); // Clear the nmea storage + storageNMEAGPVTG->completeCopy.length = 0; // Clear the data length + memset(storageNMEAGPVTG->completeCopy.nmea, 0, NMEA_VTG_MAX_LENGTH); // Clear the nmea storage + + storageNMEAGPVTG->callbackPointer = NULL; // Clear the callback pointers + storageNMEAGPVTG->callbackPointerPtr = NULL; // Clear the callback pointers + storageNMEAGPVTG->callbackCopy = NULL; + + storageNMEAGPVTG->automaticFlags.flags.all = 0; // Mark the data as invalid/stale and unread + + return (true); +} + +uint8_t SFE_UBLOX_GNSS::getLatestNMEAGNVTG(NMEA_VTG_data_t *data) +{ + if (storageNMEAGNVTG == NULL) + initStorageNMEAGNVTG(); // Check that RAM has been allocated for the message + if (storageNMEAGNVTG == NULL) // Bail if the RAM allocation failed + return (false); + + checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Use a fake UBX class and ID. + + memcpy(data, &storageNMEAGNVTG->completeCopy, sizeof(NMEA_VTG_data_t)); // Copy the complete copy + + uint8_t result = 0; + if (storageNMEAGNVTG->automaticFlags.flags.bits.completeCopyValid == 1) // Is the complete copy valid? + { + result = 1; + if (storageNMEAGNVTG->automaticFlags.flags.bits.completeCopyRead == 0) // Has the data already been read? + { + result = 2; + storageNMEAGNVTG->automaticFlags.flags.bits.completeCopyRead = 1; // Mark the data as read + } + } + + return (result); +} + +bool SFE_UBLOX_GNSS::setNMEAGNVTGcallback(void (*callbackPointer)(NMEA_VTG_data_t)) +{ + if (storageNMEAGNVTG == NULL) + initStorageNMEAGNVTG(); // Check that RAM has been allocated for the message + if (storageNMEAGNVTG == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGNVTG->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGNVTG->callbackCopy = new NMEA_VTG_data_t; + } + + if (storageNMEAGNVTG->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGNVTGcallback: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNVTG->callbackPointer = callbackPointer; + return (true); +} + +bool SFE_UBLOX_GNSS::setNMEAGNVTGcallbackPtr(void (*callbackPointerPtr)(NMEA_VTG_data_t *)) +{ + if (storageNMEAGNVTG == NULL) + initStorageNMEAGNVTG(); // Check that RAM has been allocated for the message + if (storageNMEAGNVTG == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGNVTG->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGNVTG->callbackCopy = new NMEA_VTG_data_t; + } + + if (storageNMEAGNVTG->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGNVTGcallbackPtr: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNVTG->callbackPointerPtr = callbackPointerPtr; + return (true); +} + +// Private: allocate RAM for incoming NMEA GNVTG messages and initialize it +bool SFE_UBLOX_GNSS::initStorageNMEAGNVTG() +{ + storageNMEAGNVTG = new NMEA_GNVTG_t; // Allocate RAM for the main struct + if (storageNMEAGNVTG == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("initStorageNMEAGNVTG: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNVTG->workingCopy.length = 0; // Clear the data length + memset(storageNMEAGNVTG->workingCopy.nmea, 0, NMEA_VTG_MAX_LENGTH); // Clear the nmea storage + storageNMEAGNVTG->completeCopy.length = 0; // Clear the data length + memset(storageNMEAGNVTG->completeCopy.nmea, 0, NMEA_VTG_MAX_LENGTH); // Clear the nmea storage + + storageNMEAGNVTG->callbackPointer = NULL; // Clear the callback pointers + storageNMEAGNVTG->callbackPointerPtr = NULL; // Clear the callback pointers + storageNMEAGNVTG->callbackCopy = NULL; + + storageNMEAGNVTG->automaticFlags.flags.all = 0; // Mark the data as invalid/stale and unread + + return (true); +} + +// Initiate automatic storage of NMEA GPRMC messages + +// Get the most recent GPRMC message +// Return 0 if the message has not been received from the module +// Return 1 if the data is valid but has been read before +// Return 2 if the data is valid and is fresh/unread +uint8_t SFE_UBLOX_GNSS::getLatestNMEAGPRMC(NMEA_RMC_data_t *data) +{ + if (storageNMEAGPRMC == NULL) + initStorageNMEAGPRMC(); // Check that RAM has been allocated for the message + if (storageNMEAGPRMC == NULL) // Bail if the RAM allocation failed + return (false); + + checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Use a fake UBX class and ID. + + memcpy(data, &storageNMEAGPRMC->completeCopy, sizeof(NMEA_RMC_data_t)); // Copy the complete copy + + uint8_t result = 0; + if (storageNMEAGPRMC->automaticFlags.flags.bits.completeCopyValid == 1) // Is the complete copy valid? + { + result = 1; + if (storageNMEAGPRMC->automaticFlags.flags.bits.completeCopyRead == 0) // Has the data already been read? + { + result = 2; + storageNMEAGPRMC->automaticFlags.flags.bits.completeCopyRead = 1; // Mark the data as read + } + } + + return (result); +} + +// Enable a callback on the arrival of a GPRMC message +bool SFE_UBLOX_GNSS::setNMEAGPRMCcallback(void (*callbackPointer)(NMEA_RMC_data_t)) +{ + if (storageNMEAGPRMC == NULL) + initStorageNMEAGPRMC(); // Check that RAM has been allocated for the message + if (storageNMEAGPRMC == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGPRMC->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGPRMC->callbackCopy = new NMEA_RMC_data_t; + } + + if (storageNMEAGPRMC->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGPRMCcallback: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPRMC->callbackPointer = callbackPointer; + return (true); +} + +bool SFE_UBLOX_GNSS::setNMEAGPRMCcallbackPtr(void (*callbackPointerPtr)(NMEA_RMC_data_t *)) +{ + if (storageNMEAGPRMC == NULL) + initStorageNMEAGPRMC(); // Check that RAM has been allocated for the message + if (storageNMEAGPRMC == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGPRMC->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGPRMC->callbackCopy = new NMEA_RMC_data_t; + } + + if (storageNMEAGPRMC->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGPRMCcallbackPtr: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPRMC->callbackPointerPtr = callbackPointerPtr; + return (true); +} + +// Private: allocate RAM for incoming NMEA GPRMC messages and initialize it +bool SFE_UBLOX_GNSS::initStorageNMEAGPRMC() +{ + storageNMEAGPRMC = new NMEA_GPRMC_t; // Allocate RAM for the main struct + if (storageNMEAGPRMC == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("initStorageNMEAGPRMC: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPRMC->workingCopy.length = 0; // Clear the data length + memset(storageNMEAGPRMC->workingCopy.nmea, 0, NMEA_RMC_MAX_LENGTH); // Clear the nmea storage + storageNMEAGPRMC->completeCopy.length = 0; // Clear the data length + memset(storageNMEAGPRMC->completeCopy.nmea, 0, NMEA_RMC_MAX_LENGTH); // Clear the nmea storage + + storageNMEAGPRMC->callbackPointer = NULL; // Clear the callback pointers + storageNMEAGPRMC->callbackPointerPtr = NULL; // Clear the callback pointers + storageNMEAGPRMC->callbackCopy = NULL; + + storageNMEAGPRMC->automaticFlags.flags.all = 0; // Mark the data as invalid/stale and unread + + return (true); +} + +uint8_t SFE_UBLOX_GNSS::getLatestNMEAGNRMC(NMEA_RMC_data_t *data) +{ + if (storageNMEAGNRMC == NULL) + initStorageNMEAGNRMC(); // Check that RAM has been allocated for the message + if (storageNMEAGNRMC == NULL) // Bail if the RAM allocation failed + return (false); + + checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Use a fake UBX class and ID. + + memcpy(data, &storageNMEAGNRMC->completeCopy, sizeof(NMEA_RMC_data_t)); // Copy the complete copy + + uint8_t result = 0; + if (storageNMEAGNRMC->automaticFlags.flags.bits.completeCopyValid == 1) // Is the complete copy valid? + { + result = 1; + if (storageNMEAGNRMC->automaticFlags.flags.bits.completeCopyRead == 0) // Has the data already been read? + { + result = 2; + storageNMEAGNRMC->automaticFlags.flags.bits.completeCopyRead = 1; // Mark the data as read + } + } + + return (result); +} + +bool SFE_UBLOX_GNSS::setNMEAGNRMCcallback(void (*callbackPointer)(NMEA_RMC_data_t)) +{ + if (storageNMEAGNRMC == NULL) + initStorageNMEAGNRMC(); // Check that RAM has been allocated for the message + if (storageNMEAGNRMC == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGNRMC->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGNRMC->callbackCopy = new NMEA_RMC_data_t; + } + + if (storageNMEAGNRMC->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGNRMCcallback: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNRMC->callbackPointer = callbackPointer; + return (true); +} + +bool SFE_UBLOX_GNSS::setNMEAGNRMCcallbackPtr(void (*callbackPointerPtr)(NMEA_RMC_data_t *)) +{ + if (storageNMEAGNRMC == NULL) + initStorageNMEAGNRMC(); // Check that RAM has been allocated for the message + if (storageNMEAGNRMC == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGNRMC->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGNRMC->callbackCopy = new NMEA_RMC_data_t; + } + + if (storageNMEAGNRMC->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGNRMCcallbackPtr: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNRMC->callbackPointerPtr = callbackPointerPtr; + return (true); +} + +// Private: allocate RAM for incoming NMEA GNRMC messages and initialize it +bool SFE_UBLOX_GNSS::initStorageNMEAGNRMC() +{ + storageNMEAGNRMC = new NMEA_GNRMC_t; // Allocate RAM for the main struct + if (storageNMEAGNRMC == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("initStorageNMEAGNRMC: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNRMC->workingCopy.length = 0; // Clear the data length + memset(storageNMEAGNRMC->workingCopy.nmea, 0, NMEA_RMC_MAX_LENGTH); // Clear the nmea storage + storageNMEAGNRMC->completeCopy.length = 0; // Clear the data length + memset(storageNMEAGNRMC->completeCopy.nmea, 0, NMEA_RMC_MAX_LENGTH); // Clear the nmea storage + + storageNMEAGNRMC->callbackPointer = NULL; // Clear the callback pointers + storageNMEAGNRMC->callbackPointerPtr = NULL; // Clear the callback pointers + storageNMEAGNRMC->callbackCopy = NULL; + + storageNMEAGNRMC->automaticFlags.flags.all = 0; // Mark the data as invalid/stale and unread + + return (true); +} + +// Initiate automatic storage of NMEA GPZDA messages + +// Get the most recent GPZDA message +// Return 0 if the message has not been received from the module +// Return 1 if the data is valid but has been read before +// Return 2 if the data is valid and is fresh/unread +uint8_t SFE_UBLOX_GNSS::getLatestNMEAGPZDA(NMEA_ZDA_data_t *data) +{ + if (storageNMEAGPZDA == NULL) + initStorageNMEAGPZDA(); // Check that RAM has been allocated for the message + if (storageNMEAGPZDA == NULL) // Bail if the RAM allocation failed + return (false); + + checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Use a fake UBX class and ID. + + memcpy(data, &storageNMEAGPZDA->completeCopy, sizeof(NMEA_ZDA_data_t)); // Copy the complete copy + + uint8_t result = 0; + if (storageNMEAGPZDA->automaticFlags.flags.bits.completeCopyValid == 1) // Is the complete copy valid? + { + result = 1; + if (storageNMEAGPZDA->automaticFlags.flags.bits.completeCopyRead == 0) // Has the data already been read? + { + result = 2; + storageNMEAGPZDA->automaticFlags.flags.bits.completeCopyRead = 1; // Mark the data as read + } + } + + return (result); +} + +// Enable a callback on the arrival of a GPZDA message +bool SFE_UBLOX_GNSS::setNMEAGPZDAcallback(void (*callbackPointer)(NMEA_ZDA_data_t)) +{ + if (storageNMEAGPZDA == NULL) + initStorageNMEAGPZDA(); // Check that RAM has been allocated for the message + if (storageNMEAGPZDA == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGPZDA->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGPZDA->callbackCopy = new NMEA_ZDA_data_t; + } + + if (storageNMEAGPZDA->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGPZDAcallback: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPZDA->callbackPointer = callbackPointer; + return (true); +} + +bool SFE_UBLOX_GNSS::setNMEAGPZDAcallbackPtr(void (*callbackPointerPtr)(NMEA_ZDA_data_t *)) +{ + if (storageNMEAGPZDA == NULL) + initStorageNMEAGPZDA(); // Check that RAM has been allocated for the message + if (storageNMEAGPZDA == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGPZDA->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGPZDA->callbackCopy = new NMEA_ZDA_data_t; + } + + if (storageNMEAGPZDA->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGPZDAcallbackPtr: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPZDA->callbackPointerPtr = callbackPointerPtr; + return (true); +} + +// Private: allocate RAM for incoming NMEA GPZDA messages and initialize it +bool SFE_UBLOX_GNSS::initStorageNMEAGPZDA() +{ + storageNMEAGPZDA = new NMEA_GPZDA_t; // Allocate RAM for the main struct + if (storageNMEAGPZDA == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("initStorageNMEAGPZDA: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGPZDA->workingCopy.length = 0; // Clear the data length + memset(storageNMEAGPZDA->workingCopy.nmea, 0, NMEA_ZDA_MAX_LENGTH); // Clear the nmea storage + storageNMEAGPZDA->completeCopy.length = 0; // Clear the data length + memset(storageNMEAGPZDA->completeCopy.nmea, 0, NMEA_ZDA_MAX_LENGTH); // Clear the nmea storage + + storageNMEAGPZDA->callbackPointer = NULL; // Clear the callback pointers + storageNMEAGPZDA->callbackPointerPtr = NULL; // Clear the callback pointers + storageNMEAGPZDA->callbackCopy = NULL; + + storageNMEAGPZDA->automaticFlags.flags.all = 0; // Mark the data as invalid/stale and unread + + return (true); +} + +uint8_t SFE_UBLOX_GNSS::getLatestNMEAGNZDA(NMEA_ZDA_data_t *data) +{ + if (storageNMEAGNZDA == NULL) + initStorageNMEAGNZDA(); // Check that RAM has been allocated for the message + if (storageNMEAGNZDA == NULL) // Bail if the RAM allocation failed + return (false); + + checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Use a fake UBX class and ID. + + memcpy(data, &storageNMEAGNZDA->completeCopy, sizeof(NMEA_ZDA_data_t)); // Copy the complete copy + + uint8_t result = 0; + if (storageNMEAGNZDA->automaticFlags.flags.bits.completeCopyValid == 1) // Is the complete copy valid? + { + result = 1; + if (storageNMEAGNZDA->automaticFlags.flags.bits.completeCopyRead == 0) // Has the data already been read? + { + result = 2; + storageNMEAGNZDA->automaticFlags.flags.bits.completeCopyRead = 1; // Mark the data as read + } + } + + return (result); +} + +bool SFE_UBLOX_GNSS::setNMEAGNZDAcallback(void (*callbackPointer)(NMEA_ZDA_data_t)) +{ + if (storageNMEAGNZDA == NULL) + initStorageNMEAGNZDA(); // Check that RAM has been allocated for the message + if (storageNMEAGNZDA == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGNZDA->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGNZDA->callbackCopy = new NMEA_ZDA_data_t; + } + + if (storageNMEAGNZDA->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGNZDAcallback: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNZDA->callbackPointer = callbackPointer; + return (true); +} + +bool SFE_UBLOX_GNSS::setNMEAGNZDAcallbackPtr(void (*callbackPointerPtr)(NMEA_ZDA_data_t *)) +{ + if (storageNMEAGNZDA == NULL) + initStorageNMEAGNZDA(); // Check that RAM has been allocated for the message + if (storageNMEAGNZDA == NULL) // Bail if the RAM allocation failed + return (false); + + if (storageNMEAGNZDA->callbackCopy == NULL) // Check if RAM has been allocated for the callback copy + { + storageNMEAGNZDA->callbackCopy = new NMEA_ZDA_data_t; + } + + if (storageNMEAGNZDA->callbackCopy == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("setNMEAGNZDAcallbackPtr: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNZDA->callbackPointerPtr = callbackPointerPtr; + return (true); +} + +// Private: allocate RAM for incoming NMEA GNZDA messages and initialize it +bool SFE_UBLOX_GNSS::initStorageNMEAGNZDA() +{ + storageNMEAGNZDA = new NMEA_GNZDA_t; // Allocate RAM for the main struct + if (storageNMEAGNZDA == NULL) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + _debugSerial->println(F("initStorageNMEAGNZDA: RAM alloc failed!")); +#endif + return (false); + } + + storageNMEAGNZDA->workingCopy.length = 0; // Clear the data length + memset(storageNMEAGNZDA->workingCopy.nmea, 0, NMEA_ZDA_MAX_LENGTH); // Clear the nmea storage + storageNMEAGNZDA->completeCopy.length = 0; // Clear the data length + memset(storageNMEAGNZDA->completeCopy.nmea, 0, NMEA_ZDA_MAX_LENGTH); // Clear the nmea storage + + storageNMEAGNZDA->callbackPointer = NULL; // Clear the callback pointers + storageNMEAGNZDA->callbackPointerPtr = NULL; // Clear the callback pointers + storageNMEAGNZDA->callbackCopy = NULL; + + storageNMEAGNZDA->automaticFlags.flags.all = 0; // Mark the data as invalid/stale and unread + + return (true); +} +#endif + // ***** CFG RATE Helper Functions // Set the rate at which the module will give us an updated navigation solution diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 2fbb2cf..b22e40f 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -57,9 +57,9 @@ #include "u-blox_structs.h" // Uncomment the next line (or add SFE_UBLOX_REDUCED_PROG_MEM as a compiler directive) to reduce the amount of program memory used by the library -//#define SFE_UBLOX_REDUCED_PROG_MEM // Uncommenting this line will delete the minor debug messages to save memory +//#define SFE_UBLOX_REDUCED_PROG_MEM // Uncommenting this line will delete the minor debug messages and disable auto-NMEA support to save memory -// The code just about fills the program memory on the ATmega328P (Arduino Uno), so let's delete the minor debug messages anyway +// The code just about fills the program memory on the ATmega328P (Arduino Uno), so let's delete the minor debug messages and disable auto-NMEA support anyway #if !defined(SFE_UBLOX_REDUCED_PROG_MEM) && defined(ARDUINO_ARCH_AVR) #define SFE_UBLOX_REDUCED_PROG_MEM #endif @@ -901,6 +901,16 @@ class SFE_UBLOX_GNSS bool getTimePulseParameters(UBX_CFG_TP5_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Get the time pulse parameters using UBX_CFG_TP5 bool setTimePulseParameters(UBX_CFG_TP5_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Set the time pulse parameters using UBX_CFG_TP5 + // Jamming/interference monitor configuration + bool getJammingConfiguration(UBX_CFG_ITFM_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Get the jamming/interference monitor configuration using UBX_CFG_ITFM + bool setJammingConfiguration(UBX_CFG_ITFM_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Set the jamming/interference monitor configuration using UBX_CFG_ITFM + + // RF Information (including jamming) - ZED-F9 only + bool getRFinformation(UBX_MON_RF_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Get the RF information using UBX_MON_RF + + // Hardware status (including jamming) + bool getHWstatus(UBX_MON_HW_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Get the hardware status using UBX_MON_HW + // UBX-CFG-NAVX5 - get/set the ackAiding byte. If ackAiding is 1, UBX-MGA-ACK messages will be sent by the module to acknowledge the MGA data uint8_t getAckAiding(uint16_t maxWait = defaultMaxWait); // Get the ackAiding byte - returns 255 if the sendCommand fails bool setAckAiding(uint8_t ackAiding, uint16_t maxWait = defaultMaxWait); // Set the ackAiding byte @@ -1421,6 +1431,7 @@ class SFE_UBLOX_GNSS void setProcessNMEAMask(uint32_t messages = SFE_UBLOX_FILTER_NMEA_ALL); // Control which NMEA messages are passed to processNMEA. Default to passing ALL messages uint32_t getProcessNMEAMask(); // Return which NMEA messages are passed to processNMEA +#ifndef SFE_UBLOX_REDUCED_PROG_MEM // Support for "auto" storage of NMEA messages uint8_t getLatestNMEAGPGGA(NMEA_GGA_data_t *data); // Return the most recent GPGGA: 0 = no data, 1 = stale data, 2 = fresh data bool setNMEAGPGGAcallback(void (*callbackPointer)(NMEA_GGA_data_t)); // Enable a callback on the arrival of a GPGGA message @@ -1428,6 +1439,25 @@ class SFE_UBLOX_GNSS uint8_t getLatestNMEAGNGGA(NMEA_GGA_data_t *data); // Return the most recent GNGGA: 0 = no data, 1 = stale data, 2 = fresh data bool setNMEAGNGGAcallback(void (*callbackPointer)(NMEA_GGA_data_t)); // Enable a callback on the arrival of a GNGGA message bool setNMEAGNGGAcallbackPtr(void (*callbackPointerPtr)(NMEA_GGA_data_t *)); // Enable a callback on the arrival of a GNGGA message + uint8_t getLatestNMEAGPVTG(NMEA_VTG_data_t *data); // Return the most recent GPVTG: 0 = no data, 1 = stale data, 2 = fresh data + bool setNMEAGPVTGcallback(void (*callbackPointer)(NMEA_VTG_data_t)); // Enable a callback on the arrival of a GPVTG message + bool setNMEAGPVTGcallbackPtr(void (*callbackPointerPtr)(NMEA_VTG_data_t *)); // Enable a callback on the arrival of a GPVTG message + uint8_t getLatestNMEAGNVTG(NMEA_VTG_data_t *data); // Return the most recent GNVTG: 0 = no data, 1 = stale data, 2 = fresh data + bool setNMEAGNVTGcallback(void (*callbackPointer)(NMEA_VTG_data_t)); // Enable a callback on the arrival of a GNVTG message + bool setNMEAGNVTGcallbackPtr(void (*callbackPointerPtr)(NMEA_VTG_data_t *)); // Enable a callback on the arrival of a GNVTG message + uint8_t getLatestNMEAGPRMC(NMEA_RMC_data_t *data); // Return the most recent GPRMC: 0 = no data, 1 = stale data, 2 = fresh data + bool setNMEAGPRMCcallback(void (*callbackPointer)(NMEA_RMC_data_t)); // Enable a callback on the arrival of a GPRMC message + bool setNMEAGPRMCcallbackPtr(void (*callbackPointerPtr)(NMEA_RMC_data_t *)); // Enable a callback on the arrival of a GPRMC message + uint8_t getLatestNMEAGNRMC(NMEA_RMC_data_t *data); // Return the most recent GNRMC: 0 = no data, 1 = stale data, 2 = fresh data + bool setNMEAGNRMCcallback(void (*callbackPointer)(NMEA_RMC_data_t)); // Enable a callback on the arrival of a GNRMC message + bool setNMEAGNRMCcallbackPtr(void (*callbackPointerPtr)(NMEA_RMC_data_t *)); // Enable a callback on the arrival of a GNRMC message + uint8_t getLatestNMEAGPZDA(NMEA_ZDA_data_t *data); // Return the most recent GPZDA: 0 = no data, 1 = stale data, 2 = fresh data + bool setNMEAGPZDAcallback(void (*callbackPointer)(NMEA_ZDA_data_t)); // Enable a callback on the arrival of a GPZDA message + bool setNMEAGPZDAcallbackPtr(void (*callbackPointerPtr)(NMEA_ZDA_data_t *)); // Enable a callback on the arrival of a GPZDA message + uint8_t getLatestNMEAGNZDA(NMEA_ZDA_data_t *data); // Return the most recent GNZDA: 0 = no data, 1 = stale data, 2 = fresh data + bool setNMEAGNZDAcallback(void (*callbackPointer)(NMEA_ZDA_data_t)); // Enable a callback on the arrival of a GNZDA message + bool setNMEAGNZDAcallbackPtr(void (*callbackPointerPtr)(NMEA_ZDA_data_t *)); // Enable a callback on the arrival of a GNZDA message +#endif // Functions to extract signed and unsigned 8/16/32-bit data from a ubxPacket // From v2.0: These are public. The user can call these to extract data from custom packets @@ -1483,8 +1513,16 @@ class SFE_UBLOX_GNSS UBX_MGA_ACK_DATA0_t *packetUBXMGAACK = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary UBX_MGA_DBD_t *packetUBXMGADBD = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary +#ifndef SFE_UBLOX_REDUCED_PROG_MEM NMEA_GPGGA_t *storageNMEAGPGGA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary NMEA_GNGGA_t *storageNMEAGNGGA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + NMEA_GPVTG_t *storageNMEAGPVTG = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + NMEA_GNVTG_t *storageNMEAGNVTG = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + NMEA_GPRMC_t *storageNMEAGPRMC = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + NMEA_GNRMC_t *storageNMEAGNRMC = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + NMEA_GPZDA_t *storageNMEAGPZDA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + NMEA_GNZDA_t *storageNMEAGNZDA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary +#endif uint16_t rtcmFrameCounter = 0; // Tracks the type of incoming byte inside RTCM frame @@ -1568,8 +1606,16 @@ class SFE_UBLOX_GNSS bool initPacketUBXMGAACK(); // Allocate RAM for packetUBXMGAACK and initialize it bool initPacketUBXMGADBD(); // Allocate RAM for packetUBXMGADBD and initialize it +#ifndef SFE_UBLOX_REDUCED_PROG_MEM bool initStorageNMEAGPGGA(); // Allocate RAM for incoming NMEA GPGGA messages and initialize it bool initStorageNMEAGNGGA(); // Allocate RAM for incoming NMEA GNGGA messages and initialize it + bool initStorageNMEAGPVTG(); // Allocate RAM for incoming NMEA GPVTG messages and initialize it + bool initStorageNMEAGNVTG(); // Allocate RAM for incoming NMEA GNVTG messages and initialize it + bool initStorageNMEAGPRMC(); // Allocate RAM for incoming NMEA GPRMC messages and initialize it + bool initStorageNMEAGNRMC(); // Allocate RAM for incoming NMEA GNRMC messages and initialize it + bool initStorageNMEAGPZDA(); // Allocate RAM for incoming NMEA GPZDA messages and initialize it + bool initStorageNMEAGNZDA(); // Allocate RAM for incoming NMEA GNZDA messages and initialize it +#endif // Variables TwoWire *_i2cPort; // The generic connection to user's chosen I2C hardware diff --git a/src/u-blox_structs.h b/src/u-blox_structs.h index 3812c26..2a29822 100644 --- a/src/u-blox_structs.h +++ b/src/u-blox_structs.h @@ -1667,6 +1667,118 @@ typedef struct } flags; } UBX_CFG_TP5_data_t; +// UBX-CFG-ITFM (0x06 0x39): Jamming/interference monitor configuration +const uint16_t UBX_CFG_ITFM_LEN = 8; + +typedef struct +{ + union + { + uint32_t all; + struct + { + uint32_t bbThreshold : 4; // Broadband jamming detection threshold + uint32_t cwThreshold : 5; // CW jamming detection threshold + uint32_t algorithmBits : 22; // Reserved algorithm settings - should be set to 0x16B156 in hex for correct settings + uint32_t enable : 1; // Enable interference detection + } bits; + } config; + union + { + uint32_t all; + struct + { + uint32_t generalBits : 12; // General settings - should be set to 0x31E in hex for correct setting + uint32_t antSetting : 2; // Antenna setting, 0=unknown, 1=passive, 2=active + uint32_t enable2 : 1; // Set to 1 to scan auxiliary bands (u-blox 8 / u-blox M8 only, otherwise ignored) + } bits; + } config2; +} UBX_CFG_ITFM_data_t; + +// MON-specific structs + +// UBX-MON-HW (0x0A 0x09): Hardware status +const uint16_t UBX_MON_HW_LEN = 60; + +typedef struct +{ + uint32_t pinSel; // Mask of pins set as peripheral/PIO + uint32_t pinBank; // Mask of pins set as bank A/B + uint32_t pinDir; // Mask of pins set as input/output + uint32_t pinVal; // Mask of pins value low/high + uint16_t noisePerMS; // Noise level as measured by the GPS core + uint16_t agcCnt; // AGC monitor (counts SIGHI xor SIGLO, range 0 to 8191) + uint8_t aStatus; // Status of the antenna supervisor state machine (0=INIT, 1=DONTKNOW, 2=OK, 3=SHORT, 4=OPEN) + uint8_t aPower; // Current power status of antenna (0=OFF, 1=ON, 2=DONTKNOW) + union + { + uint8_t all; + struct + { + uint8_t rtcCalib : 1; // RTC is calibrated + uint8_t safeBoot : 1; // Safeboot mode (0 = inactive, 1 = active) + uint8_t jammingState : 2; // Output from jamming/interference monitor (0 = unknown or feature disabled, + // 1 = ok - no significant jamming, + // 2 = warning - interference visible but fix OK, + // 3 = critical - interference visible and no fix) + uint8_t xtalAbsent : 1; // RTC xtal has been determined to be absent + } bits; + } flags; + uint8_t reserved1; // Reserved + uint32_t usedMask; // Mask of pins that are used by the virtual pin manager + uint8_t VP[17]; // Array of pin mappings for each of the 17 physical pins + uint8_t jamInd; // CW jamming indicator, scaled (0 = no CW jamming, 255 = strong CW jamming) + uint8_t reserved2[2]; // Reserved + uint32_t pinIrq; // Mask of pins value using the PIO Irq + uint32_t pullH; // Mask of pins value using the PIO pull high resistor + uint8_t pullL; // Mask of pins value using the PIO pull low resistor +} UBX_MON_HW_data_t; + +// UBX-MON-RF (0x0a 0x38): RF information +const uint16_t UBX_MON_RF_MAX_BLOCKS = 2; // 0 = L1; 1 = L2 / L5 +const uint16_t UBX_MON_RF_MAX_LEN = 4 + (24 * UBX_MON_RF_MAX_BLOCKS); + +typedef struct +{ + uint8_t version; // Message version (0x00 for this version) + uint8_t nBlocks; // The number of RF blocks included + uint8_t reserved0[2]; +} UBX_MON_RF_header_t; + +typedef struct +{ + uint8_t blockId; // RF block ID (0 = L1 band, 1 = L2 or L5 band depending on product configuration) + union + { + uint8_t all; + struct + { + uint8_t jammingState : 2; // output from Jamming/Interference Monitor (0 = unknown or feature disabled, + // 1 = ok - no significant jamming, + // 2 = warning - interference visible but fix OK, + // 3 = critical - interference visible and no fix) + } bits; + } flags; + uint8_t antStatus; // Status of the antenna supervisor state machine (0x00=INIT, 0x01=DONTKNOW, 0x02=OK, 0x03=SHORT, 0x04=OPEN) + uint8_t antPower; // Current power status of antenna (0x00=OFF, 0x01=ON, 0x02=DONTKNOW) + uint32_t postStatus; // POST status word + uint8_t reserved1[4]; // Reserved + uint16_t noisePerMS; // Noise level as measured by the GPS core + uint16_t agcCnt; // AGC Monitor (counts SIGHI xor SIGLO, range 0 to 8191) + uint8_t jamInd; // CW jamming indicator, scaled (0=no CW jamming, 255 = strong CW jamming) + int8_t ofsI; // Imbalance of I-part of complex signal, scaled (-128 = max. negative imbalance, 127 = max. positive imbalance) + uint8_t magI; // Magnitude of I-part of complex signal, scaled (0 = no signal, 255 = max.magnitude) + int8_t ofsQ; // Imbalance of Q-part of complex signal, scaled (-128 = max. negative imbalance, 127 = max. positive imbalance) + uint8_t magQ; // Magnitude of Q-part of complex signal, scaled (0 = no signal, 255 = max.magnitude) + uint8_t reserved2[3]; // Reserved +} UBX_MON_RF_block_t; + +typedef struct +{ + UBX_MON_RF_header_t header; + UBX_MON_RF_block_t blocks[UBX_MON_RF_MAX_BLOCKS]; +} UBX_MON_RF_data_t; + // TIM-specific structs // UBX-TIM-TM2 (0x0D 0x03): Time mark data @@ -2423,4 +2535,88 @@ typedef struct NMEA_GGA_data_t *callbackCopy; // The callback gets its own preserved copy of the complete copy } NMEA_GNGGA_t; +const uint8_t NMEA_VTG_MAX_LENGTH = 100; + +typedef struct +{ + uint8_t length; // The number of bytes in nmea + uint8_t nmea[NMEA_VTG_MAX_LENGTH]; +} NMEA_VTG_data_t; + +typedef struct +{ + nmeaAutomaticFlags automaticFlags; + NMEA_VTG_data_t workingCopy; // Incoming data is added to the working copy + NMEA_VTG_data_t completeCopy; // The working copy is copied into the complete copy when all data has been received and the checksum is valid + void (*callbackPointer)(NMEA_VTG_data_t); + void (*callbackPointerPtr)(NMEA_VTG_data_t *); + NMEA_VTG_data_t *callbackCopy; // The callback gets its own preserved copy of the complete copy +} NMEA_GPVTG_t; + +typedef struct +{ + nmeaAutomaticFlags automaticFlags; + NMEA_VTG_data_t workingCopy; // Incoming data is added to the working copy + NMEA_VTG_data_t completeCopy; // The working copy is copied into the complete copy when all data has been received and the checksum is valid + void (*callbackPointer)(NMEA_VTG_data_t); + void (*callbackPointerPtr)(NMEA_VTG_data_t *); + NMEA_VTG_data_t *callbackCopy; // The callback gets its own preserved copy of the complete copy +} NMEA_GNVTG_t; + +const uint8_t NMEA_RMC_MAX_LENGTH = 100; + +typedef struct +{ + uint8_t length; // The number of bytes in nmea + uint8_t nmea[NMEA_RMC_MAX_LENGTH]; +} NMEA_RMC_data_t; + +typedef struct +{ + nmeaAutomaticFlags automaticFlags; + NMEA_RMC_data_t workingCopy; // Incoming data is added to the working copy + NMEA_RMC_data_t completeCopy; // The working copy is copied into the complete copy when all data has been received and the checksum is valid + void (*callbackPointer)(NMEA_RMC_data_t); + void (*callbackPointerPtr)(NMEA_RMC_data_t *); + NMEA_RMC_data_t *callbackCopy; // The callback gets its own preserved copy of the complete copy +} NMEA_GPRMC_t; + +typedef struct +{ + nmeaAutomaticFlags automaticFlags; + NMEA_RMC_data_t workingCopy; // Incoming data is added to the working copy + NMEA_RMC_data_t completeCopy; // The working copy is copied into the complete copy when all data has been received and the checksum is valid + void (*callbackPointer)(NMEA_RMC_data_t); + void (*callbackPointerPtr)(NMEA_RMC_data_t *); + NMEA_RMC_data_t *callbackCopy; // The callback gets its own preserved copy of the complete copy +} NMEA_GNRMC_t; + +const uint8_t NMEA_ZDA_MAX_LENGTH = 50; + +typedef struct +{ + uint8_t length; // The number of bytes in nmea + uint8_t nmea[NMEA_ZDA_MAX_LENGTH]; +} NMEA_ZDA_data_t; + +typedef struct +{ + nmeaAutomaticFlags automaticFlags; + NMEA_ZDA_data_t workingCopy; // Incoming data is added to the working copy + NMEA_ZDA_data_t completeCopy; // The working copy is copied into the complete copy when all data has been received and the checksum is valid + void (*callbackPointer)(NMEA_ZDA_data_t); + void (*callbackPointerPtr)(NMEA_ZDA_data_t *); + NMEA_ZDA_data_t *callbackCopy; // The callback gets its own preserved copy of the complete copy +} NMEA_GPZDA_t; + +typedef struct +{ + nmeaAutomaticFlags automaticFlags; + NMEA_ZDA_data_t workingCopy; // Incoming data is added to the working copy + NMEA_ZDA_data_t completeCopy; // The working copy is copied into the complete copy when all data has been received and the checksum is valid + void (*callbackPointer)(NMEA_ZDA_data_t); + void (*callbackPointerPtr)(NMEA_ZDA_data_t *); + NMEA_ZDA_data_t *callbackCopy; // The callback gets its own preserved copy of the complete copy +} NMEA_GNZDA_t; + #endif