From c72bf5aa096b051283ca2c7e122d8d830a405cc6 Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Tue, 26 Jan 2021 19:12:11 +0000 Subject: [PATCH 01/30] Make USE_BLE_ESP32 the default for sensors. --- tasmota/tasmota_configurations.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index fd04983ec..0f4a23d0e 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -170,6 +170,8 @@ #define USE_IBEACON // Add support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) //#define USE_GPS // Add support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #define USE_HM10 // (ESP8266 only) Add support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) + +#define USE_BLE_ESP32 // (ESP32 only) Add support for native BLE on ESP32 - use new driver #define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #define USE_HRXL // Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) //#define USE_TASMOTA_CLIENT // Add support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -233,6 +235,7 @@ #undef USE_EMULATION_WEMO // Disable Belkin WeMo emulation for Alexa (+6k code, +2k mem common) #undef USE_DEEPSLEEP // Disable support for deepsleep (+1k code) #undef USE_DEVICE_GROUPS // Disable support for device groups (+3k5 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_PWM_DIMMER_REMOTE // Disbale support for remote switches to PWM Dimmer @@ -292,6 +295,7 @@ #undef USE_TELEINFO // Disable support for French Energy Provider metering telemetry #undef USE_IEM3000 // Disable support for Schneider Electric iEM3000-Modbus series energy monitor (+0k8 code) #undef USE_WE517 // Disable support for Orno WE517-Modbus energy monitor (+1k code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) @@ -416,6 +420,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -544,6 +549,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -681,6 +687,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -820,6 +827,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) From 79bf2f6aa3e424aaf2898e4caa0d3bc7fcb83b5d Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Tue, 26 Jan 2021 20:02:42 +0000 Subject: [PATCH 02/30] belt and braces fix test failure --- tasmota/tasmota_configurations.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 0f4a23d0e..de60b84e1 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -170,9 +170,10 @@ #define USE_IBEACON // Add support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) //#define USE_GPS // Add support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #define USE_HM10 // (ESP8266 only) Add support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) - -#define USE_BLE_ESP32 // (ESP32 only) Add support for native BLE on ESP32 - use new driver -#define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) +#ifdef ESP32 + #define USE_BLE_ESP32 // (ESP32 only) Add support for native BLE on ESP32 - use new driver + #define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) +#endif #define USE_HRXL // Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) //#define USE_TASMOTA_CLIENT // Add support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) //#define USE_OPENTHERM // Add support for OpenTherm (+15k code) From 8e3061ba6f3cfbba8020f2059cd1127ae1442cfd Mon Sep 17 00:00:00 2001 From: lonmi Date: Wed, 27 Jan 2021 06:37:28 +0000 Subject: [PATCH 03/30] Fix PMS3003 sensor message lenght and CRC chk --- tasmota/xsns_18_pms5003.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tasmota/xsns_18_pms5003.ino b/tasmota/xsns_18_pms5003.ino index d689c5a41..d9b37e80a 100644 --- a/tasmota/xsns_18_pms5003.ino +++ b/tasmota/xsns_18_pms5003.ino @@ -98,7 +98,7 @@ bool PmsReadData(void) PmsSerial->read(); } #ifdef PMS_MODEL_PMS3003 - if (PmsSerial->available() < 22) { + if (PmsSerial->available() < 24) { #else if (PmsSerial->available() < 32) { #endif // PMS_MODEL_PMS3003 @@ -106,8 +106,8 @@ bool PmsReadData(void) } #ifdef PMS_MODEL_PMS3003 - uint8_t buffer[22]; - PmsSerial->readBytes(buffer, 22); + uint8_t buffer[24]; + PmsSerial->readBytes(buffer, 24); #else uint8_t buffer[32]; PmsSerial->readBytes(buffer, 32); @@ -116,14 +116,14 @@ bool PmsReadData(void) PmsSerial->flush(); // Make room for another burst #ifdef PMS_MODEL_PMS3003 - AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 22); + AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 24); #else AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 32); #endif // PMS_MODEL_PMS3003 // get checksum ready #ifdef PMS_MODEL_PMS3003 - for (uint32_t i = 0; i < 20; i++) { + for (uint32_t i = 0; i < 22; i++) { #else for (uint32_t i = 0; i < 30; i++) { #endif // PMS_MODEL_PMS3003 @@ -131,8 +131,8 @@ bool PmsReadData(void) } // The data comes in endian'd, this solves it so it works on all platforms #ifdef PMS_MODEL_PMS3003 - uint16_t buffer_u16[10]; - for (uint32_t i = 0; i < 10; i++) { + uint16_t buffer_u16[12]; + for (uint32_t i = 0; i < 12; i++) { #else uint16_t buffer_u16[15]; for (uint32_t i = 0; i < 15; i++) { @@ -141,7 +141,7 @@ bool PmsReadData(void) buffer_u16[i] += (buffer[2 + i*2] << 8); } #ifdef PMS_MODEL_PMS3003 - if (sum != buffer_u16[9]) { + if (sum != buffer_u16[10]) { #else if (sum != buffer_u16[14]) { #endif // PMS_MODEL_PMS3003 @@ -150,7 +150,7 @@ bool PmsReadData(void) } #ifdef PMS_MODEL_PMS3003 - memcpy((void *)&pms_data, (void *)buffer_u16, 20); + memcpy((void *)&pms_data, (void *)buffer_u16, 22); #else memcpy((void *)&pms_data, (void *)buffer_u16, 30); #endif // PMS_MODEL_PMS3003 From ff2e1196b5af8ebec020878af35e4659addc941c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 10:00:25 +0100 Subject: [PATCH 04/30] Update changelog --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54144e094..6aa433d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Added - Function ``AddLog`` to provide logging for up to 128 (LOGSZ) characters to save stack space - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively +- Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively ### Changed - Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 121264b82..66388ab4d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -66,6 +66,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Command ``SetOption118 1`` to move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default [#10353](https://github.com/arendst/Tasmota/issues/10353) - Command ``SetOption119 1`` to remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic [#10355](https://github.com/arendst/Tasmota/issues/10355) - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively +- Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively - Milliseconds to console output [#10152](https://github.com/arendst/Tasmota/issues/10152) - Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196) - Rotary No Pullup GPIO selection ``Rotary A/B_n`` [#10407](https://github.com/arendst/Tasmota/issues/10407) From 34b9726c36df47cc7a1a5e6ffce02a813e2b3e36 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 10:38:45 +0100 Subject: [PATCH 05/30] Clarify file name functionality --- ...52_BLE_ESP32.ino => xdrv_79_esp32_ble.ino} | 33 ++++++++----------- ...droidgo.ino => xdrv_80_esp32_odroidgo.ino} | 4 +-- ...81_webcam.ino => xdrv_81_esp32_webcam.ino} | 2 +- ...thernet.ino => xdrv_82_esp32_ethernet.ino} | 2 +- ...esp32watch.ino => xdrv_83_esp32_watch.ino} | 2 +- ...v_84_core2.ino => xdrv_84_esp32_core2.ino} | 2 +- 6 files changed, 20 insertions(+), 25 deletions(-) rename tasmota/{xdrv_52_BLE_ESP32.ino => xdrv_79_esp32_ble.ino} (99%) rename tasmota/{xdrv_80_odroidgo.ino => xdrv_80_esp32_odroidgo.ino} (91%) rename tasmota/{xdrv_81_webcam.ino => xdrv_81_esp32_webcam.ino} (99%) mode change 100755 => 100644 rename tasmota/{xdrv_82_ethernet.ino => xdrv_82_esp32_ethernet.ino} (99%) rename tasmota/{xdrv_83_esp32watch.ino => xdrv_83_esp32_watch.ino} (99%) rename tasmota/{xdrv_84_core2.ino => xdrv_84_esp32_core2.ino} (99%) diff --git a/tasmota/xdrv_52_BLE_ESP32.ino b/tasmota/xdrv_79_esp32_ble.ino similarity index 99% rename from tasmota/xdrv_52_BLE_ESP32.ino rename to tasmota/xdrv_79_esp32_ble.ino index 162c434f9..3452d67d5 100644 --- a/tasmota/xdrv_52_BLE_ESP32.ino +++ b/tasmota/xdrv_79_esp32_ble.ino @@ -1,5 +1,5 @@ /* - xdrv_52_BLE_ESP32.ino - BLE via ESP32 support for Tasmota + xdrv_79_esp32_ble.ino - BLE via ESP32 support for Tasmota Copyright (C) 2020 Christian Baars and Theo Arends and Simon Hailes @@ -22,8 +22,18 @@ -------------------------------------------------------------------------------------------- */ +// TEMPORARILY define ESP32 and USE_BLE_ESP32 so VSCODE shows highlighting.... +//#define VSCODE_DEV +#ifdef VSCODE_DEV +#define ESP32 +#define USE_BLE_ESP32 +#endif + +#ifdef ESP32 // ESP32 only. Use define USE_HM10 for ESP8266 support +#ifdef USE_BLE_ESP32 + /* - xdrv_52: + xdrv_79: This driver uses the ESP32 BLE functionality to hopefully provide enough BLE functionality to implement specific drivers on top of it. @@ -80,27 +90,12 @@ i.e. the Bluetooth of the ESP can be shared without conflict. */ - -// TEMPORARILY define ESP32 and USE_BLE_ESP32 so VSCODE shows highlighting.... -//#define VSCODE_DEV - -#ifdef VSCODE_DEV -#define ESP32 -#define USE_BLE_ESP32 -#endif - -#ifdef ESP32 // ESP32 only. Use define USE_HM10 for ESP8266 support - -#ifdef USE_BLE_ESP32 - #define BLE_ESP32_ALIASES // uncomment for more diagnostic/information messages - + more flash use. //#define BLE_ESP32_DEBUG - - -#define XDRV_52 52 +#define XDRV_79 79 #define USE_MI_DECRYPTION #include @@ -3456,7 +3451,7 @@ int ExtStopBLE(){ return 0; } -bool Xdrv52(uint8_t function) +bool Xdrv79(uint8_t function) { //if (!Settings.flag5.mi32_enable) { return false; } // SetOption115 - Enable ESP32 BLE BLE diff --git a/tasmota/xdrv_80_odroidgo.ino b/tasmota/xdrv_80_esp32_odroidgo.ino similarity index 91% rename from tasmota/xdrv_80_odroidgo.ino rename to tasmota/xdrv_80_esp32_odroidgo.ino index e1d7ed412..bd7fd8cc1 100644 --- a/tasmota/xdrv_80_odroidgo.ino +++ b/tasmota/xdrv_80_esp32_odroidgo.ino @@ -1,7 +1,7 @@ /* - xdrv_81_webcam.ino - ESP32 webcam support for Tasmota + xdrv_81_esp32_odroidgo.ino - ESP32 odroid go support for Tasmota - Copyright (C) 2021 Gerhard Mutz and Theo Arends + Copyright (C) 2021 Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tasmota/xdrv_81_webcam.ino b/tasmota/xdrv_81_esp32_webcam.ino old mode 100755 new mode 100644 similarity index 99% rename from tasmota/xdrv_81_webcam.ino rename to tasmota/xdrv_81_esp32_webcam.ino index 0844b1ba9..97f88b9d3 --- a/tasmota/xdrv_81_webcam.ino +++ b/tasmota/xdrv_81_esp32_webcam.ino @@ -1,5 +1,5 @@ /* - xdrv_81_webcam.ino - ESP32 webcam support for Tasmota + xdrv_81_esp32_webcam.ino - ESP32 webcam support for Tasmota Copyright (C) 2021 Gerhard Mutz and Theo Arends diff --git a/tasmota/xdrv_82_ethernet.ino b/tasmota/xdrv_82_esp32_ethernet.ino similarity index 99% rename from tasmota/xdrv_82_ethernet.ino rename to tasmota/xdrv_82_esp32_ethernet.ino index abb6922ad..c537fae05 100644 --- a/tasmota/xdrv_82_ethernet.ino +++ b/tasmota/xdrv_82_esp32_ethernet.ino @@ -1,5 +1,5 @@ /* - xdrv_82_ethernet.ino - ESP32 (PoE) ethernet support for Tasmota + xdrv_82_esp32_ethernet.ino - ESP32 (PoE) ethernet support for Tasmota Copyright (C) 2021 Theo Arends diff --git a/tasmota/xdrv_83_esp32watch.ino b/tasmota/xdrv_83_esp32_watch.ino similarity index 99% rename from tasmota/xdrv_83_esp32watch.ino rename to tasmota/xdrv_83_esp32_watch.ino index e452e1b74..70cc1a912 100644 --- a/tasmota/xdrv_83_esp32watch.ino +++ b/tasmota/xdrv_83_esp32_watch.ino @@ -1,5 +1,5 @@ /* - xdrv_83_esp32watch.ino - ESP32 TTGO watch support for Tasmota + xdrv_83_esp32_watch.ino - ESP32 TTGO watch support for Tasmota Copyright (C) 2021 Gerhard Mutz and Theo Arends diff --git a/tasmota/xdrv_84_core2.ino b/tasmota/xdrv_84_esp32_core2.ino similarity index 99% rename from tasmota/xdrv_84_core2.ino rename to tasmota/xdrv_84_esp32_core2.ino index da3e202e9..dc196536c 100644 --- a/tasmota/xdrv_84_core2.ino +++ b/tasmota/xdrv_84_esp32_core2.ino @@ -1,5 +1,5 @@ /* - xdrv_84_core2.ino - ESP32 m5stack core2 support for Tasmota + xdrv_84_esp32_core2.ino - ESP32 m5stack core2 support for Tasmota Copyright (C) 2021 Gerhard Mutz and Theo Arends From 60094eb0eed79e5931e2e984e73919558cc4d509 Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Wed, 27 Jan 2021 10:16:30 +0000 Subject: [PATCH 06/30] rename + soime explaination --- tasmota/xdrv_79_esp32_ble.ino | 38 ++++++++----------- ...SP32.ino => xsns_52_esp32_ibeacon_ble.ino} | 6 ++- ...s_62_MI_ESP32.ino => xsns_62_esp32_mi.ino} | 4 +- ...BLE_ESP32.ino => xsns_62_esp32_mi_ble.ino} | 9 ++++- 4 files changed, 30 insertions(+), 27 deletions(-) rename tasmota/{xsns_52_ibeacon_BLE_ESP32.ino => xsns_52_esp32_ibeacon_ble.ino} (99%) rename tasmota/{xsns_62_MI_ESP32.ino => xsns_62_esp32_mi.ino} (99%) rename tasmota/{xsns_62_MI_ESP32_BLE_ESP32.ino => xsns_62_esp32_mi_ble.ino} (99%) diff --git a/tasmota/xdrv_79_esp32_ble.ino b/tasmota/xdrv_79_esp32_ble.ino index 3452d67d5..9c96da9b0 100644 --- a/tasmota/xdrv_79_esp32_ble.ino +++ b/tasmota/xdrv_79_esp32_ble.ino @@ -45,34 +45,26 @@ connect/read/awaitnotify from a MAC/Service/Characteristic/NotifyCharacteristic Cmnds: - BLEOp0 - requests status of operations - BLEOp1 MAC - create an operation in preparation, and populate it's MAC address - BLEOp2 Service - add a serviceUUID to the operation in preparation - BLEOp3 Characteristic - add a CharacteristicUUID to the operation in preparation for read/write - BLEOp4 writedata - optional:add data to write to the operation in preparation - hex string - BLEOp5 - optional:signify that a read should be done - BLEOp6 NotifyCharacteristic - optional:add a NotifyCharacteristicUUID to the operation in preparation to wait for a notify - BLEOp9 - publish the 'operation in preparation' to MQTT. - BLEOp10 - add the 'operation in preparation' to the queue of operations to perform. + BLEPeriod + BLEAdv + BLEOp + BLEMode + BLEDetails + BLEScan + BLEAlias + BLEName + BLEDebug + BLEDevices + BLEMaxAge + BLEAddrFilter Other drivers can add callbacks to receive advertisements Other drivers can add 'operations' to be performed and receive callbacks from the operation's success or failure -Example: +Example BLEOp: Write and request next notify: -backlog BLEOp1 001A22092EE0; BLEOp2 3e135142-654f-9090-134a-a6ff5bb77046; BLEOp3 3fa4585a-ce4a-3bad-db4b-b8df8179ea09; BLEOp4 03; BLEOp6 d0e8434d-cd29-0996-af41-6c90f4e0eb2a; -BLEOp10 -> -19:25:08 RSL: tele/tasmota_E89E98/SENSOR = {"BLEOperation":{"opid":"3,"state":"1,"MAC":"001A22092EE0","svc":"3e135142-654f-9090-134a-a6ff5bb77046","char":"3fa4585a-ce4a-3bad-db4b-b8df8179ea09","wrote":"03}} -19:25:08 queued 0 sent {"BLEOperation":{"opid":"3,"state":"1,"MAC":"001A22092EE0","svc":"3e135142-654f-9090-134a-a6ff5bb77046","char":"3fa4585a-ce4a-3bad-db4b-b8df8179ea09","wrote":"03}} -19:25:08 RSL: stat/tasmota_E89E98/RESULT = {"BLEOp":"Done"} -..... -19:25:11 RSL: tele/tasmota_E89E98/SENSOR = {"BLEOperation":{"opid":"3,"state":"11,"MAC":"001A22092EE0","svc":"3e135142-654f-9090-134a-a6ff5bb77046","char":"3fa4585a-ce4a-3bad-db4b-b8df8179ea09","wrote":"03","notify":"020109000428}} - -state: 1 -> starting, -7 -> read complete -8 -> write complete -11 -> notify complete --ve + -> failure (see GEN_STATE_FAILED_XXXX constants below.) +BLEOp M:4C65A8DAF43A s:00001530-1212-efde-1523-785feabcd123 n:00001531-1212-efde-1523-785feabcd123 c:00001531-1212-efde-1523-785feabcd123 w:00 go +12:45:12 MQT: tele/tasmota_esp32/BLE = {"BLEOperation":{"opid":"11","stat":"7","state":"DONENOTIFIED","MAC":"4C65A8DAF43A","svc":"00001530-1212-efde-1523-785feabcd123","char":"00001531-1212-efde-1523-785feabcd123","notifychar":"00001531-1212-efde-1523-785feabcd123","write":"00","notify":"100003"}} The driver can also be used by other drivers, using the functions: diff --git a/tasmota/xsns_52_ibeacon_BLE_ESP32.ino b/tasmota/xsns_52_esp32_ibeacon_ble.ino similarity index 99% rename from tasmota/xsns_52_ibeacon_BLE_ESP32.ino rename to tasmota/xsns_52_esp32_ibeacon_ble.ino index f869e6a20..d509332c5 100644 --- a/tasmota/xsns_52_ibeacon_BLE_ESP32.ino +++ b/tasmota/xsns_52_esp32_ibeacon_ble.ino @@ -1,5 +1,9 @@ /* - xsns_52_ibeacon.ino - Support for HM17 BLE Module + ibeacon reader on Tasmota + xsns_52_esp32_ibeacon_ble.ino + if (!USE_IBEACON_ESP32 && USE_BLE_ESP32) + - Support for HM17 BLE Module + ibeacon reader on Tasmota (untested?) + if (USE_IBEACON_ESP32 && USE_BLE_ESP32) + - Support for BLE_ESP32 ibeacon reader on Tasmota Copyright (C) 2020 Gerhard Mutz and Theo Arends diff --git a/tasmota/xsns_62_MI_ESP32.ino b/tasmota/xsns_62_esp32_mi.ino similarity index 99% rename from tasmota/xsns_62_MI_ESP32.ino rename to tasmota/xsns_62_esp32_mi.ino index 9e1b423d1..8665d6905 100644 --- a/tasmota/xsns_62_MI_ESP32.ino +++ b/tasmota/xsns_62_esp32_mi.ino @@ -1,5 +1,7 @@ /* - xsns_62_MI_ESP32.ino - MI-BLE-sensors via ESP32 support for Tasmota + xsns_62_esp32_mi.ino - MI-BLE-sensors via ESP32 support for Tasmota + enabled by ESP32 && !USE_BLE_ESP32 + if (ESP32 && USE_BLE_ESP32) then xsns_62_esp32_mi_ble.ino is used Copyright (C) 2021 Christian Baars and Theo Arends diff --git a/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino b/tasmota/xsns_62_esp32_mi_ble.ino similarity index 99% rename from tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino rename to tasmota/xsns_62_esp32_mi_ble.ino index f563e9f1a..528953e99 100644 --- a/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino +++ b/tasmota/xsns_62_esp32_mi_ble.ino @@ -1,5 +1,8 @@ /* - xsns_62_MI_ESP32.ino - MI-BLE-sensors via ESP32 support for Tasmota + xsns_62_esp32_mi_ble.ino - MI-BLE-sensors via ESP32 support for Tasmota + enabled by ESP32 && USE_BLE_ESP32 + if (ESP32 && !USE_BLE_ESP32) then xsns_62_esp32_mi.ino is used - the older driver + Copyright (C) 2020 Christian Baars and Theo Arends @@ -20,6 +23,8 @@ -------------------------------------------------------------------------------------------- Version yyyymmdd Action Description -------------------------------------------------------------------------------------------- + 0.9.2.0 20210127 changed - Officially includes as the mi driver when using USE_BLE_ESP32. + ------- 0.9.1.9 20201226 changed - All change now. ------- 0.9.1.7 20201116 changed - small bugfixes, add BLOCK and OPTION command, send BLE scan via MQTT @@ -2233,7 +2238,7 @@ void CmndMi32Keys(void){ * Presentation \*********************************************************************************************/ -const char HTTP_MI32[] PROGMEM = "{s}MI ESP32 v0918{m}%u%s / %u{e}"; +const char HTTP_MI32[] PROGMEM = "{s}MI ESP32 v0920{m}%u%s / %u{e}"; const char HTTP_MI32_ALIAS[] PROGMEM = "{s}%s Alias {m}%s{e}"; const char HTTP_MI32_MAC[] PROGMEM = "{s}%s %s{m}%s{e}"; const char HTTP_RSSI[] PROGMEM = "{s}%s " D_RSSI "{m}%d dBm{e}"; From db615c5b0ba0053c3991cf40dd47b0d484ac77ae Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 12:03:20 +0100 Subject: [PATCH 07/30] Refactor some IP addresses --- tasmota/i18n.h | 1 - tasmota/support_command.ino | 24 ++++++------------------ tasmota/support_udp.ino | 4 ++-- tasmota/support_wifi.ino | 4 ++-- tasmota/xdrv_01_webserver.ino | 20 ++++++++++---------- tasmota/xdrv_10_scripter.ino | 2 +- tasmota/xdrv_12_home_assistant.ino | 8 ++++---- tasmota/xdrv_13_display.ino | 2 +- 8 files changed, 26 insertions(+), 39 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 70329cfa2..d3f307069 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -742,7 +742,6 @@ const char S_JSON_COMMAND_INDEX_NVALUE[] PROGMEM = "{\"%s%d\":%d}"; const char S_JSON_COMMAND_INDEX_LVALUE[] PROGMEM = "{\"%s%d\":%lu}"; const char S_JSON_COMMAND_INDEX_SVALUE[] PROGMEM = "{\"%s%d\":\"%s\"}"; const char S_JSON_COMMAND_INDEX_ASTERISK[] PROGMEM = "{\"%s%d\":\"" D_ASTERISK_PWD "\"}"; -const char S_JSON_COMMAND_INDEX_SVALUE_SVALUE[] PROGMEM = "{\"%s%d\":\"%s%s\"}"; const char S_JSON_SENSOR_INDEX_NVALUE[] PROGMEM = "{\"" D_CMND_SENSOR "%d\":%d}"; const char S_JSON_SENSOR_INDEX_SVALUE[] PROGMEM = "{\"" D_CMND_SENSOR "%d\":\"%s\"}"; diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 0c0797d5e..87b2ad4f7 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -505,21 +505,12 @@ void CmndStatus(void) } if ((0 == payload) || (5 == payload)) { -/* - Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS5_NETWORK "\":{\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\",\"" D_JSON_GATEWAY "\":\"%s\",\"" - D_JSON_SUBNETMASK "\":\"%s\",\"" D_JSON_DNSSERVER "\":\"%s\",\"" D_JSON_MAC "\":\"%s\",\"" - D_CMND_WEBSERVER "\":%d,\"" D_CMND_WIFICONFIG "\":%d,\"" D_CMND_WIFIPOWER "\":%s}}"), - NetworkHostname(), NetworkAddress().toString().c_str(), IPAddress(Settings.ipv4_address[1]).toString().c_str(), - IPAddress(Settings.ipv4_address[2]).toString().c_str(), IPAddress(Settings.ipv4_address[3]).toString().c_str(), NetworkMacAddress().c_str(), - Settings.webserver, Settings.sta_config, WifiGetOutputPower().c_str()); -*/ - Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS5_NETWORK "\":{\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\",\"" + Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS5_NETWORK "\":{\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%_I\",\"" D_JSON_GATEWAY "\":\"%_I\",\"" D_JSON_SUBNETMASK "\":\"%_I\",\"" D_JSON_DNSSERVER "\":\"%_I\",\"" D_JSON_MAC "\":\"%s\",\"" D_CMND_WEBSERVER "\":%d,\"" D_CMND_WIFICONFIG "\":%d,\"" D_CMND_WIFIPOWER "\":%s}}"), - NetworkHostname(), NetworkAddress().toString().c_str(), + NetworkHostname(), (uint32_t)NetworkAddress(), Settings.ipv4_address[1], Settings.ipv4_address[2], Settings.ipv4_address[3], NetworkMacAddress().c_str(), Settings.webserver, Settings.sta_config, WifiGetOutputPower().c_str()); - MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "5")); } @@ -1517,23 +1508,20 @@ void CmndLogport(void) void CmndIpAddress(void) { if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 4)) { + char network_address[22]; + ext_snprintf_P(network_address, sizeof(network_address), PSTR(" = %_I"), (uint32_t)NetworkAddress()); if (!XdrvMailbox.usridx) { - char stemp1[TOPSZ]; - snprintf_P(stemp1, sizeof(stemp1), PSTR(" %s"), NetworkAddress().toString().c_str()); ResponseClear(); for (uint32_t i = 0; i < 4; i++) { - ResponseAppend_P(PSTR("%c\"%s%d\":\"%s%s\""), (i) ? ',' : '{', XdrvMailbox.command, i +1, IPAddress(Settings.ipv4_address[i]).toString().c_str(), (0 == i) ? stemp1:""); + ResponseAppend_P(PSTR("%c\"%s%d\":\"%_I%s\""), (i)?',':'{', XdrvMailbox.command, i +1, Settings.ipv4_address[i], (0 == i)?network_address:""); } ResponseJsonEnd(); } else { uint32_t ipv4_address; if (ParseIPv4(&ipv4_address, XdrvMailbox.data)) { Settings.ipv4_address[XdrvMailbox.index -1] = ipv4_address; -// TasmotaGlobal.restart_flag = 2; } - char stemp1[TOPSZ]; - snprintf_P(stemp1, sizeof(stemp1), PSTR(" %s"), NetworkAddress().toString().c_str()); - Response_P(S_JSON_COMMAND_INDEX_SVALUE_SVALUE, XdrvMailbox.command, XdrvMailbox.index, IPAddress(Settings.ipv4_address[XdrvMailbox.index -1]).toString().c_str(), (1 == XdrvMailbox.index) ? stemp1:""); + Response_P(PSTR("{\"%s%d\":\"%_I%s\"}"), XdrvMailbox.command, XdrvMailbox.index, Settings.ipv4_address[XdrvMailbox.index -1], (1 == XdrvMailbox.index)?network_address:""); } } } diff --git a/tasmota/support_udp.ino b/tasmota/support_udp.ino index 455b54b19..f9e89d7ab 100644 --- a/tasmota/support_udp.ino +++ b/tasmota/support_udp.ino @@ -151,8 +151,8 @@ void PollUdp(void) udp_remote_port = PortUdp.remotePort(); #endif - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: M-SEARCH Packet from %s:%d\n%s"), - // udp_remote_ip.toString().c_str(), udp_remote_port, packet_buffer); + // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: M-SEARCH Packet from %_I:%d\n%s"), + // (uint32_t)udp_remote_ip, udp_remote_port, packet_buffer); LowerCase(packet_buffer, packet_buffer); RemoveSpace(packet_buffer); diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index 1c6f1dbe6..804070103 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -748,7 +748,7 @@ uint32_t WifiGetNtp(void) { return 0; } -// AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: Name %s, IP %s"), ntp_server, time_server_ip.toString().c_str()); +// AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: Name %s, IP %_I"), ntp_server, (uint32_t)time_server_ip); WiFiUDP udp; @@ -798,7 +798,7 @@ uint32_t WifiGetNtp(void) { if ((packet_buffer[0] & 0b11000000) == 0b11000000) { // Leap-Indicator: unknown (clock unsynchronized) // See: https://github.com/letscontrolit/ESPEasy/issues/2886#issuecomment-586656384 - AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: IP %s unsynched"), time_server_ip.toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: IP %_I unsynched"), (uint32_t)time_server_ip); ntp_server_id++; // Next server next time return 0; } diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 0f7a14476..2598a295d 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -392,7 +392,7 @@ void ShowWebSource(uint32_t source) { if ((source > 0) && (source < SRC_MAX)) { char stemp1[20]; - AddLog(LOG_LEVEL_DEBUG, PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), Webserver->client().remoteIP().toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("SRC: %s from %_I"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), (uint32_t)Webserver->client().remoteIP()); } } @@ -736,10 +736,10 @@ void WSContentSendStyle_P(const char* formatP, ...) } WSContentSend_P(HTTP_HEAD_STYLE3, WebColor(COL_TEXT), #ifdef FIRMWARE_MINIMAL - WebColor(COL_TEXT_WARNING), + WebColor(COL_TEXT_WARNING), #endif - WebColor(COL_TITLE), - ModuleName().c_str(), SettingsText(SET_DEVICENAME)); + WebColor(COL_TITLE), + ModuleName().c_str(), SettingsText(SET_DEVICENAME)); if (Settings.flag3.gui_hostname_ip) { // SetOption53 - Show hostanme and IP address in GUI main menu bool lip = (static_cast(WiFi.localIP()) != 0); bool sip = (static_cast(WiFi.softAPIP()) != 0); @@ -2092,7 +2092,7 @@ void HandleInformation(void) if (static_cast(EthernetLocalIP()) != 0) { WSContentSend_P(PSTR("}1" D_HOSTNAME "}2%s%s"), EthernetHostname(), (Mdns.begun) ? PSTR(".local") : ""); WSContentSend_P(PSTR("}1" D_MAC_ADDRESS "}2%s"), EthernetMacAddress().c_str()); - WSContentSend_P(PSTR("}1" D_IP_ADDRESS " (eth)}2%s"), EthernetLocalIP().toString().c_str()); + WSContentSend_P(PSTR("}1" D_IP_ADDRESS " (eth)}2%_I"), (uint32_t)EthernetLocalIP()); WSContentSend_P(PSTR("}1
}2
")); } #endif @@ -2109,7 +2109,7 @@ void HandleInformation(void) #endif if (static_cast(WiFi.localIP()) != 0) { WSContentSend_P(PSTR("}1" D_MAC_ADDRESS "}2%s"), WiFi.macAddress().c_str()); - WSContentSend_P(PSTR("}1" D_IP_ADDRESS " (wifi)}2%s"), WiFi.localIP().toString().c_str()); + WSContentSend_P(PSTR("}1" D_IP_ADDRESS " (wifi)}2%_I"), (uint32_t)WiFi.localIP()); WSContentSend_P(PSTR("}1
}2
")); } } @@ -2121,8 +2121,8 @@ void HandleInformation(void) if ((WiFi.getMode() >= WIFI_AP) && (static_cast(WiFi.softAPIP()) != 0)) { WSContentSend_P(PSTR("}1
}2
")); WSContentSend_P(PSTR("}1" D_MAC_ADDRESS "}2%s"), WiFi.softAPmacAddress().c_str()); - WSContentSend_P(PSTR("}1" D_IP_ADDRESS " (AP)}2%s"), WiFi.softAPIP().toString().c_str()); - WSContentSend_P(PSTR("}1" D_GATEWAY "}2%s"), WiFi.softAPIP().toString().c_str()); + WSContentSend_P(PSTR("}1" D_IP_ADDRESS " (AP)}2%_I"), (uint32_t)WiFi.softAPIP()); + WSContentSend_P(PSTR("}1" D_GATEWAY "}2%_I"), (uint32_t)WiFi.softAPIP()); } WSContentSend_P(PSTR("}1}2 ")); // Empty line if (Settings.flag.mqtt_enabled) { // SetOption3 - Enable MQTT @@ -2975,8 +2975,8 @@ void CmndWebServer(void) Settings.webserver = XdrvMailbox.payload; } if (Settings.webserver) { - Response_P(PSTR("{\"" D_CMND_WEBSERVER "\":\"" D_JSON_ACTIVE_FOR " %s " D_JSON_ON_DEVICE " %s " D_JSON_WITH_IP_ADDRESS " %s\"}"), - (2 == Settings.webserver) ? PSTR(D_ADMIN) : PSTR(D_USER), NetworkHostname(), NetworkAddress().toString().c_str()); + Response_P(PSTR("{\"" D_CMND_WEBSERVER "\":\"" D_JSON_ACTIVE_FOR " %s " D_JSON_ON_DEVICE " %s " D_JSON_WITH_IP_ADDRESS " %_I\"}"), + (2 == Settings.webserver) ? PSTR(D_ADMIN) : PSTR(D_USER), NetworkHostname(), (uint32_t)NetworkAddress()); } else { ResponseCmndStateText(0); } diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index e2d35b963..c42d8163c 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -1031,7 +1031,7 @@ void Script_PollUdp(void) { int32_t len = Script_PortUdp.read(packet_buffer, SCRIPT_UDP_BUFFER_SIZE - 1); packet_buffer[len] = 0; script_udp_remote_ip = Script_PortUdp.remoteIP(); - AddLog(LOG_LEVEL_DEBUG, PSTR("UDP: Packet %s - %d - %s"), packet_buffer, len, script_udp_remote_ip.toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("UDP: Packet %s - %d - %_I"), packet_buffer, len, (uint32_t)script_udp_remote_ip); char *lp=packet_buffer; if (!strncmp(lp,"=>", 2)) { lp += 2; diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 918431071..07dcf9f6b 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -181,7 +181,7 @@ int hass_tele_period = 0; // NEW DISCOVERY const char HASS_DISCOVER_DEVICE[] PROGMEM = // Basic parameters for Discovery - "{\"ip\":\"%s\"," // IP Address + "{\"ip\":\"%_I\"," // IP Address "\"dn\":\"%s\"," // Device Name "\"fn\":[%s]," // Friendly Names "\"hn\":\"%s\"," // Host Name @@ -336,7 +336,7 @@ void NewHAssDiscovery(void) // Send empty message if new discovery is disabled TasmotaGlobal.masterlog_level = 4; // Hide topic on clean and remove use weblog 4 to show it if (!Settings.flag.hass_discovery) { // HassDiscoveryRelays(relays) - Response_P(HASS_DISCOVER_DEVICE, WiFi.localIP().toString().c_str(), SettingsText(SET_DEVICENAME), + Response_P(HASS_DISCOVER_DEVICE, (uint32_t)WiFi.localIP(), SettingsText(SET_DEVICENAME), stemp2, TasmotaGlobal.hostname, unique_id, ModuleName().c_str(), TuyaMod, iFanMod, GetStateText(0), GetStateText(1), GetStateText(2), GetStateText(3), TasmotaGlobal.version, TasmotaGlobal.mqtt_topic, SettingsText(SET_MQTT_FULLTOPIC), PSTR(SUB_PREFIX), PSTR(PUB_PREFIX), PSTR(PUB_PREFIX2), Hass.RelLst, stemp3, stemp4, stemp5, Settings.flag.mqtt_response, Settings.flag.button_swap, Settings.flag.button_single, Settings.flag.decimal_text, Settings.flag.not_power_linked, @@ -1033,10 +1033,10 @@ void HAssPublishStatus(void) { Response_P(PSTR("{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\",\"" D_CMND_MODULE " or " D_CMND_TEMPLATE"\":\"%s\"," "\"" D_JSON_RESTARTREASON "\":\"%s\",\"" D_JSON_UPTIME "\":\"%s\",\"" D_CMND_HOSTNAME "\":\"%s\"," - "\"" D_CMND_IPADDRESS "\":\"%s\",\"" D_JSON_RSSI "\":\"%d\",\"" D_JSON_SIGNAL " (dBm)""\":\"%d\"," + "\"" D_CMND_IPADDRESS "\":\"%_I\",\"" D_JSON_RSSI "\":\"%d\",\"" D_JSON_SIGNAL " (dBm)""\":\"%d\"," "\"WiFi " D_JSON_LINK_COUNT "\":%d,\"WiFi " D_JSON_DOWNTIME "\":\"%s\",\"" D_JSON_MQTT_COUNT "\":%d,\"LoadAvg\":%lu}"), TasmotaGlobal.version, TasmotaGlobal.image_name, GetBuildDateAndTime().c_str(), ModuleName().c_str(), GetResetReason().c_str(), - GetUptime().c_str(), TasmotaGlobal.hostname, WiFi.localIP().toString().c_str(), WifiGetRssiAsQuality(WiFi.RSSI()), + GetUptime().c_str(), TasmotaGlobal.hostname, (uint32_t)WiFi.localIP(), WifiGetRssiAsQuality(WiFi.RSSI()), WiFi.RSSI(), WifiLinkCount(), WifiDowntime().c_str(), MqttConnectCount(), TasmotaGlobal.loop_load_avg); MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_HASS_STATE)); } diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index 84a1d6058..b0ca3de9f 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -1045,7 +1045,7 @@ void DisplayLogBufferInit(void) DisplayLogBufferAdd(buffer); snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_MAC " %s"), NetworkMacAddress().c_str()); DisplayLogBufferAdd(buffer); - snprintf_P(buffer, sizeof(buffer), PSTR("IP %s"), NetworkAddress().toString().c_str()); + snprintf_P(buffer, sizeof(buffer), PSTR("IP %_I"), (uint32_t)NetworkAddress()); DisplayLogBufferAdd(buffer); if (!TasmotaGlobal.global_state.wifi_down) { snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_SSID " %s"), SettingsText(SET_STASSID1 + Settings.sta_active)); From 64d152a4513bb98bbb8382430458f1d02fdcdb1b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 12:14:33 +0100 Subject: [PATCH 08/30] Refactor some IP addresses --- tasmota/xdrv_50_filesystem.ino | 18 +++++++++--------- tasmota/xdrv_81_esp32_webcam.ino | 4 ++-- tasmota/xdrv_82_esp32_ethernet.ino | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index f42dd2ff6..90fdad9bf 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -413,7 +413,7 @@ const char UFS_FORM_FILE_UPGc[] PROGMEM = "
" D_FS_SIZE " %s MB - " D_FS_FREE " %s MB"; const char UFS_FORM_FILE_UPGc1[] PROGMEM = - "   %s"; + "   %s"; const char UFS_FORM_FILE_UPGc2[] PROGMEM = "
"; @@ -436,11 +436,11 @@ const char UFS_FORM_SDC_DIRd[] PROGMEM = const char UFS_FORM_SDC_DIRb[] PROGMEM = "
%s %s %8d %s
"; const char UFS_FORM_SDC_HREF[] PROGMEM = - "http://%s/ufsd?download=%s/%s"; + "http://%_I/ufsd?download=%s/%s"; #ifdef GUI_TRASH_FILE const char UFS_FORM_SDC_HREFdel[] PROGMEM = - //"🗑"; - "🔥"; // 🔥 + //"🗑"; + "🔥"; // 🔥 #endif // GUI_TRASH_FILE void UfsDirectory(void) { @@ -492,7 +492,7 @@ void UfsDirectory(void) { WSContentSend_PD(UFS_FORM_FILE_UPGc, WebColor(COL_TEXT), ts, fs); if (ufs_dir) { - WSContentSend_P(UFS_FORM_FILE_UPGc1, WiFi.localIP().toString().c_str(), (ufs_dir == 1)?2:1, (ufs_dir == 1)?PSTR("SDCard"):PSTR("FlashFS")); + WSContentSend_P(UFS_FORM_FILE_UPGc1, (uint32_t)WiFi.localIP(), (ufs_dir == 1)?2:1, (ufs_dir == 1)?PSTR("SDCard"):PSTR("FlashFS")); } WSContentSend_P(UFS_FORM_FILE_UPGc2); @@ -520,7 +520,7 @@ void UfsListDir(char *path, uint8_t depth) { if (dir) { dir.rewindDirectory(); if (strlen(path)>1) { - snprintf_P(npath, sizeof(npath), PSTR("http://%s/ufsd?download=%s"), WiFi.localIP().toString().c_str(), path); + ext_snprintf_P(npath, sizeof(npath), PSTR("http://%_I/ufsd?download=%s"), (uint32_t)WiFi.localIP(), path); for (uint32_t cnt = strlen(npath) - 1; cnt > 0; cnt--) { if (npath[cnt] == '/') { if (npath[cnt - 1] == '=') { @@ -562,7 +562,7 @@ void UfsListDir(char *path, uint8_t depth) { sprintf(cp, format, ep); if (entry.isDirectory()) { - snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, WiFi.localIP().toString().c_str(), pp, ep); + snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, (uint32_t)WiFi.localIP(), pp, ep); WSContentSend_P(UFS_FORM_SDC_DIRd, npath, ep, name); uint8_t plen = strlen(path); if (plen > 1) { @@ -574,12 +574,12 @@ void UfsListDir(char *path, uint8_t depth) { } else { #ifdef GUI_TRASH_FILE char delpath[128]; - snprintf_P(delpath, sizeof(delpath), UFS_FORM_SDC_HREFdel, WiFi.localIP().toString().c_str(), pp, ep); + snprintf_P(delpath, sizeof(delpath), UFS_FORM_SDC_HREFdel, (uint32_t)WiFi.localIP(), pp, ep); #else char delpath[2]; delpath[0]=0; #endif // GUI_TRASH_FILE - snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, WiFi.localIP().toString().c_str(), pp, ep); + snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, (uint32_t)WiFi.localIP(), pp, ep); WSContentSend_P(UFS_FORM_SDC_DIRb, npath, ep, name, tstr.c_str(), entry.size(), delpath); } } diff --git a/tasmota/xdrv_81_esp32_webcam.ino b/tasmota/xdrv_81_esp32_webcam.ino index 97f88b9d3..f7a5a5713 100644 --- a/tasmota/xdrv_81_esp32_webcam.ino +++ b/tasmota/xdrv_81_esp32_webcam.ino @@ -918,8 +918,8 @@ void WcShowStream(void) { delay(50); // Give the webcam webserver some time to prepare the stream } if (Wc.CamServer && Wc.up) { - WSContentSend_P(PSTR("

Webcam stream

"), - WiFi.localIP().toString().c_str()); + WSContentSend_P(PSTR("

Webcam stream

"), + (uint32_t)WiFi.localIP()); } } } diff --git a/tasmota/xdrv_82_esp32_ethernet.ino b/tasmota/xdrv_82_esp32_ethernet.ino index c537fae05..a14a84116 100644 --- a/tasmota/xdrv_82_esp32_ethernet.ino +++ b/tasmota/xdrv_82_esp32_ethernet.ino @@ -93,8 +93,8 @@ void EthernetEvent(WiFiEvent_t event) { ETH.linkSpeed(), (ETH.fullDuplex()) ? " Full Duplex" : ""); break; case SYSTEM_EVENT_ETH_GOT_IP: - AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %s, Hostname %s"), - ETH.macAddress().c_str(), ETH.localIP().toString().c_str(), eth_hostname); + AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %_I, Hostname %s"), + ETH.macAddress().c_str(), (uint32_t)ETH.localIP(), eth_hostname); Settings.ipv4_address[1] = (uint32_t)ETH.gatewayIP(); Settings.ipv4_address[2] = (uint32_t)ETH.subnetMask(); Settings.ipv4_address[3] = (uint32_t)ETH.dnsIP(); From 12e262d337b87610169b2cecd784d2b019d3011e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 14:27:05 +0100 Subject: [PATCH 09/30] Add support for ESP32 ``Module 5`` Wireless Tag Eth01 Add support for ESP32 ``Module 5`` Wireless Tag Eth01 (#9496) --- CHANGELOG.md | 5 +-- RELEASENOTES.md | 5 +-- tasmota/my_user_config.h | 8 ++--- tasmota/tasmota_template.h | 53 ++++++++++++++++++++++++++++-- tasmota/xdrv_82_esp32_ethernet.ino | 6 ++++ 5 files changed, 67 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aa433d80..b4f18abeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Function ``AddLog`` to provide logging for up to 128 (LOGSZ) characters to save stack space - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively - Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively +- Support for ESP32 ``Module 5`` Wireless Tag Eth01 (#9496) ### Changed - Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages @@ -25,7 +26,7 @@ All notable changes to this project will be documented in this file. - Compile time option ``USE_MQTT_TLS_DROP_OLD_FINGERPRINT`` to drop old (less secure) TLS fingerprint - Command ``SetOption40 0..250`` to disable button functionality if activated for over 0.1 second re-introduced - Support for SM2135 current selection using GPIO ``SM2135 DAT`` index (#10634) -- Basic support for ESP32 M5stack core2 16MB binary tasmota32-core2.bin (#10635) +- Support for ESP32 ``Module 7`` M5stack core2 16MB binary tasmota32-core2.bin (#10635) - Support for Sugar Valley NeoPool Controller by Norbert Richter (#10637) - Rule trigger string comparisons for EndsWith ``$>``, StartsWith ``$<`` and Contains ``$|`` (#10538) - Support for TOF10120 time of flight sensor by Cyril Pawelko (#10190) @@ -42,7 +43,7 @@ All notable changes to this project will be documented in this file. ## [9.2.0.2] 20210105 ### Added -- Basic support for ESP32 Odroid Go 16MB binary tasmota32-odroidgo.bin (#8630) +- Support for ESP32 ``Module 3`` Odroid Go 16MB binary tasmota32-odroidgo.bin (#8630) - Command ``CTRange`` to specify the visible CT range the bulb is capable of (#10311) - Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels (#10311) - Command ``SetOption118 1`` to move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default (#10353) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 66388ab4d..7e528d190 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -87,8 +87,9 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Support for Sugar Valley NeoPool Controller by Norbert Richter [#10637](https://github.com/arendst/Tasmota/issues/10637) - Support rotary encoder on Shelly Dimmer [#10407](https://github.com/arendst/Tasmota/issues/10407#issuecomment-756240920) - Support character `#` to be replaced by `space`-character in command ``Publish`` topic [#10258](https://github.com/arendst/Tasmota/issues/10258) -- Basic support for ESP32 Odroid Go 16MB binary tasmota32-odroidgo.bin [#8630](https://github.com/arendst/Tasmota/issues/8630) -- Basic support for ESP32 M5stack core2 16MB binary tasmota32-core2.bin [#10635](https://github.com/arendst/Tasmota/issues/10635) +- Support for ESP32 ``Module 3`` Odroid Go 16MB binary tasmota32-odroidgo.bin [#8630](https://github.com/arendst/Tasmota/issues/8630) +- Support for ESP32 ``Module 5`` Wireless Tag Eth01 [#9496](https://github.com/arendst/Tasmota/issues/9496) +- Support for ESP32 ``Module 7`` M5stack core2 16MB binary tasmota32-core2.bin [#10635](https://github.com/arendst/Tasmota/issues/10635) - Rule trigger string comparisons for EndsWith ``$>``, StartsWith ``$<`` and Contains ``$|`` [#10538](https://github.com/arendst/Tasmota/issues/10538) - SPI display driver SSD1331 Color oled by Jeroen Vermeulen [#10376](https://github.com/arendst/Tasmota/issues/10376) - Compile time option ``USE_MQTT_TLS_DROP_OLD_FINGERPRINT`` to drop old (less secure) TLS fingerprint diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 7ba3f4237..b88604ed3 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -849,6 +849,10 @@ #ifdef ESP32 //#define USE_ETHERNET // Add support for ethernet (Currently fixed for Olimex ESP32-PoE) +// #define USE_WT32_ETH01 // Add support for Wireless-Tag WT32-ETH01 +// #define ETH_TYPE 0 // [EthType] 0 = ETH_PHY_LAN8720, 1 = ETH_PHY_TLK110, 2 = ETH_PHY_IP101 +// #define ETH_ADDR 1 // [EthAddress] 0 = PHY0 .. 31 = PHY31 +// #define ETH_CLKMODE 0 // [EthClockMode] 0 = ETH_CLOCK_GPIO0_IN, 1 = ETH_CLOCK_GPIO0_OUT, 2 = ETH_CLOCK_GPIO16_OUT, 3 = ETH_CLOCK_GPIO17_OUT // Olimex ESP32-PoE #define ETH_TYPE 0 // [EthType] 0 = ETH_PHY_LAN8720, 1 = ETH_PHY_TLK110, 2 = ETH_PHY_IP101 #define ETH_ADDR 0 // [EthAddress] 0 = PHY0 .. 31 = PHY31 @@ -856,10 +860,6 @@ // wESP32-PoE // #define ETH_TYPE 0 // [EthType] 0 = ETH_PHY_LAN8720, 1 = ETH_PHY_TLK110, 2 = ETH_PHY_IP101 // #define ETH_ADDR 0 // [EthAddress] 0 = PHY0 .. 31 = PHY31 -// #define ETH_CLKMODE 0 // [EthClockMode] 0 = ETH_CLOCK_GPIO0_IN, 1 = ETH_CLOCK_GPIO0_OUT, 2 = ETH_CLOCK_GPIO16_OUT, 3 = ETH_CLOCK_GPIO17_OUT - // Wireless-Tag WT32-ETH01 -// #define ETH_TYPE 0 // [EthType] 0 = ETH_PHY_LAN8720, 1 = ETH_PHY_TLK110, 2 = ETH_PHY_IP101 -// #define ETH_ADDR 1 // [EthAddress] 0 = PHY0 .. 31 = PHY31 // #define ETH_CLKMODE 0 // [EthClockMode] 0 = ETH_CLOCK_GPIO0_IN, 1 = ETH_CLOCK_GPIO0_OUT, 2 = ETH_CLOCK_GPIO16_OUT, 3 = ETH_CLOCK_GPIO17_OUT #define USE_ADC // Add support for ADC on GPIO32 to GPIO39 diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index eff968de1..26a5b4686 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -2359,7 +2359,9 @@ const char kModuleNames[] PROGMEM = "Odroid Go|" #endif // USE_ODROID_GO // "ESP32-Solo|" -// "WT32-Eth01|" +#ifdef USE_WT32_ETH01 + "WT32-Eth01|" +#endif // USE_WT32_ETH01 // "TTGO Watch|" #ifdef USE_M5STACK_CORE2 "M5Stack Core2|" @@ -2376,7 +2378,9 @@ const uint8_t kModuleNiceList[] PROGMEM = { ODROID_GO, #endif // USE_ODROID_GO // ESP32_SOLO, -// WT32_ETH01, +#ifdef USE_WT32_ETH01 + WT32_ETH01, +#endif // USE_WT32_ETH01 // TTGO_WATCH, #ifdef USE_M5STACK_CORE2 M5STACK_CORE2, @@ -2518,6 +2522,51 @@ const mytmplt kModules[] PROGMEM = 0 // Flag }, #endif // USE_ODROID_GO +#ifdef USE_WT32_ETH01 + { // WT32_ETH01 - (ESP32) + 0, // 0 (I)O GPIO0, Ethernet EMAC_REF_CLK + AGPIO(GPIO_USER), // 1 IO TXD0 GPIO1, U0TXD, CLK_OUT3, EMAC_RXD2 + AGPIO(GPIO_USER), // 2 IO GPIO2, ADC2_CH2, TOUCH2, RTC_GPIO12, HSPIWP, HS2_DATA0, SD_DATA0 + AGPIO(GPIO_USER), // 3 IO RXD0 GPIO3, U0RXD, CLK_OUT2 + AGPIO(GPIO_USER), // 4 IO GPIO4, ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER + AGPIO(GPIO_USER), // 5 IO GPIO5, RXD Led green + // 6 IO GPIO6, Flash CLK + // 7 IO GPIO7, Flash D0 + // 8 IO GPIO8, Flash D1 + 0, // 9 IO GPIO9, Flash D2, U1RXD + 0, // 10 IO GPIO10, Flash D3, U1TXD + // 11 IO GPIO11, Flash CMD + AGPIO(GPIO_USER), // 12 (I)O GPIO12, ADC2_CH5, TOUCH5, RTC_GPIO15, MTDI, HSPIQ, HS2_DATA2, SD_DATA2, EMAC_TXD3 (If driven High, flash voltage (VDD_SDIO) is 1.8V not default 3.3V. Has internal pull-down, so unconnected = Low = 3.3V. May prevent flashing and/or booting if 3.3V flash is connected and pulled high. See ESP32 datasheet for more details.) + 0, // 13 IO GPIO13, Ethernet EMAC_RX_ER + AGPIO(GPIO_USER), // 14 IO GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2 + AGPIO(GPIO_USER), // 15 (I)O GPIO15, ADC2_CH3, TOUCH3, MTDO, HSPICS0, RTC_GPIO13, HS2_CMD, SD_CMD, EMAC_RXD3 (If driven Low, silences boot messages from normal boot. Has internal pull-up, so unconnected = High = normal output.) + AGPIO(GPIO_OUTPUT_HI), // 16 IO GPIO16, Ethernet OSC_ENA + AGPIO(GPIO_LEDLNK_INV), // 17 IO GPIO17, Network link led (green) + AGPIO(GPIO_ETH_PHY_MDIO), // 18 IO GPIO18, Ethernet MDIO + 0, // 19 IO GPIO19, Ethernet TXD0 + 0, // 20 + 0, // 21 IO GPIO21, Ethernet EMAC_TX_EN + 0, // 22 IO LED GPIO22, Ethernet EMAC_TXD1 + AGPIO(GPIO_ETH_PHY_MDC), // 23 IO GPIO23, Ethernet MDC + 0, // 24 + 0, // 25 IO GPIO25, Ethernet EMAC_RXD0 + 0, // 26 IO GPIO26, Ethernet EMAC_RXD1 + 0, // 27 IO GPIO27, Ethernet EMAC_RX_DV + 0, // 28 + 0, // 29 + 0, // 30 + 0, // 31 + AGPIO(GPIO_USER), // 32 IO GPIO32, CFG + AGPIO(GPIO_USER), // 33 IO GPIO33, 485_EN + 0, // 34 I NO PULLUP GPIO34, ADC1_CH6, RTC_GPIO4 + AGPIO(GPIO_USER), // 35 I NO PULLUP GPIO35, ADC1_CH7, RTC_GPIO5 + AGPIO(GPIO_USER), // 36 I NO PULLUP GPIO36, SENSOR_VP, ADC_H, ADC1_CH0, RTC_GPIO0 + 0, // 37 NO PULLUP + 0, // 38 NO PULLUP + AGPIO(GPIO_USER), // 39 I NO PULLUP GPIO39, SENSOR_VN, ADC1_CH3, ADC_H, RTC_GPIO3 + 0 // Flag + }, +#endif // USE_WT32_ETH01 #ifdef USE_M5STACK_CORE2 { // M5STACK CORE2 - (ESP32) AGPIO(GPIO_USER), // 0 (I)O GPIO0, SPKR_LRCK diff --git a/tasmota/xdrv_82_esp32_ethernet.ino b/tasmota/xdrv_82_esp32_ethernet.ino index a14a84116..1eae96991 100644 --- a/tasmota/xdrv_82_esp32_ethernet.ino +++ b/tasmota/xdrv_82_esp32_ethernet.ino @@ -120,6 +120,12 @@ void EthernetInit(void) { return; } + if (WT32_ETH01 == TasmotaGlobal.module_type) { + Settings.eth_address = 1; // EthAddress + Settings.eth_type = ETH_PHY_LAN8720; // EthType + Settings.eth_clk_mode = ETH_CLOCK_GPIO0_IN; // EthClockMode + } + // snprintf_P(Eth.hostname, sizeof(Eth.hostname), PSTR("%s_eth"), TasmotaGlobal.hostname); strlcpy(eth_hostname, TasmotaGlobal.hostname, sizeof(eth_hostname) -5); // Make sure there is room for "_eth" strcat(eth_hostname, "_eth"); From 64d1455bf666fdcc170ede4f7188aa3fc9a9b1cc Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 14:45:42 +0100 Subject: [PATCH 10/30] Add template place holders --- tasmota/tasmota_template.h | 65 +++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 26a5b4686..dbdc41cce 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -2350,24 +2350,6 @@ enum SupportedModules { M5STACK_CORE2, MAXMODULE }; -const char kModuleNames[] PROGMEM = - "ESP32-DevKit|" -#ifdef USE_WEBCAM - "ESP32-Cam|" -#endif // USE_WEBCAM -#ifdef USE_ODROID_GO - "Odroid Go|" -#endif // USE_ODROID_GO -// "ESP32-Solo|" -#ifdef USE_WT32_ETH01 - "WT32-Eth01|" -#endif // USE_WT32_ETH01 -// "TTGO Watch|" -#ifdef USE_M5STACK_CORE2 - "M5Stack Core2|" -#endif // USE_M5STACK_CORE2 - ; - // Default module settings const uint8_t kModuleNiceList[] PROGMEM = { WEMOS, @@ -2377,18 +2359,43 @@ const uint8_t kModuleNiceList[] PROGMEM = { #ifdef USE_ODROID_GO ODROID_GO, #endif // USE_ODROID_GO -// ESP32_SOLO, +#ifdef USE_ESP32_SOLO +// ESP32_SOLO, // To be defined +#endif // USE_ESP32_SOLO #ifdef USE_WT32_ETH01 WT32_ETH01, #endif // USE_WT32_ETH01 -// TTGO_WATCH, +#ifdef USE_TTGO_WATCH +// TTGO_WATCH, // To be defined +#endif // USE_TTGO_WATCH #ifdef USE_M5STACK_CORE2 M5STACK_CORE2, #endif // USE_M5STACK_CORE2 }; -const mytmplt kModules[] PROGMEM = -{ +const char kModuleNames[] PROGMEM = + "ESP32-DevKit|" +#ifdef USE_WEBCAM + "ESP32-Cam|" +#endif // USE_WEBCAM +#ifdef USE_ODROID_GO + "Odroid Go|" +#endif // USE_ODROID_GO +#ifdef USE_ESP32_SOLO +// "ESP32-Solo|" // To be defined +#endif // USE_ESP32_SOLO +#ifdef USE_WT32_ETH01 + "WT32-Eth01|" +#endif // USE_WT32_ETH01 +#ifdef USE_TTGO_WATCH +// "TTGO Watch|" // To be defined +#endif // USE_TTGO_WATCH +#ifdef USE_M5STACK_CORE2 + "M5Stack Core2|" +#endif // USE_M5STACK_CORE2 + ; + +const mytmplt kModules[] PROGMEM = { { // WEMOS - Espressif ESP32-DevKitC - Any ESP32 device like WeMos and NodeMCU hardware (ESP32) AGPIO(GPIO_USER), // 0 (I)O GPIO0, ADC2_CH1, TOUCH1, RTC_GPIO11, CLK_OUT1, EMAC_TX_CLK AGPIO(GPIO_USER), // 1 IO TXD0 GPIO1, U0TXD, CLK_OUT3, EMAC_RXD2 @@ -2432,6 +2439,7 @@ const mytmplt kModules[] PROGMEM = AGPIO(GPIO_USER), // 39 I NO PULLUP GPIO39, SENSOR_VN, ADC1_CH3, ADC_H, RTC_GPIO3 0 // Flag }, + #ifdef USE_WEBCAM { // ESP32_CAM_AITHINKER - Any ESP32 device with webcam (ESP32) AGPIO(GPIO_WEBCAM_XCLK), // 0 (I)O GPIO0, CAM_XCLK @@ -2477,6 +2485,7 @@ const mytmplt kModules[] PROGMEM = 0 // Flag }, #endif // USE_WEBCAM + #ifdef USE_ODROID_GO { // ODROID_GO - (ESP32) AGPIO(GPIO_KEY1), // 0 (I)O GPIO0, BTN-VOLUME @@ -2522,6 +2531,12 @@ const mytmplt kModules[] PROGMEM = 0 // Flag }, #endif // USE_ODROID_GO + +#ifdef USE_ESP32_SOLO +// { // ESP32 Solo (ESP32) - To be defined +// }, +#endif // USE_ESP32_SOLO + #ifdef USE_WT32_ETH01 { // WT32_ETH01 - (ESP32) 0, // 0 (I)O GPIO0, Ethernet EMAC_REF_CLK @@ -2567,6 +2582,12 @@ const mytmplt kModules[] PROGMEM = 0 // Flag }, #endif // USE_WT32_ETH01 + +#ifdef USE_TTGO_WATCH +// { // TTGO Watch (ESP32) - To be defined +// }, +#endif // USE_TTGO_WATCH + #ifdef USE_M5STACK_CORE2 { // M5STACK CORE2 - (ESP32) AGPIO(GPIO_USER), // 0 (I)O GPIO0, SPKR_LRCK From f083233b0932ff53bf057ec7fbd9135603642a30 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 16:09:56 +0100 Subject: [PATCH 11/30] Support trailing silence in buzzer tune Support trailing silence in buzzer tune (#10694) --- CHANGELOG.md | 1 + RELEASENOTES.md | 5 ++- tasmota/xdrv_24_buzzer.ino | 91 ++++++++++++++++---------------------- 3 files changed, 41 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4f18abeb..beceb6d1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively - Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively - Support for ESP32 ``Module 5`` Wireless Tag Eth01 (#9496) +- Support trailing silence in buzzer tune (#10694) ### Changed - Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7e528d190..3f0c0a46f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -85,11 +85,12 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Support for 24/26/32/34 bit RFID Wiegand interface (D0/D1) by Sigurd Leuther [#3647](https://github.com/arendst/Tasmota/issues/3647) - Support for SM2135 current selection using GPIO ``SM2135 DAT`` index [#10634](https://github.com/arendst/Tasmota/issues/10634) - Support for Sugar Valley NeoPool Controller by Norbert Richter [#10637](https://github.com/arendst/Tasmota/issues/10637) -- Support rotary encoder on Shelly Dimmer [#10407](https://github.com/arendst/Tasmota/issues/10407#issuecomment-756240920) -- Support character `#` to be replaced by `space`-character in command ``Publish`` topic [#10258](https://github.com/arendst/Tasmota/issues/10258) - Support for ESP32 ``Module 3`` Odroid Go 16MB binary tasmota32-odroidgo.bin [#8630](https://github.com/arendst/Tasmota/issues/8630) - Support for ESP32 ``Module 5`` Wireless Tag Eth01 [#9496](https://github.com/arendst/Tasmota/issues/9496) - Support for ESP32 ``Module 7`` M5stack core2 16MB binary tasmota32-core2.bin [#10635](https://github.com/arendst/Tasmota/issues/10635) +- Support rotary encoder on Shelly Dimmer [#10407](https://github.com/arendst/Tasmota/issues/10407#issuecomment-756240920) +- Support character `#` to be replaced by `space`-character in command ``Publish`` topic [#10258](https://github.com/arendst/Tasmota/issues/10258) +- Support trailing silence in buzzer tune [#10694](https://github.com/arendst/Tasmota/issues/10694) - Rule trigger string comparisons for EndsWith ``$>``, StartsWith ``$<`` and Contains ``$|`` [#10538](https://github.com/arendst/Tasmota/issues/10538) - SPI display driver SSD1331 Color oled by Jeroen Vermeulen [#10376](https://github.com/arendst/Tasmota/issues/10376) - Compile time option ``USE_MQTT_TLS_DROP_OLD_FINGERPRINT`` to drop old (less secure) TLS fingerprint diff --git a/tasmota/xdrv_24_buzzer.ino b/tasmota/xdrv_24_buzzer.ino index 868c1d84a..973799095 100644 --- a/tasmota/xdrv_24_buzzer.ino +++ b/tasmota/xdrv_24_buzzer.ino @@ -32,44 +32,39 @@ struct BUZZER { uint8_t inverted = 0; // Buzzer inverted flag (1 = (0 = On, 1 = Off)) uint8_t count = 0; // Number of buzzes uint8_t mode = 0; // Buzzer mode (0 = regular, 1 = infinite, 2 = follow LED) - uint8_t freq_mode = 0; // Output mode (0 = regular, 1 = using frequency output) uint8_t set[2]; uint8_t duration; uint8_t state = 0; + uint8_t tune_size = 0; + uint8_t size = 0; } Buzzer; /*********************************************************************************************/ -void BuzzerSet(uint8_t state) -{ +void BuzzerSet(uint32_t state) { if (Buzzer.inverted) { state = !state; } - if (Buzzer.freq_mode == 1) { + if (Settings.flag4.buzzer_freq_mode) { // SetOption111 - Enable frequency output mode for buzzer static uint8_t last_state = 0; if (last_state != state) { - if (state) { - analogWrite(Pin(GPIO_BUZZER, 0), Settings.pwm_range / 2); // set 50% duty cycle for frequency output - } - else { - analogWrite(Pin(GPIO_BUZZER, 0), 0); // set 0% (or 100% for inverted PWM) duty cycle which turns off frequency output either way - } + // Set 50% duty cycle for frequency output + // Set 0% (or 100% for inverted PWM) duty cycle which turns off frequency output either way + analogWrite(Pin(GPIO_BUZZER), (state) ? Settings.pwm_range / 2 : 0); // set duty cycle for frequency output last_state = state; } + } else { + DigitalWrite(GPIO_BUZZER, 0, state); // Buzzer On/Off } - else { - DigitalWrite(GPIO_BUZZER, 0, state); // Buzzer On/Off - } - } //void BuzzerBeep(uint32_t count = 1, uint32_t on = 1, uint32_t off = 1, uint32_t tune = 0, uint32_t mode = 0); -void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32_t mode) -{ - Buzzer.set[0] = off; // off duration in 100 mSec steps - Buzzer.set[1] = on; // on duration in 100 mSec steps - Buzzer.duration = 1; // Start buzzer on first step +void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32_t mode) { + Buzzer.set[0] = off; // Off duration in 100 mSec steps + Buzzer.set[1] = on; // On duration in 100 mSec steps + Buzzer.duration = 1; // Start buzzer on first step + Buzzer.tune_size = 0; Buzzer.tune_reload = 0; Buzzer.mode = mode; @@ -78,65 +73,55 @@ void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32 uint32_t tune2 = tune; for (uint32_t i = 0; i < 32; i++) { if (!(tune2 & 0x80000000)) { - tune2 <<= 1; // Skip leading silence + tune2 <<= 1; // Skip leading silence } else { - Buzzer.tune_reload <<= 1; // Add swapped tune + Buzzer.tune_size++; // Allow trailing silence + Buzzer.tune_reload <<= 1; // Add swapped tune Buzzer.tune_reload |= tune1 & 1; tune1 >>= 1; } } + Buzzer.size = Buzzer.tune_size; Buzzer.tune = Buzzer.tune_reload; } - Buzzer.count = count * 2; // Start buzzer + Buzzer.count = count * 2; // Start buzzer - // We can use PWM mode for buzzer output if enabled. - if (Settings.flag4.buzzer_freq_mode) { // SetOption111 - Enable frequency output mode for buzzer - Buzzer.freq_mode = 1; - } - else { - Buzzer.freq_mode = 0; - } - - AddLog(LOG_LEVEL_DEBUG, PSTR("BUZ: %d(%d),%d,%d,0x%08X(0x%08X),%d"), count, Buzzer.count, on, off, tune, Buzzer.tune, Buzzer.freq_mode); + AddLog(LOG_LEVEL_DEBUG, PSTR("BUZ: Count %d(%d), Time %d/%d, Tune 0x%08X(0x%08X), Size %d, Mode %d"), + count, Buzzer.count, on, off, tune, Buzzer.tune, Buzzer.tune_size, Settings.flag4.buzzer_freq_mode); Buzzer.enable = (Buzzer.count > 0); if (Buzzer.enable) { if (Settings.sleep > PWM_MAX_SLEEP) { - TasmotaGlobal.sleep = PWM_MAX_SLEEP; // set a maxumum value of 10 milliseconds to ensure that buzzer periods are a bit more accurate + TasmotaGlobal.sleep = PWM_MAX_SLEEP; // Set a maxumum value of 10 milliseconds to ensure that buzzer periods are a bit more accurate } else { - TasmotaGlobal.sleep = Settings.sleep; // or keep the current sleep if it's lower than 10 + TasmotaGlobal.sleep = Settings.sleep; // Or keep the current sleep if it's lower than 10 } - } - else { - TasmotaGlobal.sleep = Settings.sleep; // restore original sleep + } else { + TasmotaGlobal.sleep = Settings.sleep; // Restore original sleep BuzzerSet(0); } } -void BuzzerSetStateToLed(uint32_t state) -{ +void BuzzerSetStateToLed(uint32_t state) { if (Buzzer.enable && (2 == Buzzer.mode)) { Buzzer.state = (state != 0); BuzzerSet(Buzzer.state); } } -void BuzzerBeep(uint32_t count) -{ +void BuzzerBeep(uint32_t count) { BuzzerBeep(count, 1, 1, 0, 0); } -void BuzzerEnabledBeep(uint32_t count, uint32_t duration) -{ - if (Settings.flag3.buzzer_enable) { // SetOption67 - Enable buzzer when available +void BuzzerEnabledBeep(uint32_t count, uint32_t duration) { + if (Settings.flag3.buzzer_enable) { // SetOption67 - Enable buzzer when available BuzzerBeep(count, duration, 1, 0, 0); } } /*********************************************************************************************/ -bool BuzzerPinState(void) -{ +bool BuzzerPinState(void) { if (XdrvMailbox.index == AGPIO(GPIO_BUZZER_INV)) { Buzzer.inverted = 1; XdrvMailbox.index -= (AGPIO(GPIO_BUZZER_INV) - AGPIO(GPIO_BUZZER)); @@ -145,8 +130,7 @@ bool BuzzerPinState(void) return false; } -void BuzzerInit(void) -{ +void BuzzerInit(void) { if (PinUsed(GPIO_BUZZER)) { pinMode(Pin(GPIO_BUZZER), OUTPUT); BuzzerSet(0); @@ -155,17 +139,18 @@ void BuzzerInit(void) } } -void BuzzerEvery100mSec(void) -{ +void BuzzerEvery100mSec(void) { if (Buzzer.enable && (Buzzer.mode != 2)) { if (Buzzer.count) { if (Buzzer.duration) { Buzzer.duration--; if (!Buzzer.duration) { - if (Buzzer.tune) { + if (Buzzer.size) { + Buzzer.size--; Buzzer.state = Buzzer.tune & 1; Buzzer.tune >>= 1; } else { + Buzzer.size = Buzzer.tune_size; Buzzer.tune = Buzzer.tune_reload; Buzzer.count -= (Buzzer.tune_reload) ? 2 : 1; Buzzer.state = Buzzer.count & 1; @@ -193,8 +178,7 @@ const char kBuzzerCommands[] PROGMEM = "|" // No prefix void (* const BuzzerCommand[])(void) PROGMEM = { &CmndBuzzer }; -void CmndBuzzer(void) -{ +void CmndBuzzer(void) { // Buzzer ,,, // All parameters are optional // @@ -233,8 +217,7 @@ void CmndBuzzer(void) * Interface \*********************************************************************************************/ -bool Xdrv24(uint8_t function) -{ +bool Xdrv24(uint8_t function) { bool result = false; if (Buzzer.active) { From 027ef9d931ee764e0a9c08b599c796fe27b7cf7c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 16:31:15 +0100 Subject: [PATCH 12/30] Remove unwanted persistance --- tasmota/xdrv_24_buzzer.ino | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tasmota/xdrv_24_buzzer.ino b/tasmota/xdrv_24_buzzer.ino index 973799095..d992fd85a 100644 --- a/tasmota/xdrv_24_buzzer.ino +++ b/tasmota/xdrv_24_buzzer.ino @@ -64,7 +64,9 @@ void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32 Buzzer.set[0] = off; // Off duration in 100 mSec steps Buzzer.set[1] = on; // On duration in 100 mSec steps Buzzer.duration = 1; // Start buzzer on first step + Buzzer.size = 0; Buzzer.tune_size = 0; + Buzzer.tune = 0; Buzzer.tune_reload = 0; Buzzer.mode = mode; @@ -182,14 +184,15 @@ void CmndBuzzer(void) { // Buzzer ,,, // All parameters are optional // - // Buzzer = Buzzer 1,1,1 = Beep once with both duration and pause set to 100mS - // Buzzer 0 = Stop active beep cycle - // Buzzer 2 = Beep twice with duration 200mS and pause 100mS - // Buzzer 2,3 = Beep twice with duration 300mS and pause 100mS - // Buzzer 2,3,4 = Beep twice with duration 300mS and pause 400mS - // Buzzer 2,3,4,0xF54 = Beep a sequence twice indicated by 0xF54 = 1111 0101 01 with duration 300mS and pause 400mS - // Buzzer -1 = Beep infinite - // Buzzer -2 = Beep following link led + // Buzzer = Buzzer 1,1,1 = Beep once with both duration and pause set to 100mS + // Buzzer 0 = Stop active beep cycle + // Buzzer 2 = Beep twice with duration 200mS and pause 100mS + // Buzzer 2,3 = Beep twice with duration 300mS and pause 100mS + // Buzzer 2,3,4 = Beep twice with duration 300mS and pause 400mS + // Buzzer 2,3,4,0x0F54 = Beep a sequence twice indicated by 0x0F54 = 1111 0101 0100 with duration 300mS and pause 400mS + // Notice skipped leading zeroes but valid trailing zeroes + // Buzzer -1 = Beep infinite + // Buzzer -2 = Beep following link led if (XdrvMailbox.data_len > 0) { if (XdrvMailbox.payload != 0) { @@ -197,11 +200,11 @@ void CmndBuzzer(void) { uint32_t mode = 0; ParseParameters(4, parm); if (XdrvMailbox.payload <= 0) { - parm[0] = 1; // Default Count - mode = -XdrvMailbox.payload; // 0, 1 or 2 + parm[0] = 1; // Default Count + mode = -XdrvMailbox.payload; // 0, 1 or 2 } for (uint32_t i = 1; i < 3; i++) { - if (parm[i] < 1) { parm[i] = 1; } // Default On time, Off time + if (parm[i] < 1) { parm[i] = 1; } // Default On time, Off time } BuzzerBeep(parm[0], parm[1], parm[2], parm[3], mode); } else { From a3f5d5ce2c623a016320571f13474c2158da9667 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 16:58:33 +0100 Subject: [PATCH 13/30] Add commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively Add commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/xdrv_24_buzzer.ino | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index beceb6d1c..cad83cae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Function ``AddLog`` to provide logging for up to 128 (LOGSZ) characters to save stack space - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively - Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively +- Commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively - Support for ESP32 ``Module 5`` Wireless Tag Eth01 (#9496) - Support trailing silence in buzzer tune (#10694) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 3f0c0a46f..4789e7bb6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -67,6 +67,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Command ``SetOption119 1`` to remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic [#10355](https://github.com/arendst/Tasmota/issues/10355) - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively - Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively +- Commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively - Milliseconds to console output [#10152](https://github.com/arendst/Tasmota/issues/10152) - Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196) - Rotary No Pullup GPIO selection ``Rotary A/B_n`` [#10407](https://github.com/arendst/Tasmota/issues/10407) diff --git a/tasmota/xdrv_24_buzzer.ino b/tasmota/xdrv_24_buzzer.ino index d992fd85a..d02613d06 100644 --- a/tasmota/xdrv_24_buzzer.ino +++ b/tasmota/xdrv_24_buzzer.ino @@ -174,8 +174,13 @@ void BuzzerEvery100mSec(void) { * Commands \*********************************************************************************************/ -const char kBuzzerCommands[] PROGMEM = "|" // No prefix - "Buzzer" ; +const char kBuzzerCommands[] PROGMEM = "Buzzer|" // Prefix + "Active|Pwm||" ; + +const uint8_t kBuzzerSynonyms[] PROGMEM = { + 2, // number of synonyms + 67, 111 +}; void (* const BuzzerCommand[])(void) PROGMEM = { &CmndBuzzer }; @@ -229,7 +234,7 @@ bool Xdrv24(uint8_t function) { BuzzerEvery100mSec(); break; case FUNC_COMMAND: - result = DecodeCommand(kBuzzerCommands, BuzzerCommand); + result = DecodeCommand(kBuzzerCommands, BuzzerCommand, kBuzzerSynonyms); break; case FUNC_PRE_INIT: BuzzerInit(); From 5b375acdd29e04d95fada423324db8e2ad8fba35 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 27 Jan 2021 17:42:59 +0100 Subject: [PATCH 14/30] refactor dtostrfd --- tasmota/support.ino | 14 ------------ tasmota/xdrv_03_energy.ino | 44 +++++++++++++++----------------------- 2 files changed, 17 insertions(+), 41 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index 38e0266b2..3ae2b6105 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1219,29 +1219,15 @@ int ResponseAppendTime(void) return ResponseAppendTimeFormat(Settings.flag2.time_format); } -// int ResponseAppendTHD(float f_temperature, float f_humidity) -// { -// char temperature[FLOATSZ]; -// dtostrfd(f_temperature, Settings.flag2.temperature_resolution, temperature); -// char humidity[FLOATSZ]; -// dtostrfd(f_humidity, Settings.flag2.humidity_resolution, humidity); -// char dewpoint[FLOATSZ]; -// dtostrfd(CalcTempHumToDew(f_temperature, f_humidity), Settings.flag2.temperature_resolution, dewpoint); - -// return ResponseAppend_P(PSTR("\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_HUMIDITY "\":%s,\"" D_JSON_DEWPOINT "\":%s"), temperature, humidity, dewpoint); -// } - int ResponseAppendTHD(float f_temperature, float f_humidity) { float dewpoint = CalcTempHumToDew(f_temperature, f_humidity); - return ResponseAppend_P(PSTR("\"" D_JSON_TEMPERATURE "\":%*_f,\"" D_JSON_HUMIDITY "\":%*_f,\"" D_JSON_DEWPOINT "\":%*_f"), Settings.flag2.temperature_resolution, &f_temperature, Settings.flag2.humidity_resolution, &f_humidity, Settings.flag2.temperature_resolution, &dewpoint); } - int ResponseJsonEnd(void) { return ResponseAppend_P(PSTR("}")); diff --git a/tasmota/xdrv_03_energy.ino b/tasmota/xdrv_03_energy.ino index dd302ebf1..63369ac7d 100644 --- a/tasmota/xdrv_03_energy.ino +++ b/tasmota/xdrv_03_energy.ino @@ -225,9 +225,7 @@ void EnergyUpdateToday(void) void EnergyUpdateTotal(float value, bool kwh) { -// char energy_total_chr[FLOATSZ]; -// dtostrfd(value, 4, energy_total_chr); -// AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total %s %sWh"), energy_total_chr, (kwh) ? "k" : ""); +// AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total %4_f %sWh"), &value, (kwh) ? "k" : ""); uint32_t multiplier = (kwh) ? 100000 : 100; // kWh or Wh to deca milli Wh @@ -476,9 +474,7 @@ void EnergyMarginCheck(void) } else if ((1 == Energy.max_energy_state ) && (energy_daily_u >= Settings.energy_max_energy)) { Energy.max_energy_state = 2; - char stemp[FLOATSZ]; - dtostrfd(Energy.daily, 3, stemp); - ResponseTime_P(PSTR(",\"" D_JSON_MAXENERGYREACHED "\":%s}"), stemp); + ResponseTime_P(PSTR(",\"" D_JSON_MAXENERGYREACHED "\":%3_f}"), &Energy.daily); MqttPublishPrefixTopic_P(STAT, S_RSLT_WARNING); EnergyMqttShow(); SetAllPower(POWER_ALL_OFF, SRC_MAXENERGY); @@ -507,9 +503,7 @@ void EnergyEverySecond(void) if (TasmotaGlobal.global_update) { if (TasmotaGlobal.power && !isnan(TasmotaGlobal.temperature_celsius) && (TasmotaGlobal.temperature_celsius > (float)Settings.param[P_OVER_TEMP])) { // Device overtemp, turn off relays - char temperature[33]; - dtostrfd(TasmotaGlobal.temperature_celsius, 1, temperature); - AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: GlobTemp %s"), temperature); + AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: GlobTemp %1_f"), &TasmotaGlobal.temperature_celsius); SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP); } @@ -628,25 +622,21 @@ void CmndEnergyReset(void) } Energy.total = (float)(RtcSettings.energy_kWhtotal + Energy.kWhtoday_offset + Energy.kWhtoday) / 100000; + float energy_kWhyesterday = (float)Settings.energy_kWhyesterday / 100000; + float usage1_kWhtotal = (float)Settings.energy_usage.usage1_kWhtotal / 100000; + float usage2_kWhtotal = (float)Settings.energy_usage.usage2_kWhtotal / 100000; + float return1_kWhtotal = (float)Settings.energy_usage.return1_kWhtotal / 100000; + float return2_kWhtotal = (float)Settings.energy_usage.return2_kWhtotal / 100000; - char energy_total_chr[FLOATSZ]; - dtostrfd(Energy.total, Settings.flag2.energy_resolution, energy_total_chr); - char energy_daily_chr[FLOATSZ]; - dtostrfd(Energy.daily, Settings.flag2.energy_resolution, energy_daily_chr); - char energy_yesterday_chr[FLOATSZ]; - dtostrfd((float)Settings.energy_kWhyesterday / 100000, Settings.flag2.energy_resolution, energy_yesterday_chr); - - char energy_usage1_chr[FLOATSZ]; - dtostrfd((float)Settings.energy_usage.usage1_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_usage1_chr); - char energy_usage2_chr[FLOATSZ]; - dtostrfd((float)Settings.energy_usage.usage2_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_usage2_chr); - char energy_return1_chr[FLOATSZ]; - dtostrfd((float)Settings.energy_usage.return1_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_return1_chr); - char energy_return2_chr[FLOATSZ]; - dtostrfd((float)Settings.energy_usage.return2_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_return2_chr); - - Response_P(PSTR("{\"%s\":{\"" D_JSON_TOTAL "\":%s,\"" D_JSON_YESTERDAY "\":%s,\"" D_JSON_TODAY "\":%s,\"" D_JSON_USAGE "\":[%s,%s],\"" D_JSON_EXPORT "\":[%s,%s]}}"), - XdrvMailbox.command, energy_total_chr, energy_yesterday_chr, energy_daily_chr, energy_usage1_chr, energy_usage2_chr, energy_return1_chr, energy_return2_chr); + Response_P(PSTR("{\"%s\":{\"" D_JSON_TOTAL "\":%*_f,\"" D_JSON_YESTERDAY "\":%*_f,\"" D_JSON_TODAY "\":%*_f,\"" D_JSON_USAGE "\":[%*_f,%*_f],\"" D_JSON_EXPORT "\":[%*_f,%*_f]}}"), + XdrvMailbox.command, + Settings.flag2.energy_resolution, &Energy.total, + Settings.flag2.energy_resolution, &energy_kWhyesterday, + Settings.flag2.energy_resolution, &Energy.daily, + Settings.flag2.energy_resolution, &usage1_kWhtotal, + Settings.flag2.energy_resolution, &usage2_kWhtotal, + Settings.flag2.energy_resolution, &return1_kWhtotal, + Settings.flag2.energy_resolution, &return2_kWhtotal); } void CmndTariff(void) From 29d3e701465c61b2c26d9b83c0144242fe232c58 Mon Sep 17 00:00:00 2001 From: blakadder Date: Thu, 28 Jan 2021 01:14:37 +0100 Subject: [PATCH 15/30] add L1MusicSync mode --- tasmota/xlgt_05_sonoff_l1.ino | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tasmota/xlgt_05_sonoff_l1.ino b/tasmota/xlgt_05_sonoff_l1.ino index 368e1673d..908015d68 100644 --- a/tasmota/xlgt_05_sonoff_l1.ino +++ b/tasmota/xlgt_05_sonoff_l1.ino @@ -57,6 +57,12 @@ struct SNFL1 { uint8_t power; } Snfl1; +const char kL1Commands[] PROGMEM = "L1|" // prefix + "MusicSync"; + +void (* const L1Command[])(void) PROGMEM = { + &CmndMusicSync }; + /********************************************************************************************/ #ifdef SONOFF_L1_START_DELAY @@ -318,6 +324,55 @@ bool SnfL1ModuleSelected(void) return false; } +// SONOFF_L1_MODE_COLORFUL +void SnfL1ModeColorful() { + char buffer[SONOFF_L1_BUFFER_SIZE]; + snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"colorR\":%d,\"colorG\":%d,\"colorB\":%d,\"bright\":%d,\"mode\":%d"), + LocalTime(), millis()%1000, + Snfl1.power ? "on" : "off", + Snfl1.color[0], Snfl1.color[1], Snfl1.color[2], + Snfl1.dimmer, + SONOFF_L1_MODE_COLORFUL); + + SnfL1Send(buffer); +} + +// SONOFF_L1_MODE_SYNC_TO_MUSIC +void SnfL1ModeMusic(uint32_t sensitive, uint32_t speed) { + char buffer[SONOFF_L1_BUFFER_SIZE]; + snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d,\"sensitive\":%d,\"speed\":%d"), + LocalTime(), millis()%1000, + SONOFF_L1_MODE_SYNC_TO_MUSIC, + sensitive, + speed + ); + + SnfL1Send(buffer); +} + +void CmndMusicSync(void) +{ + // Format is L1MusicSync sensitivity,speed + // sensitivity 1..10, speed 1..100 + char *p; + strtok_r(XdrvMailbox.data, ",", &p); + if (0 == XdrvMailbox.payload) { + SnfL1SetChannels(); + + ResponseCmndDone(); + } + else if (p != nullptr) { + uint32_t sen = strtol(XdrvMailbox.data, nullptr, 0); + uint32_t spd = strtol(p, nullptr, 0); + if ( (sen >= 0) && (sen <= 10) && (spd >= 0) && (spd <= 100) ) { + SnfL1ModeMusic(sen, spd); + ResponseCmndDone(); + } + else { + return; // error + } + } +} /*********************************************************************************************\ * Interface \*********************************************************************************************/ @@ -336,6 +391,9 @@ bool Xlgt05(uint8_t function) case FUNC_MODULE_INIT: result = SnfL1ModuleSelected(); break; + case FUNC_COMMAND: + result = DecodeCommand(kL1Commands, L1Command); + break; } return result; } From 5076f428fe614259b4a76e0b685a77e279a37c21 Mon Sep 17 00:00:00 2001 From: blakadder Date: Thu, 28 Jan 2021 01:17:55 +0100 Subject: [PATCH 16/30] cleanup --- tasmota/xlgt_05_sonoff_l1.ino | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tasmota/xlgt_05_sonoff_l1.ino b/tasmota/xlgt_05_sonoff_l1.ino index 908015d68..4d70e6674 100644 --- a/tasmota/xlgt_05_sonoff_l1.ino +++ b/tasmota/xlgt_05_sonoff_l1.ino @@ -324,19 +324,6 @@ bool SnfL1ModuleSelected(void) return false; } -// SONOFF_L1_MODE_COLORFUL -void SnfL1ModeColorful() { - char buffer[SONOFF_L1_BUFFER_SIZE]; - snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"colorR\":%d,\"colorG\":%d,\"colorB\":%d,\"bright\":%d,\"mode\":%d"), - LocalTime(), millis()%1000, - Snfl1.power ? "on" : "off", - Snfl1.color[0], Snfl1.color[1], Snfl1.color[2], - Snfl1.dimmer, - SONOFF_L1_MODE_COLORFUL); - - SnfL1Send(buffer); -} - // SONOFF_L1_MODE_SYNC_TO_MUSIC void SnfL1ModeMusic(uint32_t sensitive, uint32_t speed) { char buffer[SONOFF_L1_BUFFER_SIZE]; From e68f31101e39154bbb110c56f25adc9e0d1165e4 Mon Sep 17 00:00:00 2001 From: Paul C Diem Date: Wed, 27 Jan 2021 19:43:20 -0600 Subject: [PATCH 17/30] Use dgr name for MQTT if SO88 --- tasmota/xdrv_35_pwm_dimmer.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index 0abd2206b..3bce167a2 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -619,13 +619,13 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed) if (mqtt_trigger) { char topic[TOPSZ]; sprintf_P(TasmotaGlobal.mqtt_data, PSTR("Trigger%u"), mqtt_trigger); -#ifdef USE_PWM_DIMMER_REMOTE - if (Settings.flag4.multiple_device_groups) { +#ifdef USE_DEVICE_GROUPS + if (Settings.flag4.device_groups_enabled) { snprintf_P(topic, sizeof(topic), PSTR("cmnd/%s/EVENT"), device_groups[power_button_index].group_name); MqttPublish(topic); } else -#endif // USE_PWM_DIMMER_REMOTE +#endif // USE_DEVICE_GROUPS MqttPublishPrefixTopic_P(CMND, PSTR("EVENT")); } From a436dd416d9e4d57c3e941e195e766abba1066dc Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 28 Jan 2021 09:04:42 +0100 Subject: [PATCH 18/30] Added macro for SO synonyms and MQTT --- tasmota/i18n.h | 8 +++++-- tasmota/tasmota_globals.h | 37 +++++++++++++++++++++++++++++++ tasmota/xdrv_02_mqtt.ino | 22 +++++++++++++++++- tasmota/xdrv_04_light.ino | 5 ++--- tasmota/xdrv_23_zigbee_A_impl.ino | 7 +++--- 5 files changed, 69 insertions(+), 10 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index d3f307069..28b1ea20d 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -349,7 +349,11 @@ #define D_CMND_CPU_FREQUENCY "CpuFrequency" #endif // ESP32 -// Commands xdrv_01_mqtt.ino +// Commands xdrv_02_mqtt.ino +#define D_SO_MQTTJSONONLY "MqttJSONOnly" +#define D_SO_MQTTTLS "MqttTLS" +#define D_SO_MQTTNORETAIN "MqttNoRetain" +#define D_SO_MQTTDETACHRELAY "MqttDetachRelay" #define D_CMND_MQTTLOG "MqttLog" #define D_CMND_MQTTHOST "MqttHost" #define D_CMND_MQTTPORT "MqttPort" @@ -375,7 +379,7 @@ #define D_CMND_SENSORRETAIN "SensorRetain" #define D_CMND_PUBLISH "Publish" -// Commands xdrv_02_webserver.ino +// Commands xdrv_01_webserver.ino #define D_CMND_WEBSERVER "Webserver" #define D_JSON_WEBSERVER_MODE "WebServerMode" #define D_JSON_ACTIVE_FOR "Active for" diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index be38261b7..cb3f4547b 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -472,6 +472,43 @@ bool first_device_group_is_local = true; #define DEBUG_TRACE_LOG(...) #endif + +/*********************************************************************************************\ + * Macro for SetOption synonyms + * + * SetOption synonyms come first in the list of commands, right after the prefix. + * They don't need any matching function pointer, since they are handled internally. + * So don't forget to NOT put pointers in the functions pointers list. + * + * The additionnal list of unsigned bytes contains the Option numbers of each synonyms + * in the same order. The first byte of the list contains the number of synonyms + * (not including the number itself). The is the number of names to skip to find the first command. + * + * As it si cumbersome to calculate the first byte (number of synonyms), we provide the following + * macro `SO_SYNONYMS(, )` + * + * For example: + * ``` + * SO_SYNONYMS(kLightSynonyms, + * 37, 68, 82, 91, 92, 105, + * 106, + * ); + * ``` + * + * is equivalent to: + * ``` + * const static uint8_t kLightSynonyms[] PROGMEM = { + * 7, // number of synonyms, automatically calculated + * 37, 68, 82, 91, 92, 105, + * 106, + * }; + * ``` + * + * This comes very handy if you need to adjust the number of synonyms depending on #defines +\*********************************************************************************************/ + +#define SO_SYNONYMS(N,...) const static uint8_t __syn_array_len_ ## N[] = { __VA_ARGS__ }; /* this first array will not be kept by linker, just used for sizeof() */ const static uint8_t N[] PROGMEM = { sizeof(__syn_array_len_ ## N), __VA_ARGS__ }; + /*********************************************************************************************/ #endif // _TASMOTA_GLOBALS_H_ diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 0c9779744..646df7037 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -32,6 +32,13 @@ WiFiClient EspClient; // Wifi Client - non-TLS const char kMqttCommands[] PROGMEM = "|" // No prefix + // SetOption synonyms + D_SO_MQTTJSONONLY "|" +#ifdef USE_MQTT_TLS + D_SO_MQTTTLS "|" +#endif + D_SO_MQTTNORETAIN "|" D_SO_MQTTDETACHRELAY "|" + // regular commands #if defined(USE_MQTT_TLS) && !defined(USE_MQTT_TLS_CA_CERT) D_CMND_MQTTFINGERPRINT "|" #endif @@ -43,6 +50,19 @@ const char kMqttCommands[] PROGMEM = "|" // No prefix D_CMND_FULLTOPIC "|" D_CMND_PREFIX "|" D_CMND_GROUPTOPIC "|" D_CMND_TOPIC "|" D_CMND_PUBLISH "|" D_CMND_MQTTLOG "|" D_CMND_BUTTONTOPIC "|" D_CMND_SWITCHTOPIC "|" D_CMND_BUTTONRETAIN "|" D_CMND_SWITCHRETAIN "|" D_CMND_POWERRETAIN "|" D_CMND_SENSORRETAIN ; +SO_SYNONYMS(kMqttSynonyms, + 90, +#ifdef USE_MQTT_TLS + 103, +#endif + 104, 114 +); + +// const uint8_t kMqttSynonyms[] PROGMEM = { +// 4, // number of synonyms +// 90, 103, 104, 114, +// }; + void (* const MqttCommand[])(void) PROGMEM = { #if defined(USE_MQTT_TLS) && !defined(USE_MQTT_TLS_CA_CERT) &CmndMqttFingerprint, @@ -1353,7 +1373,7 @@ bool Xdrv02(uint8_t function) break; #endif // USE_WEBSERVER case FUNC_COMMAND: - result = DecodeCommand(kMqttCommands, MqttCommand); + result = DecodeCommand(kMqttCommands, MqttCommand, kMqttSynonyms); break; } } diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index b3d014b21..637fb8f06 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -148,11 +148,10 @@ const char kLightCommands[] PROGMEM = "|" // No prefix #endif // USE_DGR_LIGHT_SEQUENCE "|UNDOCA" ; -const uint8_t kLightSynonyms[] PROGMEM = { - 7, // number of entries +SO_SYNONYMS(kLightSynonyms, 37, 68, 82, 91, 92, 105, 106, -}; +); void (* const LightCommand[])(void) PROGMEM = { &CmndColor, &CmndColorTemperature, &CmndDimmer, &CmndDimmerRange, &CmndDimmerStep, &CmndLedTable, &CmndFade, diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index b2209d2f0..ddc0a1358 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -42,11 +42,10 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix D_CMND_ZIGBEE_CONFIG "|" D_CMND_ZIGBEE_DATA ; -const uint8_t kZbSynonyms[] PROGMEM = { - 6, // number of synonyms +SO_SYNONYMS(kZbSynonyms, 83, 89, 100, 101, 110, - 112, -}; + 112, +); void (* const ZigbeeCommand[])(void) PROGMEM = { #ifdef USE_ZIGBEE_ZNP From 1502c0854005509af2e15b0217b75e9f18a03fb4 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 28 Jan 2021 16:41:59 +0100 Subject: [PATCH 19/30] Add support for once off speed and fade --- tasmota/xdrv_04_light.ino | 41 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 7e0907dd1..7fb7052c3 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -242,6 +242,10 @@ struct LIGHT { uint16_t fade_end_10[LST_MAX]; // 10 bits resolution target channel values uint16_t fade_duration = 0; // duration of fade in milliseconds uint32_t fade_start = 0; // fade start time in milliseconds, compared to millis() + bool fade_once_enabled = false; // override fade a single time + bool fade_once_value = false; // override fade a single time + bool speed_once_enabled = false; // override speed a single time + uint8_t speed_once_value = 0; // override speed a single time uint16_t pwm_min = 0; // minimum value for PWM, from DimmerRange, 0..1023 uint16_t pwm_max = 1023; // maxumum value for PWM, from DimmerRange, 0..1023 @@ -1598,6 +1602,16 @@ void LightSetPower(void) LightAnimate(); } +bool LightGetFadeSetting(void) { + if (Light.fade_once_enabled) return Light.fade_once_value; + return Settings.light_fade; +} + +uint8_t LightGetSpeedSetting(void) { + if (Light.speed_once_enabled) return Light.speed_once_value; + return Settings.light_speed; +} + // On entry Light.new_color[5] contains the color to be displayed // and Light.last_color[5] the color currently displayed // Light.power tells which lights or channels (SetOption68) are on/off @@ -1748,12 +1762,14 @@ void LightAnimate(void) cur_col_10[i] = orig_col_10bits[Light.color_remap[i]]; } - if (!Settings.light_fade || TasmotaGlobal.skip_light_fade || power_off || (!Light.fade_initialized)) { // no fade + if (!LightGetFadeSetting() || TasmotaGlobal.skip_light_fade || power_off || (!Light.fade_initialized)) { // no fade // record the current value for a future Fade memcpy(Light.fade_start_10, cur_col_10, sizeof(Light.fade_start_10)); // push the final values at 8 and 10 bits resolution to the PWMs LightSetOutputs(cur_col_10); Light.fade_initialized = true; // it is now ok to fade + Light.fade_once_enabled = false; // light has been set, reset fade_once_enabled + Light.speed_once_enabled = false; // light has been set, reset speed_once_enabled } else { // fade on if (Light.fade_running) { // if fade is running, we take the curring value as the start for the next fade @@ -1763,6 +1779,7 @@ void LightAnimate(void) Light.fade_running = true; Light.fade_duration = 0; // set the value to zero to force a recompute Light.fade_start = 0; + Light.fade_once_enabled = false; // fade will be applied, reset fade_once_enabled // Fade will applied immediately below } } @@ -1847,7 +1864,8 @@ bool LightApplyFade(void) { // did the value chanegd and needs to be applied // compute the duration of the animation // Note: Settings.light_speed is the number of half-seconds for a 100% fade, // i.e. light_speed=1 means 1024 steps in 500ms - Light.fade_duration = Settings.light_speed * 500; + Light.fade_duration = LightGetSpeedSetting() * 500; + Light.speed_once_enabled = false; // The once off speed value has been read, reset it if (!Settings.flag5.fade_fixed_duration) { Light.fade_duration = (distance * Light.fade_duration) / 1023; // time is proportional to distance, except with SO117 } @@ -2809,6 +2827,17 @@ void CmndRgbwwTable(void) void CmndFade(void) { + if (XdrvMailbox.index == 2) { + switch (XdrvMailbox.payload) { + case 0: // Off + case 1: // On + Light.fade_once_enabled = true; + Light.fade_once_value = XdrvMailbox.payload; + break; + } + return; + } + // Fade - Show current Fade state // Fade 0 - Turn Fade Off // Fade On - Turn Fade On @@ -2833,6 +2862,14 @@ void CmndFade(void) void CmndSpeed(void) { + if (XdrvMailbox.index == 2) { + if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 40)) { + Light.speed_once_enabled = true; + Light.speed_once_value = XdrvMailbox.payload; + } + return; + } + // Speed 1 - Fast // Speed 40 - Very slow // Speed + - Increment Speed From ac8d26982d220b15d8e8c089c26942f12798408b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 28 Jan 2021 17:52:17 +0100 Subject: [PATCH 20/30] Add Sonoff L1 Music Sync control Add command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed (#10722) --- CHANGELOG.md | 2 + RELEASENOTES.md | 2 + tasmota/xlgt_05_sonoff_l1.ino | 159 ++++++++++++++-------------------- 3 files changed, 68 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cad83cae6..6915df1c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ All notable changes to this project will be documented in this file. - Commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively - Support for ESP32 ``Module 5`` Wireless Tag Eth01 (#9496) - Support trailing silence in buzzer tune (#10694) +- Command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed (#10722) +- Commands ``Speed2`` and ``Fade2`` to control a once off speed and/or fade (#10730) ### Changed - Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 4789e7bb6..c0eef30eb 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -61,10 +61,12 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Command ``CTRange`` to specify the visible CT range the bulb is capable of [#10311](https://github.com/arendst/Tasmota/issues/10311) - Command ``RuleTimer0`` to access all RuleTimers at once [#10352](https://github.com/arendst/Tasmota/issues/10352) - Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels [#10311](https://github.com/arendst/Tasmota/issues/10311) +- Command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed [#10722](https://github.com/arendst/Tasmota/issues/10722) - Command ``SetOption40 0..250`` to disable button functionality if activated for over 0.1 second re-introduced - Command ``SetOption43 1..255`` to control Rotary step (#10407) - Command ``SetOption118 1`` to move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default [#10353](https://github.com/arendst/Tasmota/issues/10353) - Command ``SetOption119 1`` to remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic [#10355](https://github.com/arendst/Tasmota/issues/10355) +- Commands ``Speed2`` and ``Fade2`` to control a once off speed and/or fade [#10730](https://github.com/arendst/Tasmota/issues/10730) - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively - Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively - Commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively diff --git a/tasmota/xlgt_05_sonoff_l1.ino b/tasmota/xlgt_05_sonoff_l1.ino index 4d70e6674..78248c896 100644 --- a/tasmota/xlgt_05_sonoff_l1.ino +++ b/tasmota/xlgt_05_sonoff_l1.ino @@ -25,11 +25,11 @@ #define XLGT_05 5 -//#define SONOFF_L1_START_DELAY // Sync Nuvotron power state with Tasmota on power up +#define SONOFF_L1_START_DELAY // Sync Nuvotron power state with Tasmota on power up //#define SONOFF_L1_ALLOW_REMOTE_INTERRUPT // During schemes 2..4 #define SONOFF_L1_DEBUG1 // Add send and receive logging -#define SONOFF_L1_BUFFER_SIZE 140 +#define SONOFF_L1_BUFFER_SIZE 170 #define SONOFF_L1_MODE_COLORFUL 1 // [Color key] Colorful (static color) #define SONOFF_L1_MODE_COLORFUL_GRADIENT 2 // [SMOOTH] Colorful Gradient @@ -45,19 +45,21 @@ #define SONOFF_L1_MODE_SYNC_TO_MUSIC 12 // Sync to music [Speed 1- 100, sensitivity 1 - 10] struct SNFL1 { + char *buffer; #ifdef SONOFF_L1_ALLOW_REMOTE_INTERRUPT uint32_t unlock = 0; bool receive_ready = true; -#endif -#ifdef SONOFF_L1_START_DELAY - char buffer[SONOFF_L1_BUFFER_SIZE]; #endif uint8_t color[3]; uint8_t dimmer; uint8_t power; + uint8_t old_music_sync = 0; + uint8_t music_sync = 0; + uint8_t sensitive; + uint8_t speed; } Snfl1; -const char kL1Commands[] PROGMEM = "L1|" // prefix +const char kL1Commands[] PROGMEM = "L1|" // Prefix "MusicSync"; void (* const L1Command[])(void) PROGMEM = { @@ -72,45 +74,24 @@ Ticker SnfL1StartDelay; void SnfL1SendDelayed(void) { SnfL1Send(); } +#endif // SONOFF_L1_START_DELAY -void SnfL1Send(void) -{ +void SnfL1Send(void) { #ifdef SONOFF_L1_DEBUG1 - AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer); + AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer); #endif Serial.print(Snfl1.buffer); Serial.write(0x1B); Serial.flush(); } -void SnfL1SerialSendOk(void) -{ - snprintf_P(Snfl1.buffer, sizeof(Snfl1.buffer), PSTR("AT+SEND=ok")); +void SnfL1SerialSendOk(void) { + snprintf_P(Snfl1.buffer, SONOFF_L1_BUFFER_SIZE, PSTR("AT+SEND=ok")); SnfL1Send(); } -#else -void SnfL1Send(const char *buffer) -{ -#ifdef SONOFF_L1_DEBUG1 - AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), buffer); -#endif - Serial.print(buffer); - Serial.write(0x1B); - Serial.flush(); -} -void SnfL1SerialSendOk(void) -{ - char buffer[16]; - snprintf_P(buffer, sizeof(buffer), PSTR("AT+SEND=ok")); - - SnfL1Send(buffer); -} -#endif // SONOFF_L1_START_DELAY - -bool SnfL1SerialInput(void) -{ +bool SnfL1SerialInput(void) { if (TasmotaGlobal.serial_in_byte != 0x1B) { if (TasmotaGlobal.serial_in_byte_counter >= SONOFF_L1_BUFFER_SIZE) { TasmotaGlobal.serial_in_byte_counter = 0; @@ -125,7 +106,7 @@ bool SnfL1SerialInput(void) // AT+UPDATE="sequence":"34906","switch":"on","light_type":1,"colorR":0,"colorG":16,"colorB":0,"bright":6,"mode":1 // AT+UPDATE="switch":"on","light_type":1,"colorR":255,"colorG":0,"colorB":0,"bright":6,"mode":1,"speed":100,"sensitive":10 #ifdef SONOFF_L1_DEBUG1 - AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer); + AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer); #endif if (!strncmp(TasmotaGlobal.serial_in_buffer +3, "RESULT", 6)) { #ifdef SONOFF_L1_ALLOW_REMOTE_INTERRUPT @@ -246,8 +227,7 @@ bool SnfL1SerialInput(void) /********************************************************************************************/ -bool SnfL1SetChannels(void) -{ +bool SnfL1SetChannels(void) { #ifdef SONOFF_L1_ALLOW_REMOTE_INTERRUPT if (Snfl1.receive_ready || TimeReached(Snfl1.unlock)) { #endif @@ -269,34 +249,30 @@ bool SnfL1SetChannels(void) Snfl1.color[i] = scale_col[i]; } } - if (!power_changed && !dimmer_changed && !color_changed) { return true; } + if (!power_changed && !dimmer_changed && !color_changed && (Snfl1.old_music_sync == Snfl1.music_sync)) { return true; } -#ifdef SONOFF_L1_START_DELAY - snprintf_P(Snfl1.buffer, sizeof(Snfl1.buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"light_type\":1,\"colorR\":%d,\"colorG\":%d,\"colorB\":%d,\"bright\":%d,\"mode\":%d"), + uint32_t mode = SONOFF_L1_MODE_COLORFUL; + if (Snfl1.music_sync) { + mode = SONOFF_L1_MODE_SYNC_TO_MUSIC; + } + + snprintf_P(Snfl1.buffer, SONOFF_L1_BUFFER_SIZE, PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"light_type\":1,\"colorR\":%d,\"colorG\":%d,\"colorB\":%d,\"bright\":%d,\"mode\":%d,\"sensitive\":%d,\"speed\":%d"), LocalTime(), millis()%1000, Snfl1.power ? "on" : "off", Snfl1.color[0], Snfl1.color[1], Snfl1.color[2], Snfl1.dimmer, - SONOFF_L1_MODE_COLORFUL); + mode, + Snfl1.sensitive, + Snfl1.speed); +#ifdef SONOFF_L1_START_DELAY static bool first_call = true; if (first_call) { SnfL1StartDelay.once_ms(900, SnfL1SendDelayed); // Allow startup time for Nuvotron microcontroller first_call = false; - } else { - SnfL1Send(); - } -#else - char buffer[SONOFF_L1_BUFFER_SIZE]; - snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"light_type\":1,\"colorR\":%d,\"colorG\":%d,\"colorB\":%d,\"bright\":%d,\"mode\":%d"), - LocalTime(), millis()%1000, - Snfl1.power ? "on" : "off", - Snfl1.color[0], Snfl1.color[1], Snfl1.color[2], - Snfl1.dimmer, - SONOFF_L1_MODE_COLORFUL); - - SnfL1Send(buffer); + } else #endif // SONOFF_L1_START_DELAY + SnfL1Send(); #ifdef SONOFF_L1_ALLOW_REMOTE_INTERRUPT Snfl1.unlock = millis() + 500; // Allow time for the RC @@ -306,60 +282,53 @@ bool SnfL1SetChannels(void) return true; } -bool SnfL1ModuleSelected(void) -{ +bool SnfL1ModuleSelected(void) { if (SONOFF_L1 == TasmotaGlobal.module_type) { if (PinUsed(GPIO_RXD) && PinUsed(GPIO_TXD)) { - SetSerial(19200, TS_SERIAL_8N1); + Snfl1.buffer = (char*)malloc(SONOFF_L1_BUFFER_SIZE); + if (Snfl1.buffer) { + SetSerial(19200, TS_SERIAL_8N1); - Snfl1.power = !Light.power; - Snfl1.dimmer = !light_state.getDimmer(); + Snfl1.power = !Light.power; + Snfl1.dimmer = !light_state.getDimmer(); + Snfl1.music_sync = 0; + Snfl1.sensitive = 1; // 1..10 + Snfl1.speed = 1; // 1..100 - TasmotaGlobal.light_type = LT_RGB; - TasmotaGlobal.light_driver = XLGT_05; - AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Sonoff L1 Found")); - return true; + TasmotaGlobal.light_type = LT_RGB; + TasmotaGlobal.light_driver = XLGT_05; + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Sonoff L1 Found")); + return true; + } } } return false; } -// SONOFF_L1_MODE_SYNC_TO_MUSIC -void SnfL1ModeMusic(uint32_t sensitive, uint32_t speed) { - char buffer[SONOFF_L1_BUFFER_SIZE]; - snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d,\"sensitive\":%d,\"speed\":%d"), - LocalTime(), millis()%1000, - SONOFF_L1_MODE_SYNC_TO_MUSIC, - sensitive, - speed - ); - - SnfL1Send(buffer); -} - -void CmndMusicSync(void) -{ - // Format is L1MusicSync sensitivity,speed +void CmndMusicSync(void) { + // Format is L1MusicSync on/off/toggle, sensitivity, speed // sensitivity 1..10, speed 1..100 - char *p; - strtok_r(XdrvMailbox.data, ",", &p); - if (0 == XdrvMailbox.payload) { - SnfL1SetChannels(); - - ResponseCmndDone(); - } - else if (p != nullptr) { - uint32_t sen = strtol(XdrvMailbox.data, nullptr, 0); - uint32_t spd = strtol(p, nullptr, 0); - if ( (sen >= 0) && (sen <= 10) && (spd >= 0) && (spd <= 100) ) { - SnfL1ModeMusic(sen, spd); - ResponseCmndDone(); - } - else { - return; // error + if (XdrvMailbox.data_len > 0) { + Snfl1.old_music_sync = Snfl1.music_sync; + uint32_t parm[3] = { 0 }; + ParseParameters(3, parm); + if (2 == parm[0]) { + Snfl1.music_sync ^= 1; // Toggle + } else { + Snfl1.music_sync = parm[0] & 1; // On or Off } - } + if ((parm[1] > 0) && (parm[1] < 11)) { + Snfl1.sensitive = parm[1]; // 1..10 + } + if ((parm[2] > 0) && (parm[2] < 101)) { + Snfl1.speed = parm[2]; // 1..100 + } + SnfL1SetChannels(); + } + Response_P(PSTR("{\"%s\":{\"Mode\":\"%s\",\"Sensitive\":%d,\"Speed\":%d}}"), + XdrvMailbox.command, GetStateText(Snfl1.music_sync), Snfl1.sensitive, Snfl1.speed); } + /*********************************************************************************************\ * Interface \*********************************************************************************************/ From 7e566de93514315f74ead911d88aad61a74db7d4 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 28 Jan 2021 19:23:00 +0100 Subject: [PATCH 21/30] Initial support for ZStack 3 --- tasmota/xdrv_23_zigbee_7_0_statemachine.ino | 9 +++++---- tasmota/xdrv_23_zigbee_8_parsers.ino | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tasmota/xdrv_23_zigbee_7_0_statemachine.ino b/tasmota/xdrv_23_zigbee_7_0_statemachine.ino index 72d88a680..fcacc81c2 100644 --- a/tasmota/xdrv_23_zigbee_7_0_statemachine.ino +++ b/tasmota/xdrv_23_zigbee_7_0_statemachine.ino @@ -132,7 +132,7 @@ const char kZigbeeStarted[] PROGMEM = D_LOG_ZIGBEE "Zigbee started"; const char kResetting[] PROGMEM = "Resetting configuration"; const char kResettingDevice[] PROGMEM = D_LOG_ZIGBEE "Resetting EZSP device"; const char kReconfiguringDevice[] PROGMEM = D_LOG_ZIGBEE "Factory reset EZSP device"; -const char kZNP12[] PROGMEM = "Only ZNP 1.2 is currently supported"; +const char kZNP123[] PROGMEM = "Only ZNP 1.2 and 3.x are currently supported"; const char kEZ8[] PROGMEM = "Only EZSP protocol v8 is currently supported"; const char kAbort[] PROGMEM = "Abort"; const char kZigbeeAbort[] PROGMEM = D_LOG_ZIGBEE "Abort"; @@ -194,6 +194,7 @@ ZBM(ZBS_LOGTYPE_DEVICE, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CON // Write configuration - write success ZBM(ZBR_W_OK, Z_SRSP | Z_SAPI, SAPI_WRITE_CONFIGURATION, Z_SUCCESS ) // 660500 - Write Configuration ZBM(ZBR_WNV_OK, Z_SRSP | Z_SYS, SYS_OSAL_NV_WRITE, Z_SUCCESS ) // 610900 - NV Write +ZBM(ZBR_WNV_OKE, Z_SRSP | Z_SYS, SYS_OSAL_NV_WRITE ) // 6109xx - NV Write, OK or error // Factory reset ZBM(ZBS_FACTRES, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_STARTUP_OPTION, 0x01 /* len */, 0x03 ) // 2605030103 @@ -415,7 +416,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = { // Z_ZDO:startupFromApp //ZI_LOG(LOG_LEVEL_INFO, D_LOG_ZIGBEE "starting zigbee coordinator") ZI_SEND(ZBS_STARTUPFROMAPP) // start coordinator - ZI_WAIT_RECV(2000, ZBR_STARTUPFROMAPP) // wait for sync ack of command + ZI_WAIT_RECV(5000, ZBR_STARTUPFROMAPP) // wait for sync ack of command ZI_WAIT_UNTIL_FUNC(10000, AREQ_STARTUPFROMAPP, &ZNP_ReceiveStateChange) // wait for async message that coordinator started ZI_SEND(ZBS_GETDEVICEINFO) // GetDeviceInfo ZI_WAIT_RECV_FUNC(2000, ZBR_GETDEVICEINFO, &ZNP_ReceiveDeviceInfo) @@ -472,7 +473,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = { ZI_SEND(ZBS_W_PFGKEN) // write PRECFGKEY Enable ZI_WAIT_RECV(1000, ZBR_W_OK) ZI_SEND(ZBS_WNV_SECMODE) // write Security Mode - ZI_WAIT_RECV(1000, ZBR_WNV_OK) + ZI_WAIT_RECV(1000, ZBR_WNV_OKE) // Tolerate error for ZNP 3.x ZI_SEND(ZBS_W_ZDODCB) // write Z_ZDO Direct CB ZI_WAIT_RECV(1000, ZBR_W_OK) // Now mark the device as ready, writing 0x55 in memory slot 0x0F00 @@ -558,7 +559,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = { // Error: version of Z-Stack is not supported ZI_LABEL(ZIGBEE_LABEL_UNSUPPORTED_VERSION) - ZI_MQTT_STATE(ZIGBEE_STATUS_UNSUPPORTED_VERSION, kZNP12) + ZI_MQTT_STATE(ZIGBEE_STATUS_UNSUPPORTED_VERSION, kZNP123) ZI_GOTO(ZIGBEE_LABEL_ABORT) // Abort state machine, general error diff --git a/tasmota/xdrv_23_zigbee_8_parsers.ino b/tasmota/xdrv_23_zigbee_8_parsers.ino index c805eab13..a714d01af 100644 --- a/tasmota/xdrv_23_zigbee_8_parsers.ino +++ b/tasmota/xdrv_23_zigbee_8_parsers.ino @@ -372,8 +372,8 @@ int32_t ZNP_Reboot(int32_t res, SBuffer &buf) { MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE)); - if ((0x02 == major_rel) && (0x06 == minor_rel)) { - return 0; // version 2.6.x is ok + if ((0x02 == major_rel) && ((0x06 == minor_rel) || (0x07 == minor_rel))) { + return 0; // version 2.6.x and 2.7.x are ok } else { return ZIGBEE_LABEL_UNSUPPORTED_VERSION; // abort } @@ -403,8 +403,8 @@ int32_t ZNP_ReceiveCheckVersion(int32_t res, SBuffer &buf) { MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE)); - if ((0x02 == major_rel) && (0x06 == minor_rel)) { - return 0; // version 2.6.x is ok + if ((0x02 == major_rel) && ((0x06 == minor_rel) || (0x07 == minor_rel))) { + return 0; // version 2.6.x and 2.7.x are ok } else { return ZIGBEE_LABEL_UNSUPPORTED_VERSION; // abort } From 90afef99daa77e7f5eb6732149c0ccdb59bcceac Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 28 Jan 2021 19:52:08 +0100 Subject: [PATCH 22/30] Zibee add ``SetOption120 1`` or ``ZbEndpointTopic`` to add the endpoint as suffix in topic when using ``SetOption89 1`` --- tasmota/i18n.h | 1 + tasmota/settings.h | 2 +- tasmota/xdrv_23_zigbee_2a_devices_impl.ino | 5 +++++ tasmota/xdrv_23_zigbee_A_impl.ino | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 28b1ea20d..49a7ea347 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -539,6 +539,7 @@ #define D_SO_ZIGBEE_ENDPOINTSUFFIX "EndpointSuffix" #define D_SO_ZIGBEE_NOAUTOBIND "NoAutoBind" #define D_SO_ZIGBEE_NAMETOPIC "NameTopic" +#define D_SO_ZIGBEE_ENDPOINTTOPIC "EndpointTopic" #define D_ZIGBEE_NOT_STARTED "Zigbee not started" #define D_CMND_ZIGBEE_PERMITJOIN "PermitJoin" #define D_CMND_ZIGBEE_STATUS "Status" diff --git a/tasmota/settings.h b/tasmota/settings.h index ae81668fd..b10c972a6 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -145,7 +145,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t fade_fixed_duration : 1; // bit 3 (v9.1.0.2) - SetOption117 - (Light) run fading at fixed duration instead of fixed slew rate uint32_t zb_received_as_subtopic : 1; // bit 4 (v9.2.0.3) - SetOption118 - (Zigbee) Move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default uint32_t zb_omit_json_addr : 1; // bit 5 (v9.2.0.3) - SetOption119 - (Zigbee) Remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic - uint32_t spare06 : 1; // bit 6 + uint32_t zb_topic_endpoint : 1; // bit 6 (v9.2.0.4) - SetOption120 - (Zigbee) Append endpoint number to topic if device dependent (use with SetOption89) uint32_t spare07 : 1; // bit 7 uint32_t spare08 : 1; // bit 8 uint32_t spare09 : 1; // bit 9 diff --git a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino index b70a7edda..775621ffa 100644 --- a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino +++ b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino @@ -561,6 +561,11 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l } else { snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%04X"), TasmotaGlobal.mqtt_topic, shortaddr); } + if (Settings.flag5.zb_topic_endpoint) { + if (attr_list.isValidSrcEp()) { + snprintf_P(subtopic, sizeof(subtopic), PSTR("%s_%d"), subtopic, attr_list.src_ep); + } + } char stopic[TOPSZ]; if (Settings.flag5.zb_received_as_subtopic) GetTopic_P(stopic, TELE, subtopic, json_prefix); diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index ddc0a1358..4c6bfa214 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -26,7 +26,7 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix // SetOption synonyms D_SO_ZIGBEE_NAMEKEY "|" D_SO_ZIGBEE_DEVICETOPIC "|" D_SO_ZIGBEE_NOPREFIX "|" D_SO_ZIGBEE_ENDPOINTSUFFIX "|" D_SO_ZIGBEE_NOAUTOBIND "|" - D_SO_ZIGBEE_NAMETOPIC "|" + D_SO_ZIGBEE_NAMETOPIC "|" D_SO_ZIGBEE_ENDPOINTTOPIC "|" #ifdef USE_ZIGBEE_ZNP D_CMND_ZIGBEEZNPSEND "|" D_CMND_ZIGBEEZNPRECEIVE "|" #endif // USE_ZIGBEE_ZNP @@ -44,7 +44,7 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix SO_SYNONYMS(kZbSynonyms, 83, 89, 100, 101, 110, - 112, + 112, 120, ); void (* const ZigbeeCommand[])(void) PROGMEM = { From ef9a85481172c92b7f5a977a22d84a1aa1033443 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 28 Jan 2021 19:56:45 +0100 Subject: [PATCH 23/30] Respond to fade2 and speed2 --- tasmota/xdrv_04_light.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 5641608cc..ae1f64b64 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2844,6 +2844,7 @@ void CmndFade(void) Light.fade_once_value = XdrvMailbox.payload; break; } + ResponseCmndStateText(Light.fade_once_value); return; } @@ -2876,6 +2877,7 @@ void CmndSpeed(void) Light.speed_once_enabled = true; Light.speed_once_value = XdrvMailbox.payload; } + ResponseCmndNumber(Light.speed_once_value); return; } From 9a3e5f54749dca7642290c26e2e75d0e4c648485 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 28 Jan 2021 21:16:27 +0100 Subject: [PATCH 24/30] Merge fade2 with speed2 --- tasmota/xdrv_04_light.ino | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 5641608cc..bdc334d0e 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2836,17 +2836,6 @@ void CmndRgbwwTable(void) void CmndFade(void) { - if (XdrvMailbox.index == 2) { - switch (XdrvMailbox.payload) { - case 0: // Off - case 1: // On - Light.fade_once_enabled = true; - Light.fade_once_value = XdrvMailbox.payload; - break; - } - return; - } - // Fade - Show current Fade state // Fade 0 - Turn Fade Off // Fade On - Turn Fade On @@ -2863,18 +2852,19 @@ void CmndFade(void) #ifdef USE_DEVICE_GROUPS if (XdrvMailbox.payload >= 0 && XdrvMailbox.payload <= 2) SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade); #endif // USE_DEVICE_GROUPS -#ifdef USE_LIGHT if (!Settings.light_fade) { Light.fade_running = false; } -#endif // USE_LIGHT ResponseCmndStateText(Settings.light_fade); } void CmndSpeed(void) { if (XdrvMailbox.index == 2) { - if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 40)) { + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 40)) { + Light.fade_once_enabled = true; + Light.fade_once_value = XdrvMailbox.payload > 0; Light.speed_once_enabled = true; Light.speed_once_value = XdrvMailbox.payload; + if (!Light.fade_once_value) { Light.fade_running = false; } } return; } From 3297d0de714848bb1ce51ae33fe52c78071bcbf7 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 29 Jan 2021 10:12:24 +0100 Subject: [PATCH 25/30] Forgot changelog update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6915df1c3..631428316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - Support trailing silence in buzzer tune (#10694) - Command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed (#10722) - Commands ``Speed2`` and ``Fade2`` to control a once off speed and/or fade (#10730) +- Zibee add ``SetOption120 1`` or ``ZbEndpointTopic`` to add the endpoint as suffix in topic when using ``SetOption89 1`` ### Changed - Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages From 6298210e6ebf46bcd918e5299cfd2c4f38786687 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 29 Jan 2021 11:00:56 +0100 Subject: [PATCH 26/30] Change L1 music sync defaults --- tasmota/xlgt_05_sonoff_l1.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/xlgt_05_sonoff_l1.ino b/tasmota/xlgt_05_sonoff_l1.ino index 78248c896..23ed21e8d 100644 --- a/tasmota/xlgt_05_sonoff_l1.ino +++ b/tasmota/xlgt_05_sonoff_l1.ino @@ -292,8 +292,8 @@ bool SnfL1ModuleSelected(void) { Snfl1.power = !Light.power; Snfl1.dimmer = !light_state.getDimmer(); Snfl1.music_sync = 0; - Snfl1.sensitive = 1; // 1..10 - Snfl1.speed = 1; // 1..100 + Snfl1.sensitive = 5; // 1..10 + Snfl1.speed = 50; // 1..100 TasmotaGlobal.light_type = LT_RGB; TasmotaGlobal.light_driver = XLGT_05; From e16b78269bc16b7d9b6fd2a3f2a6d1a124a68706 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 29 Jan 2021 11:02:58 +0100 Subject: [PATCH 27/30] Revert "Merge pull request #10736 from emontnemery/once_off_speed_fade_fix" This reverts commit aa8a23e1d6c14bde161cafbb4a98c37c6c1200a1, reversing changes made to f6111e9824339bd2bac60a4c4da67d8b5b15ca62. --- tasmota/xdrv_04_light.ino | 2 -- 1 file changed, 2 deletions(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index ae1f64b64..5641608cc 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2844,7 +2844,6 @@ void CmndFade(void) Light.fade_once_value = XdrvMailbox.payload; break; } - ResponseCmndStateText(Light.fade_once_value); return; } @@ -2877,7 +2876,6 @@ void CmndSpeed(void) Light.speed_once_enabled = true; Light.speed_once_value = XdrvMailbox.payload; } - ResponseCmndNumber(Light.speed_once_value); return; } From 4c79b243365f634eacfaae61b7b0f7ab293a9233 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 29 Jan 2021 11:14:00 +0100 Subject: [PATCH 28/30] Update changelog --- CHANGELOG.md | 4 ++-- RELEASENOTES.md | 7 ++++--- tasmota/xdrv_24_buzzer.ino | 5 ++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 631428316..35353951b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,8 @@ All notable changes to this project will be documented in this file. - Support for ESP32 ``Module 5`` Wireless Tag Eth01 (#9496) - Support trailing silence in buzzer tune (#10694) - Command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed (#10722) -- Commands ``Speed2`` and ``Fade2`` to control a once off speed and/or fade (#10730) -- Zibee add ``SetOption120 1`` or ``ZbEndpointTopic`` to add the endpoint as suffix in topic when using ``SetOption89 1`` +- Command ``Speed2`` to control a once off fade (#10741) +- Zigbee command ``SetOption120 1`` or ``ZbEndpointTopic 1`` to add the endpoint as suffix in topic when using ``SetOption89 1`` ### Changed - Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c0eef30eb..84c5b9338 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -59,14 +59,15 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota ## Changelog v9.2.0.4 ### Added - Command ``CTRange`` to specify the visible CT range the bulb is capable of [#10311](https://github.com/arendst/Tasmota/issues/10311) -- Command ``RuleTimer0`` to access all RuleTimers at once [#10352](https://github.com/arendst/Tasmota/issues/10352) -- Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels [#10311](https://github.com/arendst/Tasmota/issues/10311) - Command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed [#10722](https://github.com/arendst/Tasmota/issues/10722) +- Command ``RuleTimer0`` to access all RuleTimers at once [#10352](https://github.com/arendst/Tasmota/issues/10352) +- Command ``Speed2`` to control a once off fade [#10741](https://github.com/arendst/Tasmota/issues/10741) +- Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels [#10311](https://github.com/arendst/Tasmota/issues/10311) - Command ``SetOption40 0..250`` to disable button functionality if activated for over 0.1 second re-introduced - Command ``SetOption43 1..255`` to control Rotary step (#10407) - Command ``SetOption118 1`` to move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default [#10353](https://github.com/arendst/Tasmota/issues/10353) - Command ``SetOption119 1`` to remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic [#10355](https://github.com/arendst/Tasmota/issues/10355) -- Commands ``Speed2`` and ``Fade2`` to control a once off speed and/or fade [#10730](https://github.com/arendst/Tasmota/issues/10730) +- Zigbee command ``SetOption120 1`` or ``ZbEndpointTopic 1`` to add the zigbee endpoint as suffix in topic when using ``SetOption89 1`` - Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively - Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively - Commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively diff --git a/tasmota/xdrv_24_buzzer.ino b/tasmota/xdrv_24_buzzer.ino index d02613d06..5df477d9f 100644 --- a/tasmota/xdrv_24_buzzer.ino +++ b/tasmota/xdrv_24_buzzer.ino @@ -177,10 +177,9 @@ void BuzzerEvery100mSec(void) { const char kBuzzerCommands[] PROGMEM = "Buzzer|" // Prefix "Active|Pwm||" ; -const uint8_t kBuzzerSynonyms[] PROGMEM = { - 2, // number of synonyms +SO_SYNONYMS(kBuzzerSynonyms, 67, 111 -}; +); void (* const BuzzerCommand[])(void) PROGMEM = { &CmndBuzzer }; From 26920cbb2ae8f684410d4d97c9ba391c3af64d96 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 29 Jan 2021 13:45:55 +0100 Subject: [PATCH 29/30] Zigbee more synonyms --- tasmota/i18n.h | 3 +++ tasmota/xdrv_23_zigbee_A_impl.ino | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 49a7ea347..e5919bbeb 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -540,6 +540,9 @@ #define D_SO_ZIGBEE_NOAUTOBIND "NoAutoBind" #define D_SO_ZIGBEE_NAMETOPIC "NameTopic" #define D_SO_ZIGBEE_ENDPOINTTOPIC "EndpointTopic" +#define D_SO_ZIGBEE_NOAUTOBIND "NoAutoBind" +#define D_SO_ZIGBEE_ZBRECEIVEDTOPIC "ReceivedTopic" +#define D_SO_ZIGBEE_OMITDEVICE "OmitDevice" #define D_ZIGBEE_NOT_STARTED "Zigbee not started" #define D_CMND_ZIGBEE_PERMITJOIN "PermitJoin" #define D_CMND_ZIGBEE_STATUS "Status" diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 4c6bfa214..14091c787 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -26,7 +26,7 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix // SetOption synonyms D_SO_ZIGBEE_NAMEKEY "|" D_SO_ZIGBEE_DEVICETOPIC "|" D_SO_ZIGBEE_NOPREFIX "|" D_SO_ZIGBEE_ENDPOINTSUFFIX "|" D_SO_ZIGBEE_NOAUTOBIND "|" - D_SO_ZIGBEE_NAMETOPIC "|" D_SO_ZIGBEE_ENDPOINTTOPIC "|" + D_SO_ZIGBEE_NAMETOPIC "|" D_SO_ZIGBEE_ENDPOINTTOPIC "|" D_SO_ZIGBEE_NOAUTOBIND "|" D_SO_ZIGBEE_ZBRECEIVEDTOPIC "|" D_SO_ZIGBEE_OMITDEVICE "|" #ifdef USE_ZIGBEE_ZNP D_CMND_ZIGBEEZNPSEND "|" D_CMND_ZIGBEEZNPRECEIVE "|" #endif // USE_ZIGBEE_ZNP @@ -44,7 +44,7 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix SO_SYNONYMS(kZbSynonyms, 83, 89, 100, 101, 110, - 112, 120, + 112, 120, 116, 118, 119, ); void (* const ZigbeeCommand[])(void) PROGMEM = { From 60841804195e5afefe0ae806dd3cfccd412ce214 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:05:47 +0100 Subject: [PATCH 30/30] Update changelog --- CHANGELOG.md | 7 ++++--- RELEASENOTES.md | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35353951b..9a591a2c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,10 @@ All notable changes to this project will be documented in this file. ## [9.2.0.4] ### Added - Function ``AddLog`` to provide logging for up to 128 (LOGSZ) characters to save stack space -- Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively -- Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively -- Commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively +- Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend`` and ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105`` and ``106`` +- Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind`` and ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110`` and ``112`` +- Commands ``ZbNoAutoBind``, ``ZbReceivedTopic`` and ``ZbOmitDevice`` as synonyms for ``SetOption116, 118`` and ``119`` +- Commands ``BuzzerActive`` and ``BuzzerPwm`` as synonyms for ``SetOption67`` and ``111`` - Support for ESP32 ``Module 5`` Wireless Tag Eth01 (#9496) - Support trailing silence in buzzer tune (#10694) - Command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed (#10722) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 84c5b9338..58177ee55 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -68,9 +68,10 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Command ``SetOption118 1`` to move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default [#10353](https://github.com/arendst/Tasmota/issues/10353) - Command ``SetOption119 1`` to remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic [#10355](https://github.com/arendst/Tasmota/issues/10355) - Zigbee command ``SetOption120 1`` or ``ZbEndpointTopic 1`` to add the zigbee endpoint as suffix in topic when using ``SetOption89 1`` -- Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively -- Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind``, ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110 and 112`` respectively -- Commands ``BuzzerActive``, ``BuzzerPwm`` as synonyms for ``SetOption67, 111`` respectively +- Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend`` and ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105`` and ``106`` +- Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind`` and ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110`` and ``112`` +- Commands ``ZbNoAutoBind``, ``ZbReceivedTopic`` and ``ZbOmitDevice`` as synonyms for ``SetOption116, 118`` and ``119`` +- Commands ``BuzzerActive`` and ``BuzzerPwm`` as synonyms for ``SetOption67`` and ``111`` - Milliseconds to console output [#10152](https://github.com/arendst/Tasmota/issues/10152) - Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196) - Rotary No Pullup GPIO selection ``Rotary A/B_n`` [#10407](https://github.com/arendst/Tasmota/issues/10407)