diff --git a/examples/Example19_DynamicModel/Example19_DynamicModel.ino b/examples/Example19_DynamicModel/Example19_DynamicModel.ino index 0eb795b..980c2b6 100644 --- a/examples/Example19_DynamicModel/Example19_DynamicModel.ino +++ b/examples/Example19_DynamicModel/Example19_DynamicModel.ino @@ -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 @@ -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() diff --git a/keywords.txt b/keywords.txt index b99387b..d6ce26b 100644 --- a/keywords.txt +++ b/keywords.txt @@ -37,6 +37,7 @@ getNavigationFrequency KEYWORD2 saveConfiguration KEYWORD2 factoryDefault KEYWORD2 +saveConfigSelective KEYWORD2 waitForResponse KEYWORD2 diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 844e45a..03f2400 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -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; @@ -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 @@ -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 diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index f831ab8..30f28d5 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -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. @@ -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