From fa406339964201623876cb0e9eaea25b5c2aae18 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 30 May 2018 11:05:04 +0300 Subject: [PATCH 1/2] Customize GET terminal command --- code/espurna/settings.ino | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 9d5767b3..7bfa928a 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -269,6 +269,25 @@ void _settingsInitCommands() { DEBUG_MSG_P(PSTR("+OK\n")); }); + settingsRegisterCommand(F("GET"), [](Embedis* e) { + if (e->argc < 2) { + DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); + return; + } + + for (unsigned char i = 1; i < e->argc; i++) { + String key = String(e->argv[i]); + String value; + if (!Embedis::get(key, value)) { + DEBUG_MSG_P(PSTR("-ERROR: Unknown key: %s\n"), key.c_str()); + } + + DEBUG_MSG_P(PSTR("> %s => %s\n"), key.c_str(), value.c_str()); + } + + DEBUG_MSG_P(PSTR("+OK\n")); + }); + settingsRegisterCommand(F("RELOAD"), [](Embedis* e) { wsReload(); DEBUG_MSG_P(PSTR("+OK\n")); From 0281cb26e8ca6015fe12235511b661be81cd04e4 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 30 May 2018 19:45:43 +0300 Subject: [PATCH 2/2] Empty string for no value, quote existing values --- code/espurna/settings.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 7bfa928a..b1d4d921 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -151,7 +151,7 @@ void _settingsKeysCommand() { DEBUG_MSG_P(PSTR("Current settings:\n")); for (unsigned int i=0; i %s => %s\n"), (keys[i]).c_str(), value.c_str()); + DEBUG_MSG_P(PSTR("> %s => \"%s\"\n"), (keys[i]).c_str(), value.c_str()); } unsigned long freeEEPROM = SPI_FLASH_SEC_SIZE - settingsSize(); @@ -279,10 +279,11 @@ void _settingsInitCommands() { String key = String(e->argv[i]); String value; if (!Embedis::get(key, value)) { - DEBUG_MSG_P(PSTR("-ERROR: Unknown key: %s\n"), key.c_str()); + DEBUG_MSG_P(PSTR("> %s =>\n"), key.c_str()); + continue; } - DEBUG_MSG_P(PSTR("> %s => %s\n"), key.c_str(), value.c_str()); + DEBUG_MSG_P(PSTR("> %s => \"%s\"\n"), key.c_str(), value.c_str()); } DEBUG_MSG_P(PSTR("+OK\n"));