added new CommonCLI get commands: get role and get public.key

This commit is contained in:
recrof 2025-03-29 19:40:35 +01:00
parent 0d5c17f7ed
commit b77701ced0
4 changed files with 16 additions and 3 deletions

View file

@ -198,6 +198,12 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
sprintf(reply, "> %d", (uint32_t) _prefs->tx_power_dbm);
} else if (memcmp(config, "freq", 4) == 0) {
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->freq));
} else if (memcmp(config, "public.key", 10) == 0) {
char pub_key_hex[PUB_KEY_SIZE * 2 + 1];
mesh::Utils::toHex(pub_key_hex, _mesh->self_id.pub_key, PUB_KEY_SIZE);
sprintf(reply, "> %s", pub_key_hex);
} else if (memcmp(config, "role", 4) == 0) {
sprintf(reply, "> %s", _callbacks->getRole());
} else {
sprintf(reply, "??: %s", config);
}

View file

@ -31,6 +31,7 @@ public:
virtual void savePrefs() = 0;
virtual const char* getFirmwareVer() = 0;
virtual const char* getBuildDate() = 0;
virtual const char* getRole() = 0;
virtual bool formatFileSystem() = 0;
virtual void sendSelfAdvertisement(int delay_millis) = 0;
virtual void updateAdvertTimer() = 0;
@ -56,7 +57,7 @@ class CommonCLI {
void loadPrefsInt(FILESYSTEM* _fs, const char* filename);
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) { }
void loadPrefs(FILESYSTEM* _fs);