diff --git a/keywords.txt b/keywords.txt index 6ff142f..92afc5e 100644 --- a/keywords.txt +++ b/keywords.txt @@ -195,6 +195,9 @@ powerOffWithInterrupt KEYWORD2 setDynamicModel KEYWORD2 getDynamicModel KEYWORD2 +setNAV5PositionAccuracy KEYWORD2 +getNAV5PositionAccuracy KEYWORD2 + resetOdometer KEYWORD2 enableOdometer KEYWORD2 getOdometerConfig KEYWORD2 diff --git a/library.properties b/library.properties index 03274ff..14ab073 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.2.26 +version=2.2.27 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 a399c33..943340e 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -8197,6 +8197,53 @@ bool SFE_UBLOX_GNSS::setupPowerMode(sfe_ublox_rxm_mode_e mode, uint16_t maxWait) return sendCommand(&packetCfg, maxWait); } + +// Position Accuracy + +// Change the Position Accuracy using UBX-CFG-NAV5 +// Value provided in meters +bool SFE_UBLOX_GNSS::setNAV5PositionAccuracy(uint16_t metres, uint16_t maxWait) +{ + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_NAV5; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + // Ask module for the current navigation model settings. Loads into payloadCfg. + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return (false); + + payloadCfg[0] |= 0x10; // mask: set the posMask, leave other bits unchanged + payloadCfg[18] = metres & 0xFF; + payloadCfg[19] = metres >> 8; + + packetCfg.len = 36; + packetCfg.startingSpot = 0; + + return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK +} + +// Get the position accuracy using UBX-CFG-NAV5 +// Returns meters. 0 if the sendCommand fails +uint16_t SFE_UBLOX_GNSS::getNAV5PositionAccuracy(uint16_t maxWait) +{ + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_NAV5; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + // Ask module for the current navigation model settings. Loads into payloadCfg. + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return 0; + + + uint16_t pAcc = ((uint16_t)payloadCfg[19]) << 8; + pAcc |= payloadCfg[18]; + return (pAcc); +} + + + // Dynamic Platform Model // Change the dynamic platform model using UBX-CFG-NAV5 @@ -8216,8 +8263,7 @@ bool SFE_UBLOX_GNSS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWait) if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK return (false); - payloadCfg[0] = 0x01; // mask: set only the dyn bit (0) - payloadCfg[1] = 0x00; // mask + payloadCfg[0] |= 0x01; // mask: set only the dyn bit (0) payloadCfg[2] = newDynamicModel; // dynModel packetCfg.len = 36; diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 9f7245d..c0ac083 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -950,6 +950,10 @@ class SFE_UBLOX_GNSS bool setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = defaultMaxWait); uint8_t getDynamicModel(uint16_t maxWait = defaultMaxWait); // Get the dynamic model - returns 255 if the sendCommand fails + // Change the position accuracy using UBX-CFG-NAV5 + bool setNAV5PositionAccuracy(uint16_t metres, uint16_t maxWait = defaultMaxWait); + uint16_t getNAV5PositionAccuracy(uint16_t maxWait = defaultMaxWait); // Get the position accuracy - returns 0 if the sendCommand fails + // Reset / enable / configure the odometer bool resetOdometer(uint16_t maxWait = defaultMaxWait); // Reset the odometer bool enableOdometer(bool enable = true, uint16_t maxWait = defaultMaxWait); // Enable / disable the odometer