From 36fa0e9517080f7c44b5273cb5b5502d3a356e7d Mon Sep 17 00:00:00 2001 From: andrethomas Date: Fri, 29 Nov 2019 21:20:33 +0200 Subject: [PATCH 1/6] TasmotaSlave: Bugfix for Tele & add support for Commands --- tasmota/xdrv_31_tasmota_slave.ino | 34 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tasmota/xdrv_31_tasmota_slave.ino b/tasmota/xdrv_31_tasmota_slave.ino index daa5586b85e2..2f5369a1268b 100644 --- a/tasmota/xdrv_31_tasmota_slave.ino +++ b/tasmota/xdrv_31_tasmota_slave.ino @@ -47,6 +47,7 @@ #define CMND_FUNC_EVERY_100_MSECOND 0x04 #define CMND_SLAVE_SEND 0x05 #define CMND_PUBLISH_TELE 0x06 +#define CMND_EXECUTE_CMND 0x07 #define PARAM_DATA_START 0xFE #define PARAM_DATA_END 0xFF @@ -142,6 +143,7 @@ struct TSLAVE { bool flashing = false; bool SerialEnabled = false; uint8_t waitstate = 0; // We use this so that features detection does not slow down other stuff on startup + bool unsupported = false; } TSlave; typedef union { @@ -461,9 +463,14 @@ void TasmotaSlave_Init(void) TasmotaSlave_Serial->readBytesUntil(char(PARAM_DATA_START), buffer, sizeof(buffer)); uint8_t len = TasmotaSlave_Serial->readBytesUntil(char(PARAM_DATA_END), buffer, sizeof(buffer)); memcpy(&TSlaveSettings, &buffer, sizeof(TSlaveSettings)); - if (20191101 == TSlaveSettings.features_version) { + if (20191129 == TSlaveSettings.features_version) { TSlave.type = true; AddLog_P2(LOG_LEVEL_INFO, PSTR("Tasmota Slave Version %u"), TSlaveSettings.features_version); + } else { + if ((!TSlave.unsupported) && (TSlaveSettings.features_version > 0)) { + AddLog_P2(LOG_LEVEL_INFO, PSTR("Tasmota Slave Version %u not supported!"), TSlaveSettings.features_version); + TSlave.unsupported = true; + } } } } @@ -506,8 +513,9 @@ void (* const TasmotaSlaveCommand[])(void) PROGMEM = { void CmndTasmotaSlaveReset(void) { TasmotaSlave_Reset(); - TSlave.type = false; // Force redetection - TSlave.waitstate = 7; // give it at least 3 seconds to restart from bootloader + TSlave.type = false; // Force redetection + TSlave.waitstate = 7; // give it at least 3 seconds to restart from bootloader + TSlave.unsupported = false; // Reset unsupported flag ResponseCmndDone(); } @@ -536,21 +544,25 @@ void TasmotaSlave_ProcessIn(void) } TasmotaSlave_Serial->read(); // read trailing byte of command memcpy(&TSlaveCommand, &buffer, sizeof(TSlaveCommand)); + char inbuf[TSlaveCommand.parameter+1]; + TasmotaSlave_waitForSerialData(TSlaveCommand.parameter, 50); + TasmotaSlave_Serial->read(); // Read leading byte + for (uint8_t idx = 0; idx < TSlaveCommand.parameter; idx++) { + inbuf[idx] = TasmotaSlave_Serial->read(); + } + TasmotaSlave_Serial->read(); // Read trailing byte + inbuf[TSlaveCommand.parameter] = '\0'; + if (CMND_PUBLISH_TELE == TSlaveCommand.command) { // We need to publish stat/ with incoming stream as content - char inbuf[sizeof(TSlaveCommand.parameter)+1]; - TasmotaSlave_waitForSerialData(TSlaveCommand.parameter, 50); - TasmotaSlave_Serial->read(); // Read leading byte - for (uint8_t idx = 0; idx < TSlaveCommand.parameter; idx++) { - inbuf[idx] = TasmotaSlave_Serial->read(); - } - TasmotaSlave_Serial->read(); // Read trailing byte - inbuf[TSlaveCommand.parameter] = '\0'; Response_P(PSTR("{\"TasmotaSlave\":")); ResponseAppend_P("%s", inbuf); ResponseJsonEnd(); MqttPublishPrefixTopic_P(RESULT_OR_TELE, mqtt_data); XdrvRulesProcess(); } + if (CMND_EXECUTE_CMND == TSlaveCommand.command) { // We need to execute the incoming command + ExecuteCommand(inbuf, SRC_IGNORE); + } break; default: break; From bffe8f0c8d6e83655636d4a8f07599cff9f2c1be Mon Sep 17 00:00:00 2001 From: Andre Thomas <470015+andrethomas@users.noreply.github.com> Date: Fri, 29 Nov 2019 21:24:13 +0200 Subject: [PATCH 2/6] Update CHANGELOG.md --- tasmota/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 259095dc3783..56f3c146e1e1 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -1,5 +1,7 @@ ## Unreleased (development) +- TasmotaSlave bugfix for buffer overrun on Tele +- TasmotaSlave add support for executing commands on Tasmota ## Released From 459b45bb27663637fa509b9fbe74495fded0de75 Mon Sep 17 00:00:00 2001 From: Adrian Scillato <39969427+ascillato2@users.noreply.github.com> Date: Fri, 29 Nov 2019 20:18:26 -0300 Subject: [PATCH 3/6] Fix grammar in Bot Message --- .github/issue-close-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/issue-close-app.yml b/.github/issue-close-app.yml index 0fcb996abaa6..8e981441b367 100644 --- a/.github/issue-close-app.yml +++ b/.github/issue-close-app.yml @@ -10,7 +10,7 @@ comment: >- Filling the template is required so standard questions don't need to be asked again each time. Our ability to provide assistance is greatly hampered if few minutes are not taken to complete the issue template with the requested information. The details requested potentially affect which options to pursue. The small amount - of time you spend completing the template will also help the volunteers providing the assistance to you, to reduce + of time you will spend completing the template will also help the volunteers, providing assistance to you, to reduce the time required to help you. Please, could you be so kind on completing the [issue template](https://github.com/arendst/Tasmota/issues/new/choose) in order to have more information so as to properly help you? From 09f91044658cc46ee4e31357173745d01b555e26 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 30 Nov 2019 15:36:15 +0100 Subject: [PATCH 4/6] Bump version 7.1.0.1 --- tasmota/CHANGELOG.md | 1 + tasmota/tasmota_version.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 259095dc3783..2810f33736b9 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -1,5 +1,6 @@ ## Unreleased (development) +### 7.1.0.1 20191130 ## Released diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index bb71cb5f2a9b..7484f5bc9210 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,6 +20,6 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x07010000; +const uint32_t VERSION = 0x07010001; #endif // _TASMOTA_VERSION_H_ From 5524075b04e28548e71254ae01205a58d02ecaac Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 30 Nov 2019 16:05:09 +0100 Subject: [PATCH 5/6] Fix slider for devices without RGB Fix slider for devices with one or two channels like only white or white/yellow --- tasmota/CHANGELOG.md | 2 ++ tasmota/xdrv_01_webserver.ino | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 2810f33736b9..235471a07e24 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -2,6 +2,8 @@ ### 7.1.0.1 20191130 +- Fix slider for devices with one or two channels like only white or white/yellow + ## Released ### 7.1.0 20191129 diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 42630b8baa53..48e2cd26af76 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -154,9 +154,11 @@ const char HTTP_SCRIPT_ROOT[] PROGMEM = const char HTTP_SCRIPT_ROOT_PART2[] PROGMEM = "function lc(v,i,p){" - "if(v=='h'||v=='d'){" // Hue or Brightness changed so change Saturation colors too - "var sl=eb('sl4').value;" - "eb('s').style.background='linear-gradient(to right,rgb('+sl+'%%,'+sl+'%%,'+sl+'%%),hsl('+eb('sl2').value+',100%%,50%%))';" + "if(eb('s')){" // Check if Saturation is in DOM otherwise javascript fails on la() + "if(v=='h'||v=='d'){" // Hue or Brightness changed so change Saturation colors too + "var sl=eb('sl4').value;" + "eb('s').style.background='linear-gradient(to right,rgb('+sl+'%%,'+sl+'%%,'+sl+'%%),hsl('+eb('sl2').value+',100%%,50%%))';" + "}" "}" "la('&'+v+i+'='+p);" "}" From 8cf2d15ed1c09645cc1c33fca9a6376ed4b635f0 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 30 Nov 2019 17:53:49 +0100 Subject: [PATCH 6/6] Fix light scheme 4 speed Fix light scheme 4 speed (#7072) --- tasmota/CHANGELOG.md | 1 + tasmota/xdrv_04_light.ino | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index c5aa2355de39..e9949c4f5ec4 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix slider for devices with one or two channels like only white or white/yellow - Fix TasmotaSlave buffer overrun on Tele +- Fix light scheme 4 speed (#7072) - Add support for TasmotaSlave executing commands on Tasmota ## Released diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 695815d710f6..b50d8e4dfa0e 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -242,6 +242,7 @@ struct LIGHT { uint8_t color_remap[LST_MAX]; uint8_t wheel = 0; + uint8_t random = 0; uint8_t subtype = 0; // LST_ subtype uint8_t device = 0; uint8_t old_power = 1; @@ -1541,26 +1542,17 @@ void LightCycleColor(int8_t direction) if (Light.strip_timer_counter % (Settings.light_speed * 2)) { return; } - Light.wheel += direction; - LightWheel(Light.wheel); - memcpy(Light.new_color, Light.entry_color, sizeof(Light.new_color)); -} -void LightRandomColor(void) -{ - bool update = false; - for (uint32_t i = 0; i < LST_RGB; i++) { - if (Light.new_color[i] != Light.current_color[i]) { - update = true; + if (0 == direction) { + if (Light.random == Light.wheel) { + Light.random = random(255); } + Light.wheel += (Light.random < Light.wheel) ? -1 : 1; + } else { + Light.wheel += direction; } - if (!update) { - Light.wheel = random(255); - LightWheel(Light.wheel); - memcpy(Light.current_color, Light.entry_color, sizeof(Light.current_color)); - } - - memcpy(Light.new_color, Light.current_color, sizeof(Light.new_color)); + LightWheel(Light.wheel); + memcpy(Light.new_color, Light.entry_color, sizeof(Light.new_color)); } void LightSetPower(void) @@ -1652,7 +1644,7 @@ void LightAnimate(void) LightCycleColor(-1); break; case LS_RANDOM: - LightRandomColor(); + LightCycleColor(0); break; default: XlgtCall(FUNC_SET_SCHEME);