diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino
index ed88da8c4..e9050aafb 100644
--- a/sonoff/_changelog.ino
+++ b/sonoff/_changelog.ino
@@ -3,6 +3,7 @@
* Redesign command Tariff to now default to 0 (=disabled) and allowing to set both Standard Time (ST) and Daylight Savings Time (DST) start hour
* Commands Tariff1 22,23 = Tariff1 (Off-Peak) ST,DST Tariff2 (Standard) 6,7 = Tariff2 ST,DST Tariff9 0/1 = Weekend toggle (1 = Off-Peak during weekend)
* Change rename "Data" to "Hash" and limit to 32 bits when receiving UNKNOWN IR protocol (see DECODE_HASH from IRremoteESP8266)
+ * Add command Gpios 255/All to show all available GPIO components (#6407)
*
* 6.6.0.11 20190907
* Change Settings crc calculation allowing short term backward compatibility
diff --git a/sonoff/i18n.h b/sonoff/i18n.h
index e44b4a928..a6695fb73 100644
--- a/sonoff/i18n.h
+++ b/sonoff/i18n.h
@@ -604,12 +604,6 @@ const char kCodeImage[] PROGMEM = "sonoff|minimal|classic|sensors|knx|basic|disp
// support.ino
static const char kMonthNames[] = D_MONTH3LIST;
-const char kOptionOff[] PROGMEM = "OFF|" D_OFF "|" D_FALSE "|" D_STOP "|" D_CELSIUS ;
-const char kOptionOn[] PROGMEM = "ON|" D_ON "|" D_TRUE "|" D_START "|" D_FAHRENHEIT "|" D_USER ;
-const char kOptionToggle[] PROGMEM = "TOGGLE|" D_TOGGLE "|" D_ADMIN ;
-const char kOptionBlink[] PROGMEM = "BLINK|" D_BLINK ;
-const char kOptionBlinkOff[] PROGMEM = "BLINKOFF|" D_BLINKOFF ;
-
// xdrv_02_webserver.ino
#ifdef USE_WEBSERVER
const char HTTP_SNS_TEMP[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%s°%c{e}"; // {s} =
, {m} = | , {e} = |
diff --git a/sonoff/support.ino b/sonoff/support.ino
index b9fec8651..cca75b377 100644
--- a/sonoff/support.ino
+++ b/sonoff/support.ino
@@ -761,25 +761,26 @@ bool DecodeCommand(const char* haystack, void (* const MyCommand[])(void))
return false;
}
+const char kOptions[] PROGMEM = "OFF|" D_OFF "|" D_FALSE "|" D_STOP "|" D_CELSIUS "|" // 0
+ "ON|" D_ON "|" D_TRUE "|" D_START "|" D_FAHRENHEIT "|" D_USER "|" // 1
+ "TOGGLE|" D_TOGGLE "|" D_ADMIN "|" // 2
+ "BLINK|" D_BLINK "|" // 3
+ "BLINKOFF|" D_BLINKOFF "|" // 4
+ "ALL" ; // 255
+
+const uint8_t sNumbers[] PROGMEM = { 0,0,0,0,0,
+ 1,1,1,1,1,1,
+ 2,2,2,
+ 3,3,
+ 4,4,
+ 255 };
+
int GetStateNumber(char *state_text)
{
char command[CMDSZ];
- int state_number = -1;
-
- if (GetCommandCode(command, sizeof(command), state_text, kOptionOff) >= 0) {
- state_number = 0;
- }
- else if (GetCommandCode(command, sizeof(command), state_text, kOptionOn) >= 0) {
- state_number = 1;
- }
- else if (GetCommandCode(command, sizeof(command), state_text, kOptionToggle) >= 0) {
- state_number = 2;
- }
- else if (GetCommandCode(command, sizeof(command), state_text, kOptionBlink) >= 0) {
- state_number = 3;
- }
- else if (GetCommandCode(command, sizeof(command), state_text, kOptionBlinkOff) >= 0) {
- state_number = 4;
+ int state_number = GetCommandCode(command, sizeof(command), state_text, kOptions);
+ if (state_number >= 0) {
+ state_number = pgm_read_byte(sNumbers + state_number);
}
return state_number;
}
diff --git a/sonoff/support_command.ino b/sonoff/support_command.ino
index c181a70bf..bd7107648 100644
--- a/sonoff/support_command.ino
+++ b/sonoff/support_command.ino
@@ -859,20 +859,19 @@ void CmndGpios(void)
bool jsflg = false;
for (uint32_t i = 0; i < sizeof(kGpioNiceList); i++) {
midx = pgm_read_byte(kGpioNiceList + i);
- if (!GetUsedInModule(midx, cmodule.io)) {
- if (!jsflg) {
- Response_P(PSTR("{\"" D_CMND_GPIOS "%d\":["), lines);
- } else {
- ResponseAppend_P(PSTR(","));
- }
- jsflg = true;
- char stemp1[TOPSZ];
- if ((ResponseAppend_P(PSTR("\"%d (%s)\""), midx, GetTextIndexed(stemp1, sizeof(stemp1), midx, kSensorNames)) > (LOGSZ - TOPSZ)) || (i == sizeof(kGpioNiceList) -1)) {
- ResponseAppend_P(PSTR("]}"));
- MqttPublishPrefixTopic_P(RESULT_OR_STAT, UpperCase(XdrvMailbox.command, XdrvMailbox.command));
- jsflg = false;
- lines++;
- }
+ if ((XdrvMailbox.payload != 255) && GetUsedInModule(midx, cmodule.io)) { continue; }
+ if (!jsflg) {
+ Response_P(PSTR("{\"" D_CMND_GPIOS "%d\":["), lines);
+ } else {
+ ResponseAppend_P(PSTR(","));
+ }
+ jsflg = true;
+ char stemp1[TOPSZ];
+ if ((ResponseAppend_P(PSTR("\"%d (%s)\""), midx, GetTextIndexed(stemp1, sizeof(stemp1), midx, kSensorNames)) > (LOGSZ - TOPSZ)) || (i == sizeof(kGpioNiceList) -1)) {
+ ResponseAppend_P(PSTR("]}"));
+ MqttPublishPrefixTopic_P(RESULT_OR_STAT, UpperCase(XdrvMailbox.command, XdrvMailbox.command));
+ jsflg = false;
+ lines++;
}
}
mqtt_data[0] = '\0';