mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-16 10:02:05 +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:
parent
7ae8601ba5
commit
caac2ecb83
@ -143,6 +143,11 @@ bool NodeDB::resetRadioConfig()
|
|||||||
return didFactoryReset;
|
return didFactoryReset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeDB::installDefaultConfig()
|
||||||
|
{
|
||||||
|
memset(&config, 0, sizeof(config));
|
||||||
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultRadioConfig()
|
void NodeDB::installDefaultRadioConfig()
|
||||||
{
|
{
|
||||||
memset(&radioConfig, 0, sizeof(radioConfig));
|
memset(&radioConfig, 0, sizeof(radioConfig));
|
||||||
@ -281,6 +286,7 @@ void NodeDB::pickNewNodeNum()
|
|||||||
|
|
||||||
static const char *preffile = "/prefs/db.proto";
|
static const char *preffile = "/prefs/db.proto";
|
||||||
static const char *radiofile = "/prefs/radio.proto";
|
static const char *radiofile = "/prefs/radio.proto";
|
||||||
|
static const char *configfile = "/prefs/config.proto";
|
||||||
static const char *channelfile = "/prefs/channels.proto";
|
static const char *channelfile = "/prefs/channels.proto";
|
||||||
|
|
||||||
/** Load a protobuf from a file, return true for success */
|
/** 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
|
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)) {
|
if (!loadProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
||||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||||
}
|
}
|
||||||
@ -391,6 +401,7 @@ void NodeDB::saveToDisk()
|
|||||||
#endif
|
#endif
|
||||||
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
||||||
saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
|
saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
|
||||||
|
saveProto(configfile, Config_size, sizeof(Config), Config_fields, &config);
|
||||||
saveChannelsToDisk();
|
saveChannelsToDisk();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,7 +123,7 @@ class NodeDB
|
|||||||
void loadFromDisk();
|
void loadFromDisk();
|
||||||
|
|
||||||
/// Reinit device state from scratch (not loading from disk)
|
/// Reinit device state from scratch (not loading from disk)
|
||||||
void installDefaultDeviceState(), installDefaultRadioConfig(), installDefaultChannels();
|
void installDefaultDeviceState(), installDefaultRadioConfig(), installDefaultChannels(), installDefaultConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -194,3 +194,5 @@ PREF_GET(min_wake_secs, 10)
|
|||||||
*/
|
*/
|
||||||
extern uint32_t radioGeneration;
|
extern uint32_t radioGeneration;
|
||||||
|
|
||||||
|
// Config doesn't have a nanopb generated full size constant
|
||||||
|
#define Config_size (Config_DeviceConfig_size + Config_DisplayConfig_size + Config_GpsConfig_size + Config_LoRaConfig_size + Config_ModuleConfig_CannedMessageConfig_size + Config_ModuleConfig_ExternalNotificationConfig_size + Config_ModuleConfig_MQTTConfig_size + Config_ModuleConfig_RangeTestConfig_size + Config_ModuleConfig_SerialConfig_size + Config_ModuleConfig_StoreForwardConfig_size + Config_ModuleConfig_TelemetryConfig_size + Config_ModuleConfig_size + Config_PowerConfig_size)
|
Loading…
Reference in New Issue
Block a user