Browse Source

Merged in tuzzmaniandevil/espurna/dev (pull request #27)

Add an option to query relay status

Approved-by: Wesley Tuzza <wesley@tuzza.co>
Approved-by: Xose Pérez <xose.perez@gmail.com>
fastled
Wesley Tuzza 7 years ago
committed by Xose Pérez
parent
commit
591137bb8a
2 changed files with 5 additions and 4 deletions
  1. +4
    -3
      code/espurna/relay.ino
  2. +1
    -1
      code/espurna/web.ino

+ 4
- 3
code/espurna/relay.ino View File

@ -335,13 +335,14 @@ unsigned char relayParsePayload(const char * payload) {
value = 1; value = 1;
} else if (strcmp(p, "toggle") == 0) { } else if (strcmp(p, "toggle") == 0) {
value = 2; value = 2;
} else if (strcmp(p, "query") == 0) {
value = 3;
} else { } else {
value = p[0] - '0'; value = p[0] - '0';
} }
if (0 <= value && value <=2) return value;
return 0x99;
if (0 <= value && value <=3) return value;
return 0xFF;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// REST API // REST API


+ 1
- 1
code/espurna/web.ino View File

@ -143,7 +143,7 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
if (data.containsKey("status")) { if (data.containsKey("status")) {
unsigned char value = relayParsePayload(data["status"]); unsigned char value = relayParsePayload(data["status"]);
if (value == 0xFF) {
if (value == 3) {
relayWS(); relayWS();


Loading…
Cancel
Save