Skip to content

Commit 94f7db5

Browse files
authored
Merge pull request sparkfun#78 from PaulZC/PaulZC_saveConfigSelective
Added saveConfigSelective
2 parents dbf4658 + 8e214f9 commit 94f7db5

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

examples/Example19_DynamicModel/Example19_DynamicModel.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Set Dynamic Model
33
By: Paul Clark (PaulZC)
4-
Date: December 18th, 2019
4+
Date: March 9th, 2020
55
66
Based extensively on Example3_GetPosition
77
By: Nathan Seidle
@@ -74,7 +74,7 @@ void setup()
7474
Serial.println("Dynamic platform model changed successfully!");
7575
}
7676

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

8080
void loop()

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ getNavigationFrequency KEYWORD2
3737

3838
saveConfiguration KEYWORD2
3939
factoryDefault KEYWORD2
40+
saveConfigSelective KEYWORD2
4041

4142
waitForResponse KEYWORD2
4243

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ const char *SFE_UBLOX_GPS::statusString(sfe_ublox_status_e stat)
164164
void SFE_UBLOX_GPS::factoryReset()
165165
{
166166
// Copy default settings to permanent
167+
// Note: this does not load the permanent configuration into the current configuration. Calling factoryDefault() will do that.
167168
packetCfg.cls = UBX_CLASS_CFG;
168169
packetCfg.id = UBX_CFG_CFG;
169170
packetCfg.len = 13;
@@ -1205,6 +1206,31 @@ boolean SFE_UBLOX_GPS::saveConfiguration(uint16_t maxWait)
12051206
packetCfg.payload[x] = 0;
12061207

12071208
packetCfg.payload[4] = 0xFF; //Set any bit in the saveMask field to save current config to Flash and BBR
1209+
packetCfg.payload[5] = 0xFF;
1210+
1211+
if (sendCommand(packetCfg, maxWait) == false)
1212+
return (false); //If command send fails then bail
1213+
1214+
return (true);
1215+
}
1216+
1217+
//Save the selected configuration sub-sections to flash and BBR (battery backed RAM)
1218+
//This still works but it is the old way of configuring ublox modules. See getVal and setVal for the new methods
1219+
boolean SFE_UBLOX_GPS::saveConfigSelective(uint32_t configMask, uint16_t maxWait)
1220+
{
1221+
packetCfg.cls = UBX_CLASS_CFG;
1222+
packetCfg.id = UBX_CFG_CFG;
1223+
packetCfg.len = 12;
1224+
packetCfg.startingSpot = 0;
1225+
1226+
//Clear packet payload
1227+
for (uint8_t x = 0; x < packetCfg.len; x++)
1228+
packetCfg.payload[x] = 0;
1229+
1230+
packetCfg.payload[4] = configMask & 0xFF; //Set the appropriate bits in the saveMask field to save current config to Flash and BBR
1231+
packetCfg.payload[5] = (configMask >> 8) & 0xFF;
1232+
packetCfg.payload[6] = (configMask >> 16) & 0xFF;
1233+
packetCfg.payload[7] = (configMask >> 24) & 0xFF;
12081234

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

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

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

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,18 @@ const uint8_t VAL_GROUP_I2C_SIZE = VAL_SIZE_8; //All fields in I2C group are cur
350350

351351
const uint8_t VAL_ID_I2C_ADDRESS = 0x01;
352352

353+
// Configuration Sub-Section mask definitions for saveConfigSelective (UBX-CFG-CFG)
354+
const uint32_t VAL_CFG_SUBSEC_IOPORT = 0x00000001; // ioPort - communications port settings (causes IO system reset!)
355+
const uint32_t VAL_CFG_SUBSEC_MSGCONF = 0x00000002; // msgConf - message configuration
356+
const uint32_t VAL_CFG_SUBSEC_INFMSG = 0x00000004; // infMsg - INF message configuration
357+
const uint32_t VAL_CFG_SUBSEC_NAVCONF = 0x00000008; // navConf - navigation configuration
358+
const uint32_t VAL_CFG_SUBSEC_RXMCONF = 0x00000010; // rxmConf - receiver manager configuration
359+
const uint32_t VAL_CFG_SUBSEC_SENCONF = 0x00000100; // senConf - sensor interface configuration (requires protocol 19+)
360+
const uint32_t VAL_CFG_SUBSEC_RINVCONF = 0x00000200; // rinvConf - remove inventory configuration
361+
const uint32_t VAL_CFG_SUBSEC_ANTCONF = 0x00000400; // antConf - antenna configuration
362+
const uint32_t VAL_CFG_SUBSEC_LOGCONF = 0x00000800; // logConf - logging configuration
363+
const uint32_t VAL_CFG_SUBSEC_FTSCONF = 0x00001000; // ftsConf - FTS configuration (FTS products only)
364+
353365
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
354366
{
355367
DYN_MODEL_PORTABLE = 0, //Applications with low acceleration, e.g. portable devices. Suitable for most situations.
@@ -446,6 +458,7 @@ class SFE_UBLOX_GPS
446458
uint8_t getNavigationFrequency(uint16_t maxWait = 250); //Get the number of nav solutions sent per second currently being output by module
447459
boolean saveConfiguration(uint16_t maxWait = 250); //Save current configuration to flash and BBR (battery backed RAM)
448460
boolean factoryDefault(uint16_t maxWait = 250); //Reset module to factory defaults
461+
boolean saveConfigSelective(uint32_t configMask, uint16_t maxWait = 250); //Save the selected configuration sub-sections to flash and BBR (battery backed RAM)
449462

450463
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
451464
sfe_ublox_status_e waitForNoACKResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = 250); //Poll the module until a config packet is received

0 commit comments

Comments
 (0)