From af5c54f610d66575e0182c7d51131e0a5990f73b Mon Sep 17 00:00:00 2001 From: tuzzmaniandevil Date: Tue, 5 Sep 2017 16:31:04 +1200 Subject: [PATCH] Add an option to query relay status --- code/espurna/relay.ino | 7 ++++--- code/espurna/web.ino | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 456b6b06..7f476572 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -335,13 +335,14 @@ unsigned char relayParsePayload(const char * payload) { value = 1; } else if (strcmp(p, "toggle") == 0) { value = 2; + } else if (strcmp(p, "query") == 0) { + value = 3; } else { value = p[0] - '0'; } - if (0 <= value && value <=2) return value; - return 0x99; - + if (0 <= value && value <=3) return value; + return 0xFF; } //------------------------------------------------------------------------------ // REST API diff --git a/code/espurna/web.ino b/code/espurna/web.ino index eed32a45..4f349897 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -142,7 +142,7 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { if (data.containsKey("status")) { unsigned char value = relayParsePayload(data["status"]); - if (value == 0xFF) { + if (value == 3) { relayWS();