mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* IdentityStore::save() was failing on RAK.
* Repeater: CLI 'erase' command added.
This commit is contained in:
parent
a0bb332ce5
commit
29e62b9ce2
5 changed files with 23 additions and 3 deletions
|
|
@ -388,7 +388,11 @@ public:
|
|||
|
||||
BaseChatMesh::begin();
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
IdentityStore store(fs, "");
|
||||
#else
|
||||
IdentityStore store(fs, "/identity");
|
||||
#endif
|
||||
if (!store.load("_main", self_id)) {
|
||||
self_id = mesh::LocalIdentity(&trng); // create new random identity
|
||||
store.save("_main", self_id);
|
||||
|
|
|
|||
|
|
@ -498,6 +498,15 @@ public:
|
|||
} else {
|
||||
sprintf(reply, "unknown config: %s", config);
|
||||
}
|
||||
} else if (sender_timestamp == 0 && strcmp(command, "erase") == 0) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
bool s = InternalFS.format();
|
||||
#elif defined(ESP32)
|
||||
bool s = SPIFFS.format();
|
||||
#else
|
||||
#error "need to implement file system erase"
|
||||
#endif
|
||||
sprintf(reply, "File system erase: %s", s ? "OK" : "Err");
|
||||
} else if (memcmp(command, "ver", 3) == 0) {
|
||||
strcpy(reply, FIRMWARE_VER_TEXT);
|
||||
} else {
|
||||
|
|
@ -576,7 +585,7 @@ void setup() {
|
|||
#if defined(NRF52_PLATFORM)
|
||||
InternalFS.begin();
|
||||
fs = &InternalFS;
|
||||
IdentityStore store(InternalFS, "/identity");
|
||||
IdentityStore store(InternalFS, "");
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
fs = &SPIFFS;
|
||||
|
|
@ -585,6 +594,7 @@ void setup() {
|
|||
#error "need to define filesystem"
|
||||
#endif
|
||||
if (!store.load("_main", the_mesh.self_id)) {
|
||||
MESH_DEBUG_PRINTLN("Generating new keypair");
|
||||
RadioNoiseListener rng(radio);
|
||||
the_mesh.self_id = mesh::LocalIdentity(&rng); // create new random identity
|
||||
store.save("_main", the_mesh.self_id);
|
||||
|
|
|
|||
|
|
@ -727,7 +727,7 @@ void setup() {
|
|||
#if defined(NRF52_PLATFORM)
|
||||
InternalFS.begin();
|
||||
fs = &InternalFS;
|
||||
IdentityStore store(InternalFS, "/identity");
|
||||
IdentityStore store(InternalFS, "");
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
fs = &SPIFFS;
|
||||
|
|
|
|||
|
|
@ -301,7 +301,11 @@ public:
|
|||
|
||||
BaseChatMesh::begin();
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
IdentityStore store(fs, "");
|
||||
#else
|
||||
IdentityStore store(fs, "/identity");
|
||||
#endif
|
||||
if (!store.load("_main", self_id, _prefs.node_name, sizeof(_prefs.node_name))) { // legacy: node_name was from identity file
|
||||
self_id = mesh::LocalIdentity(getRNG()); // create new random identity
|
||||
store.save("_main", self_id);
|
||||
|
|
|
|||
|
|
@ -45,10 +45,12 @@ bool IdentityStore::save(const char *name, const mesh::LocalIdentity& id) {
|
|||
File file = _fs->open(filename, "w", true);
|
||||
#endif
|
||||
if (file) {
|
||||
id.writeTo(file);
|
||||
bool success = id.writeTo(file);
|
||||
file.close();
|
||||
MESH_DEBUG_PRINTLN("IdentityStore::save() write - %s", success ? "OK" : "Err");
|
||||
return true;
|
||||
}
|
||||
MESH_DEBUG_PRINTLN("IdentityStore::save() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue