From cb393867d17e10861d7b53686f14d7a22ce3a955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sat, 18 Feb 2017 00:54:54 +0100 Subject: [PATCH] Allow to change relay status using GET requests --- code/espurna/relay.ino | 3 ++- code/espurna/web.ino | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 6b390fb9..a701910d 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -253,7 +253,8 @@ void relaySetupAPI() { } else { relayStatus(relayID, value == 1); } - }); + } + ); } diff --git a/code/espurna/web.ino b/code/espurna/web.ino index 9d68256b..dc103b09 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -587,9 +587,9 @@ ArRequestHandlerFunction _bindAPI(unsigned int apiID) { bool asJson = _asJson(request); web_api_t api = _apis[apiID]; - if (request->method() == HTTP_PUT) { - if (request->hasParam("value", true)) { - AsyncWebParameter* p = request->getParam("value", true); + if (api.putFn != NULL) { + if (request->hasParam("value", request->method() == HTTP_PUT)) { + AsyncWebParameter* p = request->getParam("value", request->method() == HTTP_PUT); (api.putFn)((p->value()).c_str()); } }