From a06eacaa884d207c5b1586f83303b6f2b072697c Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Thu, 30 May 2024 06:57:41 +0100 Subject: [PATCH 1/7] Add get/setNAV5PositionAccuracy --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 44 ++++++++++++++++++++ src/SparkFun_u-blox_GNSS_Arduino_Library.h | 5 +++ 2 files changed, 49 insertions(+) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index a399c33..ead6283 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -8197,6 +8197,50 @@ 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 meters, 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 only the posMark + payloadCfg[1] = 0x00; // mask + payloadCfg[18] = meters; + + 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; + + return (payloadCfg[18]); +} + + + // Dynamic Platform Model // Change the dynamic platform model using UBX-CFG-NAV5 diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 9f7245d..91dc1e8 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -950,6 +950,11 @@ 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 meters = 100, 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 From 1a3ffedda0553df54eba37c669f45a54358ef2fb Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Thu, 30 May 2024 07:54:38 +0100 Subject: [PATCH 2/7] Update keywords --- keywords.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keywords.txt b/keywords.txt index 6ff142f..c99883e 100644 --- a/keywords.txt +++ b/keywords.txt @@ -195,6 +195,10 @@ powerOffWithInterrupt KEYWORD2 setDynamicModel KEYWORD2 getDynamicModel KEYWORD2 +setNAV5PositionAccuracy KEYWORD2 +getNAV5PositionAccuracy KEYWORD2 + + resetOdometer KEYWORD2 enableOdometer KEYWORD2 getOdometerConfig KEYWORD2 From ddea7718526d9cde4b5599f2348fdbb4666bb77e Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Thu, 30 May 2024 07:57:00 +0100 Subject: [PATCH 3/7] Meters -> metres & correct setting of value --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 8 ++++---- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index ead6283..9a99574 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -8202,7 +8202,7 @@ bool SFE_UBLOX_GNSS::setupPowerMode(sfe_ublox_rxm_mode_e mode, uint16_t maxWait) // Change the Position Accuracy using UBX-CFG-NAV5 // Value provided in meters -bool SFE_UBLOX_GNSS::setNAV5PositionAccuracy(uint16_t meters, uint16_t maxWait) +bool SFE_UBLOX_GNSS::setNAV5PositionAccuracy(uint16_t metres, uint16_t maxWait) { packetCfg.cls = UBX_CLASS_CFG; packetCfg.id = UBX_CFG_NAV5; @@ -8213,9 +8213,9 @@ bool SFE_UBLOX_GNSS::setNAV5PositionAccuracy(uint16_t meters, uint16_t maxWait) if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK return (false); - payloadCfg[0] = 0x10; // mask: set only the posMark - payloadCfg[1] = 0x00; // mask - payloadCfg[18] = meters; + payloadCfg[0] |= 0x10; // mask: set the posMark, leave other bits unchanged + payloadCfg[18] = metres & 0xFF; + payloadCfg[19] = metres >> 8; packetCfg.len = 36; packetCfg.startingSpot = 0; diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 91dc1e8..e2ac6eb 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -951,7 +951,7 @@ class SFE_UBLOX_GNSS 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 meters = 100, uint16_t maxWait = defaultMaxWait); + bool setNAV5PositionAccuracy(uint16_t metres = 100, uint16_t maxWait = defaultMaxWait); uint16_t getNAV5PositionAccuracy(uint16_t maxWait = defaultMaxWait); // Get the position accuracy - returns 0 if the sendCommand fails From 0e6e0a68c1fee7577f43e9a52ebf31c7af1219e1 Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Thu, 30 May 2024 07:57:41 +0100 Subject: [PATCH 4/7] Correctly return uint16 --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 9a99574..a0fedb6 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -8236,7 +8236,10 @@ uint16_t SFE_UBLOX_GNSS::getNAV5PositionAccuracy(uint16_t maxWait) if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK return 0; - return (payloadCfg[18]); + + uint16_t pAcc = ((uint16_t)payloadCfg[19]) << 8; + pAcc |= payloadCfg[18]; + return (pAcc); } From 5dc0bb5a17c1bb0021a352cd2c4beb15253b57ca Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Thu, 30 May 2024 07:57:55 +0100 Subject: [PATCH 5/7] Also update setDynamicModel --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index a0fedb6..5bc5782 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -8263,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; From 689e0635f5fbb69e797632488190125219255ef9 Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Thu, 30 May 2024 07:59:40 +0100 Subject: [PATCH 6/7] Remove default on setNAV5PositionAccuracy --- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index e2ac6eb..615da28 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -951,7 +951,7 @@ class SFE_UBLOX_GNSS 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 = 100, uint16_t maxWait = defaultMaxWait); + 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 From 3ff04e7623fbce0a132f7978f10a6ef2a377142a Mon Sep 17 00:00:00 2001 From: Ruben d'Arco Date: Thu, 30 May 2024 08:12:40 +0100 Subject: [PATCH 7/7] Typo --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 5bc5782..943340e 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -8213,7 +8213,7 @@ bool SFE_UBLOX_GNSS::setNAV5PositionAccuracy(uint16_t metres, uint16_t maxWait) if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK return (false); - payloadCfg[0] |= 0x10; // mask: set the posMark, leave other bits unchanged + payloadCfg[0] |= 0x10; // mask: set the posMask, leave other bits unchanged payloadCfg[18] = metres & 0xFF; payloadCfg[19] = metres >> 8;