From d9fd01a30d943a011768b3352e7d58309432ad0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 29 Jun 2018 19:50:56 +0200 Subject: [PATCH] Override SET command and add backwards hacks --- code/espurna/settings.ino | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index a200a370..efa16675 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -304,6 +304,7 @@ void _settingsInitCommands() { }); settingsRegisterCommand(F("GET"), [](Embedis* e) { + if (e->argc < 2) { DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); return; @@ -321,6 +322,29 @@ void _settingsInitCommands() { } DEBUG_MSG_P(PSTR("+OK\n")); + + }); + + settingsRegisterCommand(F("SET"), [](Embedis* e) { + + if (e->argc != 3) { + DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); + return; + } + + String key = String(e->argv[1]); + String value = String(e->argv[2]); + + // Hacks for backwards compatibility + if (key.startsWith("ssid")) key.replace("ssid", "wifiName"); + if (key.startsWith("pass")) key.replace("pass", "wifiPass"); + + if (Embedis::set(key, value)) { + DEBUG_MSG_P(PSTR("+OK\n")); + } else { + DEBUG_MSG_P(PSTR("-ERROR: Error storing key-value\n")); + } + }); #if WEB_SUPPORT