* repeater & room server: "node_prefs" -> "com_prefs" migration
This commit is contained in:
@@ -14,8 +14,17 @@ static uint32_t _atoi(const char* sp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CommonCLI::loadPrefs(FILESYSTEM* fs) {
|
void CommonCLI::loadPrefs(FILESYSTEM* fs) {
|
||||||
if (fs->exists("/node_prefs")) {
|
if (fs->exists("/com_prefs")) {
|
||||||
File file = fs->open("/node_prefs");
|
loadPrefsInt(fs, "/com_prefs"); // new filename
|
||||||
|
} else if (fs->exists("/node_prefs")) {
|
||||||
|
loadPrefsInt(fs, "/node_prefs");
|
||||||
|
savePrefs(fs); // save to new filename
|
||||||
|
fs->remove("/node_prefs"); // remove old
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
||||||
|
File file = fs->open(filename);
|
||||||
if (file) {
|
if (file) {
|
||||||
uint8_t pad[8];
|
uint8_t pad[8];
|
||||||
|
|
||||||
@@ -56,15 +65,14 @@ void CommonCLI::loadPrefs(FILESYSTEM* fs) {
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonCLI::savePrefs(FILESYSTEM* fs) {
|
void CommonCLI::savePrefs(FILESYSTEM* fs) {
|
||||||
#if defined(NRF52_PLATFORM)
|
#if defined(NRF52_PLATFORM)
|
||||||
File file = fs->open("/node_prefs", FILE_O_WRITE);
|
File file = fs->open("/com_prefs", FILE_O_WRITE);
|
||||||
if (file) { file.seek(0); file.truncate(); }
|
if (file) { file.seek(0); file.truncate(); }
|
||||||
#else
|
#else
|
||||||
File file = fs->open("/node_prefs", "w", true);
|
File file = fs->open("/com_prefs", "w", true);
|
||||||
#endif
|
#endif
|
||||||
if (file) {
|
if (file) {
|
||||||
uint8_t pad[8];
|
uint8_t pad[8];
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class CommonCLI {
|
|||||||
|
|
||||||
void checkAdvertInterval();
|
void checkAdvertInterval();
|
||||||
|
|
||||||
|
void loadPrefsInt(FILESYSTEM* _fs, const char* filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CommonCLI(mesh::MainBoard& board, mesh::Mesh* mesh, NodePrefs* prefs, CommonCLICallbacks* callbacks)
|
CommonCLI(mesh::MainBoard& board, mesh::Mesh* mesh, NodePrefs* prefs, CommonCLICallbacks* callbacks)
|
||||||
: _board(&board), _mesh(mesh), _prefs(prefs), _callbacks(callbacks) { }
|
: _board(&board), _mesh(mesh), _prefs(prefs), _callbacks(callbacks) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user