Skip to content

Commit 5582ed9

Browse files
authored
Merge pull request #224 from cyclops1982/PositionAccuracy
Add get/setNAV5PositionAccuracy
2 parents a01eef6 + 3ff04e7 commit 5582ed9

3 files changed

+57
-2
lines changed

Diff for: keywords.txt

+4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ powerOffWithInterrupt KEYWORD2
195195
setDynamicModel KEYWORD2
196196
getDynamicModel KEYWORD2
197197

198+
setNAV5PositionAccuracy KEYWORD2
199+
getNAV5PositionAccuracy KEYWORD2
200+
201+
198202
resetOdometer KEYWORD2
199203
enableOdometer KEYWORD2
200204
getOdometerConfig KEYWORD2

Diff for: src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+48-2
Original file line numberDiff line numberDiff line change
@@ -8197,6 +8197,53 @@ bool SFE_UBLOX_GNSS::setupPowerMode(sfe_ublox_rxm_mode_e mode, uint16_t maxWait)
81978197
return sendCommand(&packetCfg, maxWait);
81988198
}
81998199

8200+
8201+
// Position Accuracy
8202+
8203+
// Change the Position Accuracy using UBX-CFG-NAV5
8204+
// Value provided in meters
8205+
bool SFE_UBLOX_GNSS::setNAV5PositionAccuracy(uint16_t metres, uint16_t maxWait)
8206+
{
8207+
packetCfg.cls = UBX_CLASS_CFG;
8208+
packetCfg.id = UBX_CFG_NAV5;
8209+
packetCfg.len = 0;
8210+
packetCfg.startingSpot = 0;
8211+
8212+
// Ask module for the current navigation model settings. Loads into payloadCfg.
8213+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8214+
return (false);
8215+
8216+
payloadCfg[0] |= 0x10; // mask: set the posMask, leave other bits unchanged
8217+
payloadCfg[18] = metres & 0xFF;
8218+
payloadCfg[19] = metres >> 8;
8219+
8220+
packetCfg.len = 36;
8221+
packetCfg.startingSpot = 0;
8222+
8223+
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
8224+
}
8225+
8226+
// Get the position accuracy using UBX-CFG-NAV5
8227+
// Returns meters. 0 if the sendCommand fails
8228+
uint16_t SFE_UBLOX_GNSS::getNAV5PositionAccuracy(uint16_t maxWait)
8229+
{
8230+
packetCfg.cls = UBX_CLASS_CFG;
8231+
packetCfg.id = UBX_CFG_NAV5;
8232+
packetCfg.len = 0;
8233+
packetCfg.startingSpot = 0;
8234+
8235+
// Ask module for the current navigation model settings. Loads into payloadCfg.
8236+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8237+
return 0;
8238+
8239+
8240+
uint16_t pAcc = ((uint16_t)payloadCfg[19]) << 8;
8241+
pAcc |= payloadCfg[18];
8242+
return (pAcc);
8243+
}
8244+
8245+
8246+
82008247
// Dynamic Platform Model
82018248

82028249
// Change the dynamic platform model using UBX-CFG-NAV5
@@ -8216,8 +8263,7 @@ bool SFE_UBLOX_GNSS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWait)
82168263
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
82178264
return (false);
82188265

8219-
payloadCfg[0] = 0x01; // mask: set only the dyn bit (0)
8220-
payloadCfg[1] = 0x00; // mask
8266+
payloadCfg[0] |= 0x01; // mask: set only the dyn bit (0)
82218267
payloadCfg[2] = newDynamicModel; // dynModel
82228268

82238269
packetCfg.len = 36;

Diff for: src/SparkFun_u-blox_GNSS_Arduino_Library.h

+5
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,11 @@ class SFE_UBLOX_GNSS
950950
bool setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = defaultMaxWait);
951951
uint8_t getDynamicModel(uint16_t maxWait = defaultMaxWait); // Get the dynamic model - returns 255 if the sendCommand fails
952952

953+
// Change the position accuracy using UBX-CFG-NAV5
954+
bool setNAV5PositionAccuracy(uint16_t metres, uint16_t maxWait = defaultMaxWait);
955+
uint16_t getNAV5PositionAccuracy(uint16_t maxWait = defaultMaxWait); // Get the position accuracy - returns 0 if the sendCommand fails
956+
957+
953958
// Reset / enable / configure the odometer
954959
bool resetOdometer(uint16_t maxWait = defaultMaxWait); // Reset the odometer
955960
bool enableOdometer(bool enable = true, uint16_t maxWait = defaultMaxWait); // Enable / disable the odometer

0 commit comments

Comments
 (0)