Browse Source

Better support for multicase payloads

fastled
Xose Pérez 7 years ago
parent
commit
e2e5cc57f5
1 changed files with 9 additions and 10 deletions
  1. +9
    -10
      code/espurna/relay.ino

+ 9
- 10
code/espurna/relay.ino View File

@ -319,21 +319,20 @@ unsigned char _relayValueFromPayload(const char * payload) {
// Payload could be "OFF", "ON", "TOGGLE" // Payload could be "OFF", "ON", "TOGGLE"
// or its number equivalents: 0, 1 or 2 // or its number equivalents: 0, 1 or 2
unsigned int value;
// trim payload // trim payload
char * p = ltrim((char *)payload); char * p = ltrim((char *)payload);
if (strcmp(p, "ON") == 0) {
value = 1;
// to lower
for (unsigned char i=0; i<strlen(p); i++) {
p[i] = tolower(p[i]);
}
unsigned int value;
if (strcmp(p, "off") == 0) {
value = 0;
} else if (strcmp(p, "on") == 0) { } else if (strcmp(p, "on") == 0) {
value = 1; value = 1;
} else if (strcmp(p, "OFF") == 0) {
value = 0;
} else if (strcmp(p, "off") == 0) {
value = 0;
} else if (strcmp(p, "TOGGLE") == 0) {
value = 2;
} else if (strcmp(p, "toggle") == 0) { } else if (strcmp(p, "toggle") == 0) {
value = 2; value = 2;
} else { } else {


Loading…
Cancel
Save