diff --git a/examples/Callbacks/CallbackExample6_RAWX/CallbackExample6_RAWX.ino b/examples/Callbacks/CallbackExample6_RAWX/CallbackExample6_RAWX.ino new file mode 100644 index 0000000..2461ccc --- /dev/null +++ b/examples/Callbacks/CallbackExample6_RAWX/CallbackExample6_RAWX.ino @@ -0,0 +1,107 @@ +/* + Configuring the GNSS to automatically send RXM RZWX reports over I2C and display them using a callback + By: Paul Clark + SparkFun Electronics + Date: March 11th, 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 configure the u-blox GNSS to send RXM RAWX reports automatically + and access the data via a callback. No more polling! + + Feel like supporting open source hardware? + Buy a board from SparkFun! + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a BlackBoard + 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 GPS + +#include //http://librarymanager/All#SparkFun_u-blox_GNSS +SFE_UBLOX_GNSS myGNSS; + +// Callback: newRAWX will be called when new RXM RAWX data arrives +// See u-blox_structs.h for the full definition of UBX_RXMRAWX_data_t +// _____ You can use any name you like for the callback. Use the same name when you call setAutoRXMRAWXcallback +// / _____ This _must_ be UBX_RXM_RAWX_data_t +// | / _____ You can use any name you like for the struct +// | | / +// | | | +void newRAWX(UBX_RXM_RAWX_data_t ubxDataStruct) +{ + Serial.println(); + + Serial.print(F("New RAWX data received. It contains ")); + Serial.print(ubxDataStruct.header.numMeas); // Print numMeas (Number of measurements / blocks) + Serial.println(F(" data blocks:")); + + for (uint8_t block = 0; block < ubxDataStruct.header.numMeas; block++) // For each block + { + Serial.print(F("GNSS ID: ")); + if (ubxDataStruct.blocks[block].gnssId < 100) Serial.print(F(" ")); // Align the gnssId + if (ubxDataStruct.blocks[block].gnssId < 10) Serial.print(F(" ")); // Align the gnssId + Serial.print(ubxDataStruct.blocks[block].gnssId); + Serial.print(F(" SV ID: ")); + if (ubxDataStruct.blocks[block].svId < 100) Serial.print(F(" ")); // Align the svId + if (ubxDataStruct.blocks[block].svId < 10) Serial.print(F(" ")); // Align the svId + Serial.print(ubxDataStruct.blocks[block].svId); + + if (sizeof(double) == 8) // Check if our processor supports 64-bit double + { + // Convert prMes from uint8_t[8] to 64-bit double + // prMes is little-endian + double pseudorange; + memcpy(&pseudorange, &ubxDataStruct.blocks[block].prMes, 8); + Serial.print(F(" PR: ")); + Serial.print(pseudorange, 3); + + // Convert cpMes from uint8_t[8] to 64-bit double + // cpMes is little-endian + double carrierPhase; + memcpy(&carrierPhase, &ubxDataStruct.blocks[block].cpMes, 8); + Serial.print(F(" m CP: ")); + Serial.print(carrierPhase, 3); + Serial.print(F(" cycles")); + } + Serial.println(); + } +} + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun u-blox Example"); + + Wire.begin(); + + //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial + + myGNSS.disableUBX7Fcheck(); // RAWX data can legitimately contain 0x7F, so we need to disable the "7F" check in checkUbloxI2C + + if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port + { + Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR + + myGNSS.setNavigationFrequency(1); //Produce one solution per second (RAWX produces a _lot_ of data!) + + myGNSS.setAutoRXMRAWXcallback(&newRAWX); // Enable automatic RXM RAWX messages with callback to newRAWX +} + +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/Example24_GetUnixEpochAndMicros/Example24_GetUnixEpochAndMicros.ino b/examples/Example24_GetUnixEpochAndMicros/Example24_GetUnixEpochAndMicros.ino new file mode 100644 index 0000000..b3ea934 --- /dev/null +++ b/examples/Example24_GetUnixEpochAndMicros/Example24_GetUnixEpochAndMicros.ino @@ -0,0 +1,108 @@ +/* + Getting Unix Epoch Time and micros using u-blox commands + By: UT2UH + Date: March 30th, 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 query a u-blox module for the current time and date as Unix Epoch uint32_t type to avoid time.h dependency. + We also turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic dramatically. + + Note: this example works best on modules like the ZED_F9P. Modules like the ZOE_M8Q do not support confirmedTime. + + Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! + + 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 BlackBoard + 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 //http://librarymanager/All#SparkFun_u-blox_GNSS +SFE_UBLOX_GNSS myGNSS; + + +long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. + +void setup() +{ + Serial.begin(115200); + while (!Serial) + ; //Wait for user to open terminal + Serial.println("SparkFun u-blox Example"); + + Wire.begin(); + + if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port + { + Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); + while (1) + ; + } + + // Uncomment the next line if you need to completely reset your module + //myGNSS.factoryDefault(); delay(5000); // Reset everything and wait while the module restarts + + myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR + + Serial.println("Compare Unix Epoch given with reference one from https://www.epochconverter.com/"); + +} + +void loop() +{ + //Query module only every second. Doing it more often will just cause I2C traffic. + //The module only responds when a new position is available + if (millis() - lastTime > 1000) + { + lastTime = millis(); //Update the timer + + // getUnixEpoch marks the PVT data as stale so you will get Unix time and PVT time on alternate seconds + + uint32_t us; //microseconds returned by getUnixEpoch() + uint32_t epoch = myGNSS.getUnixEpoch(us); + Serial.print("Unix Epoch: "); + Serial.print(epoch, DEC); + Serial.print(" micros: "); + Serial.println(us, DEC); + + Serial.print(myGNSS.getYear()); + Serial.print("-"); + Serial.print(myGNSS.getMonth()); + Serial.print("-"); + Serial.print(myGNSS.getDay()); + Serial.print(" "); + Serial.print(myGNSS.getHour()); + Serial.print(":"); + Serial.print(myGNSS.getMinute()); + Serial.print(":"); + Serial.print(myGNSS.getSecond()); + + Serial.print(" Time is "); + if (myGNSS.getTimeValid() == false) + { + Serial.print("not "); + } + Serial.print("valid "); + if (myGNSS.getConfirmedTime() == false) + { + Serial.print("but not "); + } else { + Serial.print("and "); + } + Serial.print("confirmed"); + + byte SIV = myGNSS.getSIV(); + Serial.print(F(" SIV: ")); + Serial.println(SIV); + } +} diff --git a/examples/Example25_MeasurementAndNavigationRate/Example25_MeasurementAndNavigationRate.ino b/examples/Example25_MeasurementAndNavigationRate/Example25_MeasurementAndNavigationRate.ino new file mode 100644 index 0000000..c16f6ed --- /dev/null +++ b/examples/Example25_MeasurementAndNavigationRate/Example25_MeasurementAndNavigationRate.ino @@ -0,0 +1,123 @@ +/* + Demonstrate get/setMeasurementRate and get/setNavigationRate + By: Paul Clark + SparkFun Electronics + Date: March 30th, 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 slow down the measurement and navigation rates. + This should run on any GNSS module but has only been tested on the ZED_F9P and ZOE_M8Q. + + 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 BlackBoard + 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 //http://librarymanager/All#SparkFun_u-blox_GNSS +SFE_UBLOX_GNSS myGNSS; + +unsigned long lastTime = 0; //Simple local timer. Used to calc the message interval. + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun u-blox Example"); + + Wire.begin(); + + //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial + + if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port + { + Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + // Uncomment the next line if you need to completely reset your module + //myGNSS.factoryDefault(); delay(5000); // Reset everything and wait while the module restarts + + myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + + // Begin by printing the current measurement rate and navigation rate + + uint16_t rate = myGNSS.getMeasurementRate(); //Get the measurement rate of this module + Serial.print("Current measurement interval (ms): "); + Serial.println(rate); + + rate = myGNSS.getNavigationRate(); //Get the navigation rate of this module + Serial.print("Current navigation ratio (cycles): "); + Serial.println(rate); + + // The measurement rate is the elapsed time between GNSS measurements, which defines the rate + // e.g. 100 ms => 10 Hz, 1000 ms => 1 Hz, 10000 ms => 0.1 Hz. + // Let's set the measurement rate (interval) to 5 seconds = 5000 milliseconds + if (myGNSS.setMeasurementRate(5000) == false) + { + Serial.println(F("Could not set the measurement rate. Freezing.")); + while (1); + } + + // setMeasurementRate will set i2cPollingWait to a quarter of the interval + // Let's override that so we can poll the module more frequently and avoid timeouts + myGNSS.setI2CpollingWait(25); // Set i2cPollingWait to 25ms + + // The navigation rate is the ratio between the number of measurements and the number of navigation solutions + // e.g. 5 means five measurements for every navigation solution. Maximum value is 127 + // Let's set the navigation rate (ratio) to 12 to produce a solution every minute + if (myGNSS.setNavigationRate(12) == false) + { + Serial.println(F("Could not set the navigation rate. Freezing.")); + while (1); + } + + // Another trick we can use is to mark the CFG RATE data as stale so we can be sure we read fresh data + myGNSS.packetUBXCFGRATE->moduleQueried.moduleQueried.all = 0; // Mark all of the CFG RATE data as stale + + // Read and print the updated measurement rate and navigation rate + + rate = myGNSS.getMeasurementRate(); //Get the measurement rate of this module + Serial.print("New measurement interval (ms): "); + Serial.println(rate); + + rate = myGNSS.getNavigationRate(); //Get the navigation rate of this module + Serial.print("New navigation ratio (cycles): "); + Serial.println(rate); + + lastTime = millis(); +} + +void loop() +{ + // i2cPollingWait will prevent us from thrashing the I2C bus + + if (myGNSS.getPVT()) //Check for new Position, Velocity, Time data. getPVT returns true if new data is available. + { + long latitude = myGNSS.getLatitude(); + Serial.print(F("Lat: ")); + Serial.print(latitude); + + long longitude = myGNSS.getLongitude(); + Serial.print(F(" Long: ")); + Serial.print(longitude); + + //Calculate the interval since the last message + Serial.print(F(" Interval: ")); + Serial.print(((float)(millis() - lastTime)) / 1000.0, 2); + Serial.print(F("s")); + + Serial.println(); + + lastTime = millis(); //Update lastTime + } +} diff --git a/keywords.txt b/keywords.txt index e277b18..3a24b76 100644 --- a/keywords.txt +++ b/keywords.txt @@ -84,6 +84,8 @@ setFileBufferSize KEYWORD2 extractFileBufferData KEYWORD2 fileBufferAvailable KEYWORD2 getMaxFileBufferAvail KEYWORD2 +clearFileBuffer KEYWORD2 +clearMaxFileBufferAvail KEYWORD2 getPortSettings KEYWORD2 setPortOutput KEYWORD2 @@ -369,6 +371,10 @@ logHNRPVT KEYWORD2 setNavigationFrequency KEYWORD2 getNavigationFrequency KEYWORD2 +setMeasurementRate KEYWORD2 +getMeasurementRate KEYWORD2 +setNavigationRate KEYWORD2 +getNavigationRate KEYWORD2 getGeometricDOP KEYWORD2 getPositionDOP KEYWORD2 @@ -391,8 +397,11 @@ getMinute KEYWORD2 getSecond KEYWORD2 getMillisecond KEYWORD2 getNanosecond KEYWORD2 +getUnixEpoch KEYWORD2 getDateValid KEYWORD2 getTimeValid KEYWORD2 +getConfirmedDate KEYWORD2 +getConfirmedTime KEYWORD2 getFixType KEYWORD2 getGnssFixOk KEYWORD2 getDiffSoln KEYWORD2 @@ -602,3 +611,5 @@ SFE_UBLOX_GNSS_ID_BEIDOU LITERAL1 SFE_UBLOX_GNSS_ID_IMES LITERAL1 SFE_UBLOX_GNSS_ID_QZSS LITERAL1 SFE_UBLOX_GNSS_ID_GLONASS LITERAL1 + +DAYS_SINCE_MONTH LITERAL1 diff --git a/library.properties b/library.properties index abda2e9..41b6fc5 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.0.3 +version=2.0.4 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C and Serial 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 aaa1f11..4d5b20f 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -3055,6 +3055,20 @@ uint16_t SFE_UBLOX_GNSS::getMaxFileBufferAvail(void) return (fileBufferMaxAvail); } +// Clear the file buffer - discard all contents +void SFE_UBLOX_GNSS::clearFileBuffer(void) +{ + if (fileBufferSize == 0) // Bail if the user has not called setFileBufferSize (probably redundant) + return; + fileBufferTail = fileBufferHead; +} + +// Reset fileBufferMaxAvail +void SFE_UBLOX_GNSS::clearMaxFileBufferAvail(void) +{ + fileBufferMaxAvail = 0; +} + // PRIVATE: Create the file buffer. Called by .begin boolean SFE_UBLOX_GNSS::createFileBuffer(void) { @@ -8569,7 +8583,7 @@ boolean SFE_UBLOX_GNSS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait //Adjust the I2C polling timeout based on update rate i2cPollingWait = 1000 / (((int)navFreq) * 4); //This is the number of ms to wait between checks for new I2C data - //Query the module for the latest lat/long + //Query the module packetCfg.cls = UBX_CLASS_CFG; packetCfg.id = UBX_CFG_RATE; packetCfg.len = 0; @@ -8606,6 +8620,79 @@ uint8_t SFE_UBLOX_GNSS::getNavigationFrequency(uint16_t maxWait) return (measurementRate); } +//Set the elapsed time between GNSS measurements in milliseconds, which defines the rate +boolean SFE_UBLOX_GNSS::setMeasurementRate(uint16_t rate, uint16_t maxWait) +{ + //Adjust the I2C polling timeout based on update rate + i2cPollingWait = rate / 4; //This is the number of ms to wait between checks for new I2C data + + //Query the module + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_RATE; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + //This will load the payloadCfg array with current settings of the given register + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return (false); //If command send fails then bail + + //payloadCfg is now loaded with current bytes. Change only the ones we need to + payloadCfg[0] = rate & 0xFF; //measRate LSB + payloadCfg[1] = rate >> 8; //measRate MSB + + return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK +} + +//Return the elapsed time between GNSS measurements in milliseconds, which defines the rate +uint16_t SFE_UBLOX_GNSS::getMeasurementRate(uint16_t maxWait) +{ + if (packetUBXCFGRATE == NULL) initPacketUBXCFGRATE(); //Check that RAM has been allocated for the RATE data + if (packetUBXCFGRATE == NULL) //Bail if the RAM allocation failed + return 0; + + if (packetUBXCFGRATE->moduleQueried.moduleQueried.bits.measRate == false) + getNavigationFrequencyInternal(maxWait); + packetUBXCFGRATE->moduleQueried.moduleQueried.bits.measRate = false; //Since we are about to give this to user, mark this data as stale + packetUBXCFGRATE->moduleQueried.moduleQueried.bits.all = false; + + return (packetUBXCFGRATE->data.measRate); +} + +//Set the ratio between the number of measurements and the number of navigation solutions. Unit is cycles. Max is 127. +boolean SFE_UBLOX_GNSS::setNavigationRate(uint16_t rate, uint16_t maxWait) +{ + //Query the module + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_RATE; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + //This will load the payloadCfg array with current settings of the given register + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return (false); //If command send fails then bail + + //payloadCfg is now loaded with current bytes. Change only the ones we need to + payloadCfg[2] = rate & 0xFF; //navRate LSB + payloadCfg[3] = rate >> 8; //navRate MSB + + return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK +} + +//Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles +uint16_t SFE_UBLOX_GNSS::getNavigationRate(uint16_t maxWait) +{ + if (packetUBXCFGRATE == NULL) initPacketUBXCFGRATE(); //Check that RAM has been allocated for the RATE data + if (packetUBXCFGRATE == NULL) //Bail if the RAM allocation failed + return 0; + + if (packetUBXCFGRATE->moduleQueried.moduleQueried.bits.navRate == false) + getNavigationFrequencyInternal(maxWait); + packetUBXCFGRATE->moduleQueried.moduleQueried.bits.navRate = false; //Since we are about to give this to user, mark this data as stale + packetUBXCFGRATE->moduleQueried.moduleQueried.bits.all = false; + + return (packetUBXCFGRATE->data.navRate); +} + // ***** DOP Helper Functions uint16_t SFE_UBLOX_GNSS::getGeometricDOP(uint16_t maxWait) @@ -8867,6 +8954,45 @@ int32_t SFE_UBLOX_GNSS::getNanosecond(uint16_t maxWait) return (packetUBXNAVPVT->data.nano); } +//Get the current Unix epoch - includes microseconds +uint32_t SFE_UBLOX_GNSS::getUnixEpoch(uint32_t& microsecond, uint16_t maxWait) +{ + if (packetUBXNAVPVT == NULL) initPacketUBXNAVPVT(); //Check that RAM has been allocated for the PVT data + if (packetUBXNAVPVT == NULL) //Bail if the RAM allocation failed + return 0; + + if (packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.confirmedTime == false) + getPVT(maxWait); + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.confirmedTime = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.year = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.month = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.day = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.hour = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.min = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.sec = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.nano = false; + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.all = false; + uint32_t t = 0; + if((bool)packetUBXNAVPVT->data.flags2.bits.confirmedTime) + { + // assemble time elements into time_t - credits to Thomas Roell @ https://github.com/GrumpyOldPizza + t = (uint32_t)(((((((packetUBXNAVPVT->data.year - 1970) * 365) + (((packetUBXNAVPVT->data.year - 1970) + 3) / 4)) + + DAYS_SINCE_MONTH[(packetUBXNAVPVT->data.year - 1970) & 3][packetUBXNAVPVT->data.month] + + (packetUBXNAVPVT->data.day - 1)) * 24 + + packetUBXNAVPVT->data.hour) * 60 + + packetUBXNAVPVT->data.min) * 60 + + packetUBXNAVPVT->data.sec); + int32_t us = packetUBXNAVPVT->data.nano / 1000; + microsecond = (uint32_t)us; + // adjust t if nano is negative + if(us < 0) { + microsecond = (uint32_t)(us + 1000000); + t--; + } + } + return t; +} + //Get the current date validity bool SFE_UBLOX_GNSS::getDateValid(uint16_t maxWait) { @@ -8895,6 +9021,34 @@ bool SFE_UBLOX_GNSS::getTimeValid(uint16_t maxWait) return ((bool)packetUBXNAVPVT->data.valid.bits.validTime); } +//Get the confirmed date validity +bool SFE_UBLOX_GNSS:: getConfirmedDate(uint16_t maxWait) +{ + if (packetUBXNAVPVT == NULL) initPacketUBXNAVPVT(); //Check that RAM has been allocated for the PVT data + if (packetUBXNAVPVT == NULL) //Bail if the RAM allocation failed + return (false); + + if (packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.confirmedDate == false) + getPVT(maxWait); + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.confirmedDate = false; //Since we are about to give this to user, mark this data as stale + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.all = false; + return ((bool)packetUBXNAVPVT->data.flags2.bits.confirmedDate); +} + +//Get the confirmed time validity +bool SFE_UBLOX_GNSS:: getConfirmedTime(uint16_t maxWait) +{ + if (packetUBXNAVPVT == NULL) initPacketUBXNAVPVT(); //Check that RAM has been allocated for the PVT data + if (packetUBXNAVPVT == NULL) //Bail if the RAM allocation failed + return (false); + + if (packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.confirmedTime == false) + getPVT(maxWait); + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.confirmedTime = false; //Since we are about to give this to user, mark this data as stale + packetUBXNAVPVT->moduleQueried.moduleQueried1.bits.all = false; + return ((bool)packetUBXNAVPVT->data.flags2.bits.confirmedTime); +} + //Get the current fix type //0=no fix, 1=dead reckoning, 2=2D, 3=3D, 4=GNSS, 5=Time fix uint8_t SFE_UBLOX_GNSS::getFixType(uint16_t maxWait) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index df2bf69..a534530 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -454,6 +454,14 @@ typedef struct bool moduleQueried; } moduleSWVersion_t; +const uint16_t DAYS_SINCE_MONTH[4][16] = +{ + { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 335, 335, 335 }, + { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 334, 334, 334 }, + { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 334, 334, 334 }, + { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 334, 334, 334 }, +}; + class SFE_UBLOX_GNSS { public: @@ -557,8 +565,10 @@ class SFE_UBLOX_GNSS // Support for data logging void setFileBufferSize(uint16_t bufferSize); // Set the size of the file buffer. This must be called _before_ .begin. uint16_t extractFileBufferData(uint8_t *destination, uint16_t numBytes); // Extract numBytes of data from the file buffer. Copy it to destination. It is the user's responsibility to ensure destination is large enough. - uint16_t fileBufferAvailable(void); // Returns the number of bytes available in file buffer which are waiting to be read - uint16_t getMaxFileBufferAvail(void); // Returns the maximum number of bytes which the file buffer has contained. Handy for checking the buffer is large enough to handle all the incoming data. + uint16_t fileBufferAvailable(void); // Returns the number of bytes available in file buffer which are waiting to be read + uint16_t getMaxFileBufferAvail(void); // Returns the maximum number of bytes which the file buffer has contained. Handy for checking the buffer is large enough to handle all the incoming data. + void clearFileBuffer(void); // Empty the file buffer - discard all contents + void clearMaxFileBufferAvail(void); // Reset fileBufferMaxAvail // Specific commands @@ -686,7 +696,7 @@ class SFE_UBLOX_GNSS boolean getNAVPOSECEF(uint16_t maxWait = defaultMaxWait); // NAV POSECEF boolean setAutoNAVPOSECEF(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic POSECEF reports at the navigation frequency - boolean setAutoNAVPOSECEF(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic POSECEF reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVPOSECEF(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic POSECEF reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVPOSECEFcallback(void (*callbackPointer)(UBX_NAV_POSECEF_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic POSECEF reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVPOSECEF(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and POSECEF is send cyclically already void flushNAVPOSECEF(); //Mark all the data as read/stale @@ -694,24 +704,24 @@ class SFE_UBLOX_GNSS boolean getNAVSTATUS(uint16_t maxWait = defaultMaxWait); // NAV STATUS boolean setAutoNAVSTATUS(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic STATUS reports at the navigation frequency - boolean setAutoNAVSTATUS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic STATUS reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVSTATUS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic STATUS reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVSTATUScallback(void (*callbackPointer)(UBX_NAV_STATUS_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic STATUS reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVSTATUS(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and STATUS is send cyclically already void flushNAVSTATUS(); //Mark all the data as read/stale void logNAVSTATUS(boolean enabled = true); // Log data to file buffer boolean getDOP(uint16_t maxWait = defaultMaxWait); //Query module for latest dilution of precision values and load global vars:. If autoDOP is disabled, performs an explicit poll and waits, if enabled does not block. Returns true if new DOP is available. - boolean setAutoDOP(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic DOP reports at the navigation frequency - boolean setAutoDOP(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic DOP reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoDOP(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic DOP reports at the navigation frequency + boolean setAutoDOP(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic DOP reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoDOPcallback(void (*callbackPointer)(UBX_NAV_DOP_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic DOP reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoDOP(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and DOP is send cyclically already - void flushDOP(); //Mark all the DOP data as read/stale + void flushDOP(); //Mark all the DOP data as read/stale void logNAVDOP(boolean enabled = true); // Log data to file buffer boolean getVehAtt(uint16_t maxWait = defaultMaxWait); // NAV ATT Helper boolean getNAVATT(uint16_t maxWait = defaultMaxWait); // NAV ATT boolean setAutoNAVATT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic vehicle attitude reports at the navigation frequency - boolean setAutoNAVATT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic vehicle attitude reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVATT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic vehicle attitude reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVATTcallback(void (*callbackPointer)(UBX_NAV_ATT_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic ATT reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVATT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and vehicle attitude is send cyclically already void flushNAVATT(); //Mark all the data as read/stale @@ -727,7 +737,7 @@ class SFE_UBLOX_GNSS boolean getNAVODO(uint16_t maxWait = defaultMaxWait); // NAV ODO boolean setAutoNAVODO(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ODO reports at the navigation frequency - boolean setAutoNAVODO(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ODO reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVODO(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ODO reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVODOcallback(void (*callbackPointer)(UBX_NAV_ODO_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic ODO reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVODO(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and ODO is send cyclically already void flushNAVODO(); //Mark all the data as read/stale @@ -735,7 +745,7 @@ class SFE_UBLOX_GNSS boolean getNAVVELECEF(uint16_t maxWait = defaultMaxWait); // NAV VELECEF boolean setAutoNAVVELECEF(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic VELECEF reports at the navigation frequency - boolean setAutoNAVVELECEF(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic VELECEF reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVVELECEF(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic VELECEF reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVVELECEFcallback(void (*callbackPointer)(UBX_NAV_VELECEF_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic VELECEF reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVVELECEF(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and VELECEF is send cyclically already void flushNAVVELECEF(); //Mark all the data as read/stale @@ -743,7 +753,7 @@ class SFE_UBLOX_GNSS boolean getNAVVELNED(uint16_t maxWait = defaultMaxWait); // NAV VELNED boolean setAutoNAVVELNED(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic VELNED reports at the navigation frequency - boolean setAutoNAVVELNED(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic VELNED reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVVELNED(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic VELNED reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVVELNEDcallback(void (*callbackPointer)(UBX_NAV_VELNED_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic VELNED reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVVELNED(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and VELNED is send cyclically already void flushNAVVELNED(); //Mark all the data as read/stale @@ -751,7 +761,7 @@ class SFE_UBLOX_GNSS boolean getNAVHPPOSECEF(uint16_t maxWait = defaultMaxWait); // NAV HPPOSECEF boolean setAutoNAVHPPOSECEF(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HPPOSECEF reports at the navigation frequency - boolean setAutoNAVHPPOSECEF(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HPPOSECEF reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVHPPOSECEF(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HPPOSECEF reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVHPPOSECEFcallback(void (*callbackPointer)(UBX_NAV_HPPOSECEF_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic HPPOSECEF reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVHPPOSECEF(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and HPPOSECEF is send cyclically already void flushNAVHPPOSECEF(); //Mark all the data as read/stale @@ -767,7 +777,7 @@ class SFE_UBLOX_GNSS boolean getNAVCLOCK(uint16_t maxWait = defaultMaxWait); // NAV CLOCK boolean setAutoNAVCLOCK(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic clock reports at the navigation frequency - boolean setAutoNAVCLOCK(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic clock reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoNAVCLOCK(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic clock reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoNAVCLOCKcallback(void (*callbackPointer)(UBX_NAV_CLOCK_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic CLOCK reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoNAVCLOCK(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and clock is send cyclically already void flushNAVCLOCK(); //Mark all the data as read/stale @@ -778,7 +788,7 @@ class SFE_UBLOX_GNSS boolean getRELPOSNED(uint16_t maxWait = defaultMaxWait); //Get Relative Positioning Information of the NED frame boolean setAutoRELPOSNED(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic RELPOSNED reports - boolean setAutoRELPOSNED(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic RELPOSNED, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoRELPOSNED(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic RELPOSNED, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoRELPOSNEDcallback(void (*callbackPointer)(UBX_NAV_RELPOSNED_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic RELPOSNED reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoRELPOSNED(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and RELPOSNED is send cyclically already void flushNAVRELPOSNED(); //Mark all the data as read/stale @@ -822,7 +832,7 @@ class SFE_UBLOX_GNSS boolean getEsfAlignment(uint16_t maxWait = defaultMaxWait); // ESF ALG Helper boolean getESFALG(uint16_t maxWait = defaultMaxWait); // ESF ALG boolean setAutoESFALG(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF ALG reports - boolean setAutoESFALG(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF ALG reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoESFALG(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF ALG reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoESFALGcallback(void (*callbackPointer)(UBX_ESF_ALG_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic ALG reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoESFALG(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and ESF ALG is send cyclically already void flushESFALG(); //Mark all the data as read/stale @@ -831,7 +841,7 @@ class SFE_UBLOX_GNSS boolean getEsfInfo(uint16_t maxWait = defaultMaxWait); // ESF STATUS Helper boolean getESFSTATUS(uint16_t maxWait = defaultMaxWait); // ESF STATUS boolean setAutoESFSTATUS(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF STATUS reports - boolean setAutoESFSTATUS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF STATUS reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoESFSTATUS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF STATUS reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoESFSTATUScallback(void (*callbackPointer)(UBX_ESF_STATUS_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic STATUS reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoESFSTATUS(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and ESF STATUS is send cyclically already void flushESFSTATUS(); //Mark all the data as read/stale @@ -840,7 +850,7 @@ class SFE_UBLOX_GNSS boolean getEsfIns(uint16_t maxWait = defaultMaxWait); // ESF INS Helper boolean getESFINS(uint16_t maxWait = defaultMaxWait); // ESF INS boolean setAutoESFINS(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF INS reports - boolean setAutoESFINS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF INS reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoESFINS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF INS reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoESFINScallback(void (*callbackPointer)(UBX_ESF_INS_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic INS reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoESFINS(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and ESF INS is send cyclically already void flushESFINS(); //Mark all the data as read/stale @@ -849,7 +859,7 @@ class SFE_UBLOX_GNSS boolean getEsfDataInfo(uint16_t maxWait = defaultMaxWait); // ESF MEAS Helper boolean getESFMEAS(uint16_t maxWait = defaultMaxWait); // ESF MEAS boolean setAutoESFMEAS(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF MEAS reports - boolean setAutoESFMEAS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF MEAS reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoESFMEAS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF MEAS reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoESFMEAScallback(void (*callbackPointer)(UBX_ESF_MEAS_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic MEAS reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoESFMEAS(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and ESF MEAS is send cyclically already void flushESFMEAS(); //Mark all the data as read/stale @@ -858,7 +868,7 @@ class SFE_UBLOX_GNSS boolean getEsfRawDataInfo(uint16_t maxWait = defaultMaxWait); // ESF RAW Helper boolean getESFRAW(uint16_t maxWait = defaultMaxWait); // ESF RAW boolean setAutoESFRAW(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF RAW reports - boolean setAutoESFRAW(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF RAW reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoESFRAW(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic ESF RAW reports, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoESFRAWcallback(void (*callbackPointer)(UBX_ESF_RAW_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic RAW reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoESFRAW(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and ESF RAW is send cyclically already void flushESFRAW(); //Mark all the data as read/stale @@ -868,8 +878,8 @@ class SFE_UBLOX_GNSS boolean getHNRAtt(uint16_t maxWait = defaultMaxWait); // HNR ATT Helper boolean getHNRATT(uint16_t maxWait = defaultMaxWait); // Returns true if the get HNR attitude is successful - boolean setAutoHNRATT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR Attitude reports at the HNR rate - boolean setAutoHNRATT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR Attitude reports at the HNR rate, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoHNRATT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR Attitude reports at the HNR rate + boolean setAutoHNRATT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR Attitude reports at the HNR rate, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoHNRATTcallback(void (*callbackPointer)(UBX_HNR_ATT_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic ATT reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoHNRATT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and HNR Attitude is send cyclically already void flushHNRATT(); //Mark all the data as read/stale @@ -877,16 +887,16 @@ class SFE_UBLOX_GNSS boolean getHNRDyn(uint16_t maxWait = defaultMaxWait); // HNR INS Helper boolean getHNRINS(uint16_t maxWait = defaultMaxWait); // Returns true if the get HNR dynamics is successful - boolean setAutoHNRINS(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR dynamics reports at the HNR rate - boolean setAutoHNRINS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR dynamics reports at the HNR rate, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoHNRINS(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR dynamics reports at the HNR rate + boolean setAutoHNRINS(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR dynamics reports at the HNR rate, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoHNRINScallback(void (*callbackPointer)(UBX_HNR_INS_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic INS reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoHNRINS(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and HNR dynamics is send cyclically already void flushHNRINS(); //Mark all the data as read/stale void logHNRINS(boolean enabled = true); // Log data to file buffer boolean getHNRPVT(uint16_t maxWait = defaultMaxWait); // Returns true if the get HNR PVT is successful - boolean setAutoHNRPVT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR PVT reports at the HNR rate - boolean setAutoHNRPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR PVT reports at the HNR rate, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update + boolean setAutoHNRPVT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR PVT reports at the HNR rate + boolean setAutoHNRPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HNR PVT reports at the HNR rate, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update boolean setAutoHNRPVTcallback(void (*callbackPointer)(UBX_HNR_PVT_data_t), uint16_t maxWait = defaultMaxWait); //Enable automatic PVT reports at the navigation frequency. Data is accessed from the callback. boolean assumeAutoHNRPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and HNR PVT is send cyclically already void flushHNRPVT(); //Mark all the data as read/stale @@ -894,18 +904,22 @@ class SFE_UBLOX_GNSS // Helper functions for CFG RATE - boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second - uint8_t getNavigationFrequency(uint16_t maxWait = defaultMaxWait); //Get the number of nav solutions sent per second currently being output by module + boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second + uint8_t getNavigationFrequency(uint16_t maxWait = defaultMaxWait); //Get the number of nav solutions sent per second currently being output by module + boolean setMeasurementRate(uint16_t rate, uint16_t maxWait = defaultMaxWait); //Set the elapsed time between GNSS measurements in milliseconds, which defines the rate + uint16_t getMeasurementRate(uint16_t maxWait = defaultMaxWait); //Return the elapsed time between GNSS measurements in milliseconds + boolean setNavigationRate(uint16_t rate, uint16_t maxWait = defaultMaxWait); //Set the ratio between the number of measurements and the number of navigation solutions. Unit is cycles. Max is 127 + uint16_t getNavigationRate(uint16_t maxWait = defaultMaxWait); //Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles // Helper functions for DOP - uint16_t getGeometricDOP(uint16_t maxWait = defaultMaxWait); - uint16_t getPositionDOP(uint16_t maxWait = defaultMaxWait); - uint16_t getTimeDOP(uint16_t maxWait = defaultMaxWait); - uint16_t getVerticalDOP(uint16_t maxWait = defaultMaxWait); - uint16_t getHorizontalDOP(uint16_t maxWait = defaultMaxWait); - uint16_t getNorthingDOP(uint16_t maxWait = defaultMaxWait); - uint16_t getEastingDOP(uint16_t maxWait = defaultMaxWait); + uint16_t getGeometricDOP(uint16_t maxWait = defaultMaxWait); + uint16_t getPositionDOP(uint16_t maxWait = defaultMaxWait); + uint16_t getTimeDOP(uint16_t maxWait = defaultMaxWait); + uint16_t getVerticalDOP(uint16_t maxWait = defaultMaxWait); + uint16_t getHorizontalDOP(uint16_t maxWait = defaultMaxWait); + uint16_t getNorthingDOP(uint16_t maxWait = defaultMaxWait); + uint16_t getEastingDOP(uint16_t maxWait = defaultMaxWait); // Helper functions for ATT @@ -924,9 +938,12 @@ class SFE_UBLOX_GNSS uint8_t getSecond(uint16_t maxWait = defaultMaxWait); uint16_t getMillisecond(uint16_t maxWait = defaultMaxWait); int32_t getNanosecond(uint16_t maxWait = defaultMaxWait); + uint32_t getUnixEpoch(uint32_t& microsecond, uint16_t maxWait = defaultMaxWait); bool getDateValid(uint16_t maxWait = defaultMaxWait); bool getTimeValid(uint16_t maxWait = defaultMaxWait); + bool getConfirmedDate(uint16_t maxWait = defaultMaxWait); + bool getConfirmedTime(uint16_t maxWait = defaultMaxWait); uint8_t getFixType(uint16_t maxWait = defaultMaxWait); //Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning @@ -1164,7 +1181,7 @@ class SFE_UBLOX_GNSS //Limit checking of new data to every X ms //If we are expecting an update every X Hz then we should check every half that amount of time //Otherwise we may block ourselves from seeing new data - uint8_t i2cPollingWait = 100; //Default to 100ms. Adjusted when user calls setNavigationFrequency() or setHNRNavigationRate() + uint8_t i2cPollingWait = 100; //Default to 100ms. Adjusted when user calls setNavigationFrequency() or setHNRNavigationRate() or setMeasurementRate() unsigned long lastCheck = 0; diff --git a/src/u-blox_structs.h b/src/u-blox_structs.h index 74cc1d3..50611bf 100644 --- a/src/u-blox_structs.h +++ b/src/u-blox_structs.h @@ -1052,7 +1052,7 @@ typedef struct uint8_t rcvTow[8]; // Measurement time of week in receiver local time [64-bit float] uint16_t week; // GPS week number int8_t leapS; // GPS leap seconds - uint8_t numMeas; // Numnber of measurements to follow + uint8_t numMeas; // Number of measurements to follow union { uint8_t all;