From 547e5d9c5d679069b15429af365a0413cd0015ee Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 24 Nov 2020 15:14:22 +0100 Subject: [PATCH] Fix command ``gpio`` Fix command ``gpio`` using non-indexed functions regression from v9.1.0 (#9962) --- CHANGELOG.md | 3 ++- RELEASENOTES.md | 2 ++ tasmota/support.ino | 2 +- tasmota/support_command.ino | 17 +++++++++-------- tasmota/support_tasmota.ino | 8 ++++---- tasmota/xdrv_01_webserver.ino | 28 ++++++++++++++-------------- 6 files changed, 32 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6111f2b4..86a040cb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. ## [9.1.0.2] ### Added - KNX read reply for Power (#9236, #9891) -- Zigbee persistence of device/sensir data in EEPROM (only ZBBridge) +- Zigbee persistence of device/sensor data in EEPROM (only ZBBridge) ### Breaking Changed - KNX DPT9 (16-bit float) to DPT14 (32-bit float) by Adrian Scillato (#9811, #9888) @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. ### Fixed - KNX ESP32 UDP mulicastpackage (#9811) +- Command ``gpio`` using non-indexed functions regression from v9.1.0 (#9962) ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c11f7a39a..d472c210b 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -65,6 +65,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Zigbee command ``ZbLeave`` to unpair a device - Zigbee support for Mi Door and Contact (#9759) - Zigbee alarm persistence (#9785) +- Zigbee persistence of device/sensor data in EEPROM (only ZBBridge) - Support for additional EZO sensors by Christopher Tremblay - Support for AS608 optical and R503 capacitive fingerprint sensor - Support for Shelly Dimmer 1 and 2 by James Turton (#9854) @@ -80,6 +81,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - MQTT Wifi connection timeout from 5000 to 200 mSec (#9886) ### Fixed +- Command ``gpio`` using non-indexed functions regression from v9.1.0 (#9962) - NTP fallback server functionality (#9739) - Telegram group chatid not supported (#9831) - KNX buttons, switches and sensors detection regression from v9.1.0 (#9811) diff --git a/tasmota/support.ino b/tasmota/support.ino index 0fcd45cc8..6c05162b8 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1380,7 +1380,7 @@ void GetInternalTemplate(void* ptr, uint32_t module, uint32_t option) { } #endif // ESP8266 -void ModuleGpios(myio *gp) +void TemplateGpios(myio *gp) { uint16_t *dest = (uint16_t *)gp; uint16_t src[ARRAY_SIZE(Settings.user_template.gp.io)]; diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index d137fd5be..1be2c6588 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1132,20 +1132,21 @@ void CmndModules(void) void CmndGpio(void) { if (XdrvMailbox.index < ARRAY_SIZE(Settings.my_gp.io)) { - myio cmodule; - ModuleGpios(&cmodule); - if (ValidGPIO(XdrvMailbox.index, cmodule.io[XdrvMailbox.index]) && (XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < AGPIO(GPIO_SENSOR_END))) { + myio template_gp; + TemplateGpios(&template_gp); + if (ValidGPIO(XdrvMailbox.index, template_gp.io[XdrvMailbox.index]) && (XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < AGPIO(GPIO_SENSOR_END))) { bool present = false; for (uint32_t i = 0; i < ARRAY_SIZE(kGpioNiceList); i++) { uint32_t midx = pgm_read_word(kGpioNiceList + i); - if ((XdrvMailbox.payload >= (midx & 0xFFE0)) && (XdrvMailbox.payload < midx)) { + uint32_t max_midx = ((midx & 0x001F) > 0) ? midx : midx +1; + if ((XdrvMailbox.payload >= (midx & 0xFFE0)) && (XdrvMailbox.payload < max_midx)) { present = true; break; } } if (present) { for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) { - if (ValidGPIO(i, cmodule.io[i]) && (Settings.my_gp.io[i] == XdrvMailbox.payload)) { + if (ValidGPIO(i, template_gp.io[i]) && (Settings.my_gp.io[i] == XdrvMailbox.payload)) { Settings.my_gp.io[i] = GPIO_NONE; } } @@ -1156,12 +1157,12 @@ void CmndGpio(void) Response_P(PSTR("{")); bool jsflg = false; for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) { - if (ValidGPIO(i, cmodule.io[i]) || ((255 == XdrvMailbox.payload) && !FlashPin(i))) { + if (ValidGPIO(i, template_gp.io[i]) || ((255 == XdrvMailbox.payload) && !FlashPin(i))) { if (jsflg) { ResponseAppend_P(PSTR(",")); } jsflg = true; uint32_t sensor_type = Settings.my_gp.io[i]; - if (!ValidGPIO(i, cmodule.io[i])) { - sensor_type = cmodule.io[i]; + if (!ValidGPIO(i, template_gp.io[i])) { + sensor_type = template_gp.io[i]; if (AGPIO(GPIO_USER) == sensor_type) { // A user GPIO equals a not connected (=GPIO_NONE) GPIO here sensor_type = GPIO_NONE; } diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index b62c19b39..c402e00b2 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1513,8 +1513,8 @@ void GpioInit(void) } } - myio def_gp; - ModuleGpios(&def_gp); + myio template_gp; + TemplateGpios(&template_gp); for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) { if ((Settings.my_gp.io[i] >= AGPIO(GPIO_SENSOR_END)) && (Settings.my_gp.io[i] < AGPIO(GPIO_USER))) { Settings.my_gp.io[i] = GPIO_NONE; // Fix not supported sensor ids in module @@ -1522,8 +1522,8 @@ void GpioInit(void) else if (Settings.my_gp.io[i] > GPIO_NONE) { TasmotaGlobal.my_module.io[i] = Settings.my_gp.io[i]; // Set User selected Module sensors } - if ((def_gp.io[i] > GPIO_NONE) && (def_gp.io[i] < AGPIO(GPIO_USER))) { - TasmotaGlobal.my_module.io[i] = def_gp.io[i]; // Force Template override + if ((template_gp.io[i] > GPIO_NONE) && (template_gp.io[i] < AGPIO(GPIO_USER))) { + TasmotaGlobal.my_module.io[i] = template_gp.io[i]; // Force Template override } } diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index bf08d61e3..ae7e72072 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -1806,16 +1806,16 @@ void HandleTemplateConfiguration(void) uint32_t module = atoi(stemp); uint32_t module_save = Settings.module; Settings.module = module; - myio cmodule; - ModuleGpios(&cmodule); + myio template_gp; + TemplateGpios(&template_gp); gpio_flag flag = ModuleFlag(); Settings.module = module_save; WSContentBegin(200, CT_PLAIN); WSContentSend_P(PSTR("%s}1"), AnyModuleName(module).c_str()); // NAME: Generic - for (uint32_t i = 0; i < ARRAY_SIZE(cmodule.io); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255 + for (uint32_t i = 0; i < ARRAY_SIZE(template_gp.io); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255 if (!FlashPin(i)) { - WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", cmodule.io[i]); + WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", template_gp.io[i]); } } WSContentSend_P(PSTR("}1%d}1%d"), flag, Settings.user_template_base); // FLAG: 1 BASE: 17 @@ -1936,8 +1936,8 @@ void HandleModuleConfiguration(void) char stemp[30]; // Sensor name uint32_t midx; - myio cmodule; - ModuleGpios(&cmodule); + myio template_gp; + TemplateGpios(&template_gp); WSContentStart_P(PSTR(D_CONFIGURE_MODULE)); WSContentSend_P(HTTP_SCRIPT_MODULE_TEMPLATE); @@ -1958,8 +1958,8 @@ void HandleModuleConfiguration(void) WSContentSendNiceLists(0); - for (uint32_t i = 0; i < ARRAY_SIZE(cmodule.io); i++) { - if (ValidGPIO(i, cmodule.io[i])) { + for (uint32_t i = 0; i < ARRAY_SIZE(template_gp.io); i++) { + if (ValidGPIO(i, template_gp.io[i])) { WSContentSend_P(PSTR("sk(%d,%d);"), TasmotaGlobal.my_module.io[i], i); // g0 - g17 } } @@ -1975,8 +1975,8 @@ void HandleModuleConfiguration(void) WSContentSendStyle(); WSContentSend_P(HTTP_FORM_MODULE, AnyModuleName(MODULE).c_str()); - for (uint32_t i = 0; i < ARRAY_SIZE(cmodule.io); i++) { - if (ValidGPIO(i, cmodule.io[i])) { + for (uint32_t i = 0; i < ARRAY_SIZE(template_gp.io); i++) { + if (ValidGPIO(i, template_gp.io[i])) { snprintf_P(stemp, 3, PINS_WEMOS +i*2); WSContentSend_P(PSTR("%s " D_GPIO "%d"), (WEMOS==TasmotaGlobal.module_type)?stemp:"", i, i, i); @@ -1998,14 +1998,14 @@ void ModuleSaveSettings(void) Settings.last_module = Settings.module; Settings.module = new_module; SetModuleType(); - myio cmodule; - ModuleGpios(&cmodule); + myio template_gp; + TemplateGpios(&template_gp); String gpios = ""; - for (uint32_t i = 0; i < ARRAY_SIZE(cmodule.io); i++) { + for (uint32_t i = 0; i < ARRAY_SIZE(template_gp.io); i++) { if (Settings.last_module != new_module) { Settings.my_gp.io[i] = GPIO_NONE; } else { - if (ValidGPIO(i, cmodule.io[i])) { + if (ValidGPIO(i, template_gp.io[i])) { Settings.my_gp.io[i] = WebGetGpioArg(i); gpios += F(", " D_GPIO ); gpios += String(i); gpios += F(" "); gpios += String(Settings.my_gp.io[i]); }