|
|
@ -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]; |
|
|
|
|
|
|
|
|
@ -57,14 +66,13 @@ 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]; |
|
|
|