* added CommonCLI::saveIdentity()
This commit is contained in:
@@ -732,6 +732,20 @@ public:
|
|||||||
|
|
||||||
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
||||||
|
|
||||||
|
void saveIdentity(const mesh::LocalIdentity& new_id) override {
|
||||||
|
self_id = new_id;
|
||||||
|
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||||
|
IdentityStore store(*_fs, "");
|
||||||
|
#elif defined(ESP32)
|
||||||
|
IdentityStore store(*_fs, "/identity");
|
||||||
|
#elif defined(RP2040_PLATFORM)
|
||||||
|
IdentityStore store(*_fs, "/identity");
|
||||||
|
#else
|
||||||
|
#error "need to define saveIdentity()"
|
||||||
|
#endif
|
||||||
|
store.save("_main", self_id);
|
||||||
|
}
|
||||||
|
|
||||||
void clearStats() override {
|
void clearStats() override {
|
||||||
radio_driver.resetStats();
|
radio_driver.resetStats();
|
||||||
resetStats();
|
resetStats();
|
||||||
|
|||||||
@@ -865,6 +865,20 @@ public:
|
|||||||
|
|
||||||
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
||||||
|
|
||||||
|
void saveIdentity(const mesh::LocalIdentity& new_id) override {
|
||||||
|
self_id = new_id;
|
||||||
|
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||||
|
IdentityStore store(*_fs, "");
|
||||||
|
#elif defined(ESP32)
|
||||||
|
IdentityStore store(*_fs, "/identity");
|
||||||
|
#elif defined(RP2040_PLATFORM)
|
||||||
|
IdentityStore store(*_fs, "/identity");
|
||||||
|
#else
|
||||||
|
#error "need to define saveIdentity()"
|
||||||
|
#endif
|
||||||
|
store.save("_main", self_id);
|
||||||
|
}
|
||||||
|
|
||||||
void clearStats() override {
|
void clearStats() override {
|
||||||
radio_driver.resetStats();
|
radio_driver.resetStats();
|
||||||
resetStats();
|
resetStats();
|
||||||
|
|||||||
@@ -837,6 +837,20 @@ bool SensorMesh::formatFileSystem() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SensorMesh::saveIdentity(const mesh::LocalIdentity& new_id) {
|
||||||
|
self_id = new_id;
|
||||||
|
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||||
|
IdentityStore store(*_fs, "");
|
||||||
|
#elif defined(ESP32)
|
||||||
|
IdentityStore store(*_fs, "/identity");
|
||||||
|
#elif defined(RP2040_PLATFORM)
|
||||||
|
IdentityStore store(*_fs, "/identity");
|
||||||
|
#else
|
||||||
|
#error "need to define saveIdentity()"
|
||||||
|
#endif
|
||||||
|
store.save("_main", self_id);
|
||||||
|
}
|
||||||
|
|
||||||
void SensorMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) {
|
void SensorMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) {
|
||||||
set_radio_at = futureMillis(2000); // give CLI reply some time to be sent back, before applying temp radio params
|
set_radio_at = futureMillis(2000); // give CLI reply some time to be sent back, before applying temp radio params
|
||||||
pending_freq = freq;
|
pending_freq = freq;
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public:
|
|||||||
strcpy(reply, "not supported");
|
strcpy(reply, "not supported");
|
||||||
}
|
}
|
||||||
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
||||||
|
void saveIdentity(const mesh::LocalIdentity& new_id) override;
|
||||||
void clearStats() override { }
|
void clearStats() override { }
|
||||||
void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) override;
|
void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) override;
|
||||||
|
|
||||||
|
|||||||
@@ -305,7 +305,9 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
|||||||
uint8_t prv_key[PRV_KEY_SIZE];
|
uint8_t prv_key[PRV_KEY_SIZE];
|
||||||
bool success = mesh::Utils::fromHex(prv_key, PRV_KEY_SIZE, &config[8]);
|
bool success = mesh::Utils::fromHex(prv_key, PRV_KEY_SIZE, &config[8]);
|
||||||
if (success) {
|
if (success) {
|
||||||
_callbacks->getSelfId().readFrom(prv_key, PRV_KEY_SIZE);
|
mesh::LocalIdentity new_id;
|
||||||
|
new_id.readFrom(prv_key, PRV_KEY_SIZE);
|
||||||
|
_callbacks->saveIdentity(new_id);
|
||||||
strcpy(reply, "OK");
|
strcpy(reply, "OK");
|
||||||
} else {
|
} else {
|
||||||
strcpy(reply, "Error, invalid key");
|
strcpy(reply, "Error, invalid key");
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
// no op by default
|
// no op by default
|
||||||
};
|
};
|
||||||
virtual mesh::LocalIdentity& getSelfId() = 0;
|
virtual mesh::LocalIdentity& getSelfId() = 0;
|
||||||
|
virtual void saveIdentity(const mesh::LocalIdentity& new_id) = 0;
|
||||||
virtual void clearStats() = 0;
|
virtual void clearStats() = 0;
|
||||||
virtual void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) = 0;
|
virtual void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user