mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-28 07:13:25 +00:00
Add FACTORY_INSTALL option to do a filesystem reset on first boot (#8185)
* Add FACTORY_INSTALL option to do a filesystem reset on first boot * Check for valid file handle before using Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
305f513834
commit
0ddaf710e4
@ -56,6 +56,10 @@
|
|||||||
#include <WiFiOTA.h>
|
#include <WiFiOTA.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// stringify
|
||||||
|
#define xstr(s) str(s)
|
||||||
|
#define str(s) #s
|
||||||
|
|
||||||
NodeDB *nodeDB = nullptr;
|
NodeDB *nodeDB = nullptr;
|
||||||
|
|
||||||
// we have plenty of ram so statically alloc this tempbuf (for now)
|
// we have plenty of ram so statically alloc this tempbuf (for now)
|
||||||
@ -1152,6 +1156,20 @@ void NodeDB::loadFromDisk()
|
|||||||
spiLock->unlock();
|
spiLock->unlock();
|
||||||
#endif
|
#endif
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
|
#ifdef FACTORY_INSTALL
|
||||||
|
spiLock->lock();
|
||||||
|
if (!FSCom.exists("/prefs/" xstr(BUILD_EPOCH))) {
|
||||||
|
LOG_WARN("Factory Install Reset!");
|
||||||
|
FSCom.format();
|
||||||
|
FSCom.mkdir("/prefs");
|
||||||
|
File f2 = FSCom.open("/prefs/" xstr(BUILD_EPOCH), FILE_O_WRITE);
|
||||||
|
if (f2) {
|
||||||
|
f2.flush();
|
||||||
|
f2.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spiLock->unlock();
|
||||||
|
#endif
|
||||||
spiLock->lock();
|
spiLock->lock();
|
||||||
if (FSCom.exists(legacyPrefFileName)) {
|
if (FSCom.exists(legacyPrefFileName)) {
|
||||||
spiLock->unlock();
|
spiLock->unlock();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user