minimize radioconfig file writes

1.2-legacy
Kevin Hester 2021-03-11 18:29:47 +08:00
rodzic 76e2c39c63
commit a97c2ae6eb
4 zmienionych plików z 23 dodań i 12 usunięć

Wyświetl plik

@ -104,7 +104,7 @@ bool MeshService::reloadConfig()
// This will also update the region as needed
bool didReset = nodeDB.resetRadioConfig(); // Don't let the phone send us fatally bad settings
configChanged.notifyObservers(NULL);
configChanged.notifyObservers(NULL); // This will cause radio hardware to change freqs etc
nodeDB.saveToDisk();
return didReset;

Wyświetl plik

@ -359,6 +359,16 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
return okay;
}
void NodeDB::saveChannelsToDisk()
{
if (!devicestate.no_save) {
#ifdef FS
FS.mkdir("/prefs");
#endif
saveProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
}
}
void NodeDB::saveToDisk()
{
if (!devicestate.no_save) {
@ -367,7 +377,7 @@ void NodeDB::saveToDisk()
#endif
bool okay = saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
okay &= saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
okay &= saveProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
saveChannelsToDisk();
// remove any pre 1.2 pref files, turn on after 1.2 is in beta
// if(okay) FS.remove(preffileOld);

Wyświetl plik

@ -43,7 +43,7 @@ class NodeDB
void init();
/// write to flash
void saveToDisk();
void saveToDisk(), saveChannelsToDisk();
/** Reinit radio config if needed, because either:
* a) sometimes a buggy android app might send us bogus settings or

Wyświetl plik

@ -96,21 +96,22 @@ void AdminPlugin::handleSetChannel(const Channel &cc)
{
channels.setChannel(cc);
bool didReset = service.reloadConfig();
/* FIXME - do we need this still?
if (didReset) {
state = STATE_SEND_MY_INFO; // Squirt a completely new set of configs to the client
} */
// Just update and save the channels - no need to update the radio for ! primary channel changes
if (cc.index == 0) {
// FIXME, this updates the user preferences also, which isn't needed - we really just want to notify on configChanged
service.reloadConfig();
}
else {
channels.onConfigChanged(); // tell the radios about this change
nodeDB.saveChannelsToDisk();
}
}
void AdminPlugin::handleSetRadio(const RadioConfig &r)
{
radioConfig = r;
bool didReset = service.reloadConfig();
/* FIXME - do we need this still? if (didReset) {
state = STATE_SEND_MY_INFO; // Squirt a completely new set of configs to the client
} */
service.reloadConfig();
}
MeshPacket *AdminPlugin::allocReply()