From 4b72080b6d4858233ed4bc7687fc3b373547d0e4 Mon Sep 17 00:00:00 2001 From: David Conran Date: Thu, 17 May 2018 15:41:44 +1000 Subject: [PATCH 1/2] Allow IR messages with a data payload of zero. Ref: Issue #2751 Incorrect assumption that if the result of `strtoul()` is zero (0) it is a parse failure. That's incorrect as the "data" payload could actually be 0. Ref: https://github.com/markszabo/IRremoteESP8266/issues/447#issuecomment-389745404 --- sonoff/xdrv_02_irremote.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonoff/xdrv_02_irremote.ino b/sonoff/xdrv_02_irremote.ino index 99f4dfed7..b4414b375 100644 --- a/sonoff/xdrv_02_irremote.ino +++ b/sonoff/xdrv_02_irremote.ino @@ -298,7 +298,7 @@ boolean IrSendCommand() protocol = root[UpperCase_P(parm_uc, PSTR(D_JSON_IR_PROTOCOL))]; bits = root[UpperCase_P(parm_uc, PSTR(D_JSON_IR_BITS))]; data = strtoul(root[UpperCase_P(parm_uc, PSTR(D_JSON_IR_DATA))], NULL, 0); - if (protocol && bits && data) { + if (protocol && bits) { int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols); snprintf_P(log_data, sizeof(log_data), PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %u (0x%lX), protocol_code %d"), From 80ffea085b45a98e75325db6bbea3486ba130121 Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Thu, 17 May 2018 11:55:40 +0200 Subject: [PATCH 2/2] Admin and some fixes 5.14.0a * Add KNX energy data (#2750) * Fix display selection of un-available GPIO options in Module Configuration webpage (#2718) * Fix IRSend not accepting data value of 0 (#2751) --- sonoff/_releasenotes.ino | 3 +++ sonoff/sonoff.h | 20 ++++++++--------- sonoff/webserver.ino | 44 +++++++++++++++++++++++++++++++++++++ sonoff/xdrv_02_irremote.ino | 2 +- sonoff/xdrv_03_energy.ino | 2 +- sonoff/xdrv_11_knx.ino | 2 +- 6 files changed, 60 insertions(+), 13 deletions(-) diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 02ea82c75..533199886 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,7 +1,10 @@ /* 5.14.0a * Add Eastron SDM630 energy meter (#2735) * Add KNX communication enhancement (#2742) + * Add KNX energy data (#2750) + * Fix display selection of un-available GPIO options in Module Configuration webpage (#2718) * Fix timer re-trigger within one minute after restart (#2744) + * Fix IRSend not accepting data value of 0 (#2751) * * 5.14.0 20180515 * Update language files diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 47fec4645..a4077c8f1 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -132,16 +132,16 @@ typedef unsigned long power_t; // Power (Relay) type #define DAWN_ASTRONOMIC -18.0 // Sensor definition for KNX Driver -#define KNX_TEMPERATURE 17 -#define KNX_HUMIDITY 18 -#define KNX_ENERGY_VOLTAGE 19 -#define KNX_ENERGY_CURRENT 20 -#define KNX_ENERGY_POWER 21 +#define KNX_TEMPERATURE 17 +#define KNX_HUMIDITY 18 +#define KNX_ENERGY_VOLTAGE 19 +#define KNX_ENERGY_CURRENT 20 +#define KNX_ENERGY_POWER 21 #define KNX_ENERGY_POWERFACTOR 22 -#define KNX_ENERGY_DAILY 23 -#define KNX_ENERGY_START 24 -#define KNX_ENERGY_TOTAL 25 -#define KNX_MAX_device_param 25 +#define KNX_ENERGY_DAILY 23 +#define KNX_ENERGY_START 24 +#define KNX_ENERGY_TOTAL 25 +#define KNX_MAX_device_param 25 /*********************************************************************************************\ * Enumeration @@ -192,4 +192,4 @@ const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, extern uint8_t light_device; // Light device number -#endif // _SONOFF_H_ +#endif // _SONOFF_H_ \ No newline at end of file diff --git a/sonoff/webserver.ino b/sonoff/webserver.ino index 3c74d346a..e9f9eded5 100644 --- a/sonoff/webserver.ino +++ b/sonoff/webserver.ino @@ -660,6 +660,50 @@ boolean GetUsedInModule(byte val, uint8_t *arr) #endif #ifndef USE_IR_REMOTE if (GPIO_IRSEND == val) { return true; } +#ifndef USE_IR_RECEIVE + if (GPIO_IRRECV == val) { return true; } +#endif +#endif +#ifndef USE_MHZ19 + if (GPIO_MHZ_TXD == val) { return true; } + if (GPIO_MHZ_RXD == val) { return true; } +#endif +#ifndef USE_PZEM004T + if (GPIO_PZEM_TX == val) { return true; } + if (GPIO_PZEM_RX == val) { return true; } +#endif +#ifndef USE_SENSEAIR + if (GPIO_SAIR_TX == val) { return true; } + if (GPIO_SAIR_RX == val) { return true; } +#endif +#ifndef USE_SPI + if (GPIO_SPI_CS == val) { return true; } + if (GPIO_SPI_DC == val) { return true; } +#endif +#ifndef USE_DISPLAY + if (GPIO_BACKLIGHT == val) { return true; } +#endif +#ifndef USE_PMS5003 + if (GPIO_PMS5003 == val) { return true; } +#endif +#ifndef USE_NOVA_SDS + if (GPIO_SDS0X1 == val) { return true; } +#endif +#ifndef USE_SERIAL_BRIDGE + if (GPIO_SBR_TX == val) { return true; } + if (GPIO_SBR_RX == val) { return true; } +#endif +#ifndef USE_SR04 + if (GPIO_SR04_TRIG == val) { return true; } + if (GPIO_SR04_ECHO == val) { return true; } +#endif +#ifndef USE_SDM120 + if (GPIO_SDM120_TX == val) { return true; } + if (GPIO_SDM120_RX == val) { return true; } +#endif +#ifndef USE_SDM630 + if (GPIO_SDM630_TX == val) { return true; } + if (GPIO_SDM630_RX == val) { return true; } #endif if ((val >= GPIO_REL1) && (val < GPIO_REL1 + MAX_RELAYS)) { offset = (GPIO_REL1_INV - GPIO_REL1); diff --git a/sonoff/xdrv_02_irremote.ino b/sonoff/xdrv_02_irremote.ino index b4414b375..e2d4a1019 100644 --- a/sonoff/xdrv_02_irremote.ino +++ b/sonoff/xdrv_02_irremote.ino @@ -384,7 +384,7 @@ boolean IrSendCommand() } #endif // USE_IR_HVAC else serviced = false; // Unknown command - + return serviced; } diff --git a/sonoff/xdrv_03_energy.ino b/sonoff/xdrv_03_energy.ino index 8eca675f3..b3d717d65 100644 --- a/sonoff/xdrv_03_energy.ino +++ b/sonoff/xdrv_03_energy.ino @@ -1187,4 +1187,4 @@ boolean Xsns03(byte function) return result; } -#endif // USE_ENERGY_SENSOR +#endif // USE_ENERGY_SENSOR \ No newline at end of file diff --git a/sonoff/xdrv_11_knx.ino b/sonoff/xdrv_11_knx.ino index 4379efad4..80d2e2cdf 100644 --- a/sonoff/xdrv_11_knx.ino +++ b/sonoff/xdrv_11_knx.ino @@ -968,4 +968,4 @@ boolean Xdrv11(byte function) return result; } -#endif // USE_KNX +#endif // USE_KNX \ No newline at end of file