Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Added saveConfigSelective #78

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 2 deletions examples/Example19_DynamicModel/Example19_DynamicModel.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Set Dynamic Model
By: Paul Clark (PaulZC)
Date: December 18th, 2019
Date: March 9th, 2020

Based extensively on Example3_GetPosition
By: Nathan Seidle
Expand Down Expand Up @@ -74,7 +74,7 @@ void setup()
Serial.println("Dynamic platform model changed successfully!");
}

//myGPS.saveConfiguration(); //Uncomment this line to save the current settings to flash and BBR
//myGPS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); //Uncomment this line to save only the NAV settings to flash and BBR
}

void loop()
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ getNavigationFrequency KEYWORD2

saveConfiguration KEYWORD2
factoryDefault KEYWORD2
saveConfigSelective KEYWORD2

waitForResponse KEYWORD2

Expand Down
28 changes: 28 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const char *SFE_UBLOX_GPS::statusString(sfe_ublox_status_e stat)
void SFE_UBLOX_GPS::factoryReset()
{
// Copy default settings to permanent
// Note: this does not load the permanent configuration into the current configuration. Calling factoryDefault() will do that.
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_CFG;
packetCfg.len = 13;
Expand Down Expand Up @@ -1205,6 +1206,31 @@ boolean SFE_UBLOX_GPS::saveConfiguration(uint16_t maxWait)
packetCfg.payload[x] = 0;

packetCfg.payload[4] = 0xFF; //Set any bit in the saveMask field to save current config to Flash and BBR
packetCfg.payload[5] = 0xFF;

if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail

return (true);
}

//Save the selected configuration sub-sections to flash and BBR (battery backed RAM)
//This still works but it is the old way of configuring ublox modules. See getVal and setVal for the new methods
boolean SFE_UBLOX_GPS::saveConfigSelective(uint32_t configMask, uint16_t maxWait)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_CFG;
packetCfg.len = 12;
packetCfg.startingSpot = 0;

//Clear packet payload
for (uint8_t x = 0; x < packetCfg.len; x++)
packetCfg.payload[x] = 0;

packetCfg.payload[4] = configMask & 0xFF; //Set the appropriate bits in the saveMask field to save current config to Flash and BBR
packetCfg.payload[5] = (configMask >> 8) & 0xFF;
packetCfg.payload[6] = (configMask >> 16) & 0xFF;
packetCfg.payload[7] = (configMask >> 24) & 0xFF;

if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail
Expand All @@ -1226,7 +1252,9 @@ boolean SFE_UBLOX_GPS::factoryDefault(uint16_t maxWait)
packetCfg.payload[x] = 0;

packetCfg.payload[0] = 0xFF; //Set any bit in the clearMask field to clear saved config
packetCfg.payload[1] = 0xFF;
packetCfg.payload[8] = 0xFF; //Set any bit in the loadMask field to discard current config and rebuild from lower non-volatile memory layers
packetCfg.payload[9] = 0xFF;

if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail
Expand Down
13 changes: 13 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ const uint8_t VAL_GROUP_I2C_SIZE = VAL_SIZE_8; //All fields in I2C group are cur

const uint8_t VAL_ID_I2C_ADDRESS = 0x01;

// Configuration Sub-Section mask definitions for saveConfigSelective (UBX-CFG-CFG)
const uint32_t VAL_CFG_SUBSEC_IOPORT = 0x00000001; // ioPort - communications port settings (causes IO system reset!)
const uint32_t VAL_CFG_SUBSEC_MSGCONF = 0x00000002; // msgConf - message configuration
const uint32_t VAL_CFG_SUBSEC_INFMSG = 0x00000004; // infMsg - INF message configuration
const uint32_t VAL_CFG_SUBSEC_NAVCONF = 0x00000008; // navConf - navigation configuration
const uint32_t VAL_CFG_SUBSEC_RXMCONF = 0x00000010; // rxmConf - receiver manager configuration
const uint32_t VAL_CFG_SUBSEC_SENCONF = 0x00000100; // senConf - sensor interface configuration (requires protocol 19+)
const uint32_t VAL_CFG_SUBSEC_RINVCONF = 0x00000200; // rinvConf - remove inventory configuration
const uint32_t VAL_CFG_SUBSEC_ANTCONF = 0x00000400; // antConf - antenna configuration
const uint32_t VAL_CFG_SUBSEC_LOGCONF = 0x00000800; // logConf - logging configuration
const uint32_t VAL_CFG_SUBSEC_FTSCONF = 0x00001000; // ftsConf - FTS configuration (FTS products only)

enum dynModel // Possible values for the dynamic platform model, which provide more accuract position output for the situation. Description extracted from ZED-F9P Integration Manual
{
DYN_MODEL_PORTABLE = 0, //Applications with low acceleration, e.g. portable devices. Suitable for most situations.
Expand Down Expand Up @@ -446,6 +458,7 @@ class SFE_UBLOX_GPS
uint8_t getNavigationFrequency(uint16_t maxWait = 250); //Get the number of nav solutions sent per second currently being output by module
boolean saveConfiguration(uint16_t maxWait = 250); //Save current configuration to flash and BBR (battery backed RAM)
boolean factoryDefault(uint16_t maxWait = 250); //Reset module to factory defaults
boolean saveConfigSelective(uint32_t configMask, uint16_t maxWait = 250); //Save the selected configuration sub-sections to flash and BBR (battery backed RAM)

sfe_ublox_status_e waitForACKResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = 250); //Poll the module until a config packet and an ACK is received
sfe_ublox_status_e waitForNoACKResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = 250); //Poll the module until a config packet is received
Expand Down