Skip to content

Commit

Permalink
File management changes (Part 2 - Reboot instead of reformat NRF52 af…
Browse files Browse the repository at this point in the history
…ter two failed file saves) (#3630)

* Add LoadFileState to differentiate types of success / failures

* Try rebooting NRF52s with multiple failed saves

* Trunkate
  • Loading branch information
thebentern authored Apr 15, 2024
1 parent 27ae439 commit 2f9b68e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,13 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
static uint8_t failedCounter = 0;
failedCounter++;
if (failedCounter >= 2) {
FSCom.format();
// After formatting, the device needs to be restarted
nodeDB->resetRadioConfig(true);
LOG_ERROR("Failed to save file twice. Rebooting...\n");
delay(100);
NVIC_SystemReset();
// We used to blow away the filesystem here, but that's a bit extreme
// FSCom.format();
// // After formatting, the device needs to be restarted
// nodeDB->resetRadioConfig(true);
}
#endif
}
Expand Down Expand Up @@ -734,6 +738,7 @@ void NodeDB::saveToDisk(int saveWhat)
config.has_power = true;
config.has_network = true;
config.has_bluetooth = true;

saveProto(configFileName, meshtastic_LocalConfig_size, &meshtastic_LocalConfig_msg, &config);
}

Expand All @@ -745,6 +750,12 @@ void NodeDB::saveToDisk(int saveWhat)
moduleConfig.has_serial = true;
moduleConfig.has_store_forward = true;
moduleConfig.has_telemetry = true;
moduleConfig.has_neighbor_info = true;
moduleConfig.has_detection_sensor = true;
moduleConfig.has_ambient_lighting = true;
moduleConfig.has_audio = true;
moduleConfig.has_paxcounter = true;

saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig);
}

Expand Down

0 comments on commit 2f9b68e

Please sign in to comment.