mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 02:32:23 +00:00
Compute config size and account for reloadconfig (#1428)
* Compute config size and account for reloadconfig * Reload config and config_size
This commit is contained in:
@@ -143,6 +143,11 @@ bool NodeDB::resetRadioConfig()
|
||||
return didFactoryReset;
|
||||
}
|
||||
|
||||
void NodeDB::installDefaultConfig()
|
||||
{
|
||||
memset(&config, 0, sizeof(config));
|
||||
}
|
||||
|
||||
void NodeDB::installDefaultRadioConfig()
|
||||
{
|
||||
memset(&radioConfig, 0, sizeof(radioConfig));
|
||||
@@ -281,6 +286,7 @@ void NodeDB::pickNewNodeNum()
|
||||
|
||||
static const char *preffile = "/prefs/db.proto";
|
||||
static const char *radiofile = "/prefs/radio.proto";
|
||||
static const char *configfile = "/prefs/config.proto";
|
||||
static const char *channelfile = "/prefs/channels.proto";
|
||||
|
||||
/** Load a protobuf from a file, return true for success */
|
||||
@@ -333,6 +339,10 @@ void NodeDB::loadFromDisk()
|
||||
installDefaultRadioConfig(); // Our in RAM copy might now be corrupt
|
||||
}
|
||||
|
||||
if (!loadProto(configfile, Config_size, sizeof(Config), Config_fields, &config)) {
|
||||
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
||||
}
|
||||
|
||||
if (!loadProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||
}
|
||||
@@ -391,6 +401,7 @@ void NodeDB::saveToDisk()
|
||||
#endif
|
||||
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
||||
saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
|
||||
saveProto(configfile, Config_size, sizeof(Config), Config_fields, &config);
|
||||
saveChannelsToDisk();
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user