* RP2040 IdentityStore begin(), to ensure mkdir()

This commit is contained in:
Scott Powell 2025-04-22 15:26:04 +10:00
parent 2ba3f42f30
commit a87b5231cc
5 changed files with 9 additions and 1 deletions

View file

@ -817,6 +817,9 @@ public:
#if defined(NRF52_PLATFORM) #if defined(NRF52_PLATFORM)
_identity_store = new IdentityStore(fs, ""); _identity_store = new IdentityStore(fs, "");
#elif defined(RP2040_PLATFORM)
_identity_store = new IdentityStore(fs, "/identity");
_identity_store->begin();
#else #else
_identity_store = new IdentityStore(fs, "/identity"); _identity_store = new IdentityStore(fs, "/identity");
#endif #endif

View file

@ -651,6 +651,7 @@ void setup() {
LittleFS.begin(); LittleFS.begin();
fs = &LittleFS; fs = &LittleFS;
IdentityStore store(LittleFS, "/identity"); IdentityStore store(LittleFS, "/identity");
store.begin();
#else #else
#error "need to define filesystem" #error "need to define filesystem"
#endif #endif

View file

@ -889,6 +889,7 @@ void setup() {
LittleFS.begin(); LittleFS.begin();
fs = &LittleFS; fs = &LittleFS;
IdentityStore store(LittleFS, "/identity"); IdentityStore store(LittleFS, "/identity");
store.begin();
#elif defined(ESP32) #elif defined(ESP32)
SPIFFS.begin(true); SPIFFS.begin(true);
fs = &SPIFFS; fs = &SPIFFS;

View file

@ -295,6 +295,9 @@ public:
#if defined(NRF52_PLATFORM) #if defined(NRF52_PLATFORM)
IdentityStore store(fs, ""); IdentityStore store(fs, "");
#elif defined(RP2040_PLATFORM)
IdentityStore store(fs, "/identity");
store.begin();
#else #else
IdentityStore store(fs, "/identity"); IdentityStore store(fs, "/identity");
#endif #endif

View file

@ -18,7 +18,7 @@ class IdentityStore {
public: public:
IdentityStore(FILESYSTEM& fs, const char* dir): _fs(&fs), _dir(dir) { } IdentityStore(FILESYSTEM& fs, const char* dir): _fs(&fs), _dir(dir) { }
void begin() { _fs->mkdir(_dir); } void begin() { if (_dir && _dir[0] == '/') { _fs->mkdir(_dir); } }
bool load(const char *name, mesh::LocalIdentity& id); bool load(const char *name, mesh::LocalIdentity& id);
bool load(const char *name, mesh::LocalIdentity& id, char display_name[], int max_name_sz); bool load(const char *name, mesh::LocalIdentity& id, char display_name[], int max_name_sz);
bool save(const char *name, const mesh::LocalIdentity& id); bool save(const char *name, const mesh::LocalIdentity& id);