Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ powerOffWithInterrupt KEYWORD2
setDynamicModel KEYWORD2
getDynamicModel KEYWORD2

setNAV5PositionAccuracy KEYWORD2
getNAV5PositionAccuracy KEYWORD2


resetOdometer KEYWORD2
enableOdometer KEYWORD2
getOdometerConfig KEYWORD2
Expand Down
50 changes: 48 additions & 2 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 posMark, 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
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down