From 125c6a4402647dc9e7706bbf2dc273515b5507f1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 Jul 2020 09:03:04 +0200 Subject: [PATCH 01/25] sync platformio_override.ini with platformio.ini Platform is `platform = espressif8266@2.5.1` no need to install `platform = espressif8266@2.6.0` too. It is overwritten anyway with Tasmota core `platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.8.0-tasmota/esp8266-2.8.0.zip` Delete lwIP 1.4 from core_stage because it is not anymore in core > 2.7.2 --- platformio_override_sample.ini | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 3ec6c3a57..8499764fa 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -87,7 +87,7 @@ extra_scripts = ${scripts_defaults.extra_scripts} [tasmota_stage] ; *** Esp8266 core for Arduino version Tasmota stage -platform = espressif8266@2.6.0 +platform = espressif8266@2.5.1 platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.8.0-tasmota/esp8266-2.8.0.zip build_unflags = ${esp_defaults.build_unflags} build_flags = ${esp82xx_defaults.build_flags} @@ -143,8 +143,6 @@ build_flags = ${esp82xx_defaults.build_flags} ; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191122 ; NONOSDK3V0 (known issues) ; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3 -; lwIP 1.4 -; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH ; lwIP 2 - Low Memory ; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY ; lwIP 2 - Higher Bandwidth From fe99143f1c42b9f1c867cfdb8583eb133fe6e7c8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 Jul 2020 09:06:14 +0200 Subject: [PATCH 02/25] Tasmota Core 2.8.0 --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 597c69eff..a8b712779 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,7 +6,7 @@ - [ ] The pull request is done against the latest dev branch - [ ] Only relevant files were touched - [ ] Only one feature/fix was added per PR. - - [ ] The code change is tested and works on core ESP8266 V.2.7.2 + - [ ] The code change is tested and works on Tasmota core ESP8266 V.2.8.0 - [ ] The code change is tested and works on core ESP32 V.1.12.2 - [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla). From 02a30ae12bde246db2e3589194d3fb27986ca998 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 Jul 2020 12:08:06 +0200 Subject: [PATCH 03/25] Update platformio.ini --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index ad2b13c28..c68991444 100644 --- a/platformio.ini +++ b/platformio.ini @@ -124,6 +124,6 @@ build_flags = -DUSE_IR_REMOTE_FULL [core] ; *** Esp8266 Tasmota modified Arduino core based on core 2.7.2 platform = espressif8266@2.5.1 -platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.8.0-tasmota/esp8266-2.8.0.zip +platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.7.2.1/esp8266-2.7.2.1.zip build_unflags = ${esp_defaults.build_unflags} build_flags = ${esp82xx_defaults.build_flags} From 19c1bf2d7fd0ffbfe0699796827846cbbd5251b2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 Jul 2020 12:08:51 +0200 Subject: [PATCH 04/25] Update platformio_override_sample.ini --- platformio_override_sample.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 8499764fa..01aa03601 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -88,7 +88,7 @@ extra_scripts = ${scripts_defaults.extra_scripts} [tasmota_stage] ; *** Esp8266 core for Arduino version Tasmota stage platform = espressif8266@2.5.1 -platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.8.0-tasmota/esp8266-2.8.0.zip +platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.7.2.1/esp8266-2.7.2.1.zip build_unflags = ${esp_defaults.build_unflags} build_flags = ${esp82xx_defaults.build_flags} From f65e4a381faac47a76234b6903cc03a24ba47ea8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 Jul 2020 12:09:22 +0200 Subject: [PATCH 05/25] Update PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a8b712779..fa3a182c3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,7 +6,7 @@ - [ ] The pull request is done against the latest dev branch - [ ] Only relevant files were touched - [ ] Only one feature/fix was added per PR. - - [ ] The code change is tested and works on Tasmota core ESP8266 V.2.8.0 + - [ ] The code change is tested and works on Tasmota core ESP8266 V.2.7.2.1 - [ ] The code change is tested and works on core ESP32 V.1.12.2 - [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla). From 9d69c36355e03baf61358490085716719782357f Mon Sep 17 00:00:00 2001 From: bovirus <1262554+bovirus@users.noreply.github.com> Date: Thu, 16 Jul 2020 14:24:41 +0200 Subject: [PATCH 06/25] Update Italian language --- tasmota/language/it_IT.h | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index 788cee051..3d26d9f09 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -245,22 +245,22 @@ #define D_SECONDS "secondi" #define D_DEVICE_WILL_RESTART "Il dispositivo verrĂ  riavviato tra pochi secondi" #define D_BUTTON_TOGGLE "ON/OFF" -#define D_CONFIGURATION "Configurazione" +#define D_CONFIGURATION "Impostazioni" #define D_INFORMATION "Informazioni" #define D_FIRMWARE_UPGRADE "Aggiorna firmware" #define D_CONSOLE "Console" #define D_CONFIRM_RESTART "Conferma riavvio" -#define D_CONFIGURE_MODULE "Configura modulo" -#define D_CONFIGURE_WIFI "Configura WiFi" -#define D_CONFIGURE_MQTT "Configura MQTT" -#define D_CONFIGURE_DOMOTICZ "Configura Domoticz" -#define D_CONFIGURE_LOGGING "Livello registro" +#define D_CONFIGURE_MODULE "Modulo" +#define D_CONFIGURE_WIFI "Rete WiFi" +#define D_CONFIGURE_MQTT "MQTT" +#define D_CONFIGURE_DOMOTICZ "Domoticz" +#define D_CONFIGURE_LOGGING "Livelli registri" #define D_CONFIGURE_OTHER "Altre impostazioni" -#define D_CONFIRM_RESET_CONFIGURATION "Conferma ripristino configurazione" -#define D_RESET_CONFIGURATION "Ripristino configurazione" -#define D_BACKUP_CONFIGURATION "Backup configurazione" -#define D_RESTORE_CONFIGURATION "Ripristino configurazione" +#define D_CONFIRM_RESET_CONFIGURATION "Conferma ripristino impostazioni" +#define D_RESET_CONFIGURATION "Ripristino impostazioni" +#define D_BACKUP_CONFIGURATION "Backup impostazioni" +#define D_RESTORE_CONFIGURATION "Ripristino impostazioni" #define D_MAIN_MENU "Menu principale" #define D_MODULE_PARAMETERS "Parametri modulo" @@ -291,7 +291,7 @@ #define D_CLIENT "Client" #define D_FULL_TOPIC "Full topic" -#define D_LOGGING_PARAMETERS "Livelli registro eventi" +#define D_LOGGING_PARAMETERS "Livelli registri eventi" #define D_SERIAL_LOG_LEVEL "Livello registro seriale" #define D_MQTT_LOG_LEVEL "Livello registro MQTT" #define D_WEB_LOG_LEVEL "Livello registro web" @@ -313,15 +313,15 @@ #define D_SINGLE_DEVICE "dispositivo singolo" #define D_MULTI_DEVICE "dispositivo multiplo" -#define D_CONFIGURE_TEMPLATE "Configura modello" +#define D_CONFIGURE_TEMPLATE "Modello" #define D_TEMPLATE_PARAMETERS "Parametri modello" #define D_TEMPLATE_NAME "Nome" #define D_BASE_TYPE "Basato su" #define D_TEMPLATE_FLAGS "Opzioni" -#define D_SAVE_CONFIGURATION "Salva configurazione" -#define D_CONFIGURATION_SAVED "Configurazione salvata" -#define D_CONFIGURATION_RESET "Configurazione ripristinata" +#define D_SAVE_CONFIGURATION "Salva impostazioni" +#define D_CONFIGURATION_SAVED "Impostazioni salvate" +#define D_CONFIGURATION_RESET "Impostazioni ripristinate" #define D_PROGRAM_VERSION "Versione programma" #define D_BUILD_DATE_AND_TIME "Data/ora compilazione" @@ -416,7 +416,7 @@ #define D_DOMOTICZ_UPDATE_TIMER "Intervallo aggiornamento" // xdrv_09_timers.ino -#define D_CONFIGURE_TIMER "Configura timer" +#define D_CONFIGURE_TIMER "Timer" #define D_TIMER_PARAMETERS "Parametri timer" #define D_TIMER_ENABLE "Abilita timer" #define D_TIMER_ARM "Attiva" @@ -427,7 +427,7 @@ #define D_TIMER_ACTION "Azione" // xdrv_10_knx.ino -#define D_CONFIGURE_KNX "Configura KNX" +#define D_CONFIGURE_KNX "KNX" #define D_KNX_PARAMETERS "Parametri KNX" #define D_KNX_GENERAL_CONFIG "Generale" #define D_KNX_PHYSICAL_ADDRESS "Indirizzo fisico" @@ -461,7 +461,7 @@ #define D_DOMOTICZ_SHUTTER "Serranda" // xdrv_28_pcf8574.ino -#define D_CONFIGURE_PCF8574 "Configura PCF8574" +#define D_CONFIGURE_PCF8574 "PCF8574" #define D_PCF8574_PARAMETERS "Parametri PCF8574" #define D_INVERT_PORTS "Inverti porte" #define D_DEVICE "Dispositivo" @@ -511,7 +511,7 @@ #define D_HX_CAL_DONE "Calibrato" #define D_HX_CAL_FAIL "Calibrazione fallita" #define D_RESET_HX711 "Ripristino scala" -#define D_CONFIGURE_HX711 "Configura scala" +#define D_CONFIGURE_HX711 "Scala" #define D_HX711_PARAMETERS "Parametri scala" #define D_ITEM_WEIGHT "Peso oggetto" #define D_REFERENCE_WEIGHT "Peso di riferimento" @@ -703,8 +703,8 @@ #define D_SENSOR_ETH_PHY_MDIO "ETH MDIO" #define D_SENSOR_TCP_TXD "TCP - TX" #define D_SENSOR_TCP_RXD "TCP - RX" -#define D_SENSOR_IEM3000_TX "iEM3000 TX" -#define D_SENSOR_IEM3000_RX "iEM3000 RX" +#define D_SENSOR_IEM3000_TX "iEM3000 - TX" +#define D_SENSOR_IEM3000_RX "iEM3000 - RX" // Units #define D_UNIT_AMPERE "A" From 858d1503985b34e33732fba85d16fa4ef5e21c9c Mon Sep 17 00:00:00 2001 From: Walter Zengel Date: Thu, 16 Jul 2020 16:42:06 +0200 Subject: [PATCH 07/25] issues #8866 update tuyatime every 60sec --- tasmota/xdrv_16_tuyamcu.ino | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 7165126f5..47adaaf65 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -62,6 +62,9 @@ struct TUYA { uint8_t data_len = 0; // Data lenght of command uint8_t wifi_state = -2; // Keep MCU wifi-status in sync with WifiState() uint8_t heartbeat_timer = 0; // 10 second heartbeat timer for tuya module +#ifdef USE_TUYA_TIME + uint8_t settime_timer = 0; // 60 second settime timer for tuya module +#endif //USE_TUYA_TIME #ifdef USE_ENERGY_SENSOR uint32_t lastPowerCheckTime = 0; // Time when last power was checked #endif // USE_ENERGY_SENSOR @@ -881,6 +884,13 @@ bool Xdrv16(uint8_t function) Tuya.heartbeat_timer = 0; TuyaSendCmd(TUYA_CMD_HEARTBEAT); } + #ifdef USE_TUYA_TIME + Tuya.settime_timer++; + if (Tuya.settime_timer > 60) { + Tuya.settime_timer = 0; + TuyaSetTime(); + } + #endif } else { TuyaSendLowPowerSuccessIfNeeded(); } From 66b3dc1cf2109ea8fa1bb9a5f6d2e53e12f90e97 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 16 Jul 2020 16:46:30 +0200 Subject: [PATCH 08/25] Increase TLS fingerprint security --- tasmota/WiFiClientSecureLightBearSSL.cpp | 93 +++++++++++++++++++++++- tasmota/WiFiClientSecureLightBearSSL.h | 5 ++ tasmota/xdrv_02_mqtt.ino | 31 ++++++++ 3 files changed, 128 insertions(+), 1 deletion(-) diff --git a/tasmota/WiFiClientSecureLightBearSSL.cpp b/tasmota/WiFiClientSecureLightBearSSL.cpp index d0907788e..0d69ff810 100755 --- a/tasmota/WiFiClientSecureLightBearSSL.cpp +++ b/tasmota/WiFiClientSecureLightBearSSL.cpp @@ -695,18 +695,56 @@ extern "C" { xc->done_cert = true; // first cert already processed } +// **** Start patch Castellucci +/* static void pubkeyfingerprint_pubkey_fingerprint(br_sha1_context *shactx, br_rsa_public_key rsakey) { br_sha1_init(shactx); br_sha1_update(shactx, "ssh-rsa", 7); // tag br_sha1_update(shactx, rsakey.e, rsakey.elen); // exponent br_sha1_update(shactx, rsakey.n, rsakey.nlen); // modulus } +*/ + // If `compat` id false, adds a u32be length prefixed value to the sha1 state. + // If `compat` is true, the length will be omitted for compatibility with + // data from older versions of Tasmota. + static void sha1_update_len(br_sha1_context *shactx, const void *msg, uint32_t len, bool compat) { + uint8_t buf[] = {0, 0, 0, 0}; + + if (!compat) { + buf[0] = (len >> 24) & 0xff; + buf[1] = (len >> 16) & 0xff; + buf[2] = (len >> 8) & 0xff; + buf[3] = (len >> 0) & 0xff; + br_sha1_update(shactx, buf, 4); // length + } + br_sha1_update(shactx, msg, len); // message + } + + // Update the received fingerprint based on the certificate's public key. + // If `compat` is true, an insecure version of the fingerprint will be + // calcualted for compatibility with older versions of Tasmota. Normally, + // `compat` should be false. + static void pubkeyfingerprint_pubkey_fingerprint(br_x509_pubkeyfingerprint_context *xc, bool compat) { + br_rsa_public_key rsakey = xc->ctx.pkey.key.rsa; + + br_sha1_context shactx; + + br_sha1_init(&shactx); + + sha1_update_len(&shactx, "ssh-rsa", 7, compat); // tag + sha1_update_len(&shactx, rsakey.e, rsakey.elen, compat); // exponent + sha1_update_len(&shactx, rsakey.n, rsakey.nlen, compat); // modulus + + br_sha1_out(&shactx, xc->pubkey_recv_fingerprint); // copy to fingerprint + } +// **** End patch Castellucci // Callback when complete chain has been parsed. // Return 0 on validation success, !0 on validation error static unsigned pubkeyfingerprint_end_chain(const br_x509_class **ctx) { br_x509_pubkeyfingerprint_context *xc = (br_x509_pubkeyfingerprint_context *)ctx; - +// **** Start patch Castellucci +/* br_sha1_context sha1_context; pubkeyfingerprint_pubkey_fingerprint(&sha1_context, xc->ctx.pkey.key.rsa); br_sha1_out(&sha1_context, xc->pubkey_recv_fingerprint); // copy to fingerprint @@ -723,6 +761,59 @@ extern "C" { // Default (no validation at all) or no errors in prior checks = success. return 0; } +*/ + // set fingerprint status byte to zero + // FIXME: find a better way to pass this information + xc->pubkey_recv_fingerprint[20] = 0; + // Try matching using the the new fingerprint algorithm + pubkeyfingerprint_pubkey_fingerprint(xc, false); + if (!xc->fingerprint_all) { + if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint1, 20)) { + return 0; + } + if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint2, 20)) { + return 0; + } + + // No match under new algorithm, do some basic checking on the key. + // + // RSA keys normally have an e value of 65537, which is three bytes long. + // Other e values are suspicious, but if the modulus is a standard size + // (multiple of 512 bits/64 bytes), any public exponent up to eight bytes + // long will be allowed. + // + // A legitimate key could possibly be marked as bad by this check, but + // the user would have had to really worked at making a strange key. + if (!(xc->ctx.pkey.key.rsa.elen == 3 + && xc->ctx.pkey.key.rsa.e[0] == 1 + && xc->ctx.pkey.key.rsa.e[1] == 0 + && xc->ctx.pkey.key.rsa.e[2] == 1)) { + if (xc->ctx.pkey.key.rsa.nlen & 63 != 0 || xc->ctx.pkey.key.rsa.elen > 8) { + return 2; // suspicious key, return error + } + } + + // try the old algorithm and potentially mark for update + pubkeyfingerprint_pubkey_fingerprint(xc, true); + if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint1, 20)) { + xc->pubkey_recv_fingerprint[20] |= 1; // mark for update + } + if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint2, 20)) { + xc->pubkey_recv_fingerprint[20] |= 2; // mark for update + } + if (!xc->pubkey_recv_fingerprint[20]) { + return 1; // not marked for update because no match, error + } + + // the old fingerprint format matched, recompute new one for update + pubkeyfingerprint_pubkey_fingerprint(xc, false); + + return 0; + } else { + // Default (no validation at all) or no errors in prior checks = success. + return 0; + } +// **** End patch Castellucci } // Return the public key from the validator (set by x509_minimal) diff --git a/tasmota/WiFiClientSecureLightBearSSL.h b/tasmota/WiFiClientSecureLightBearSSL.h index e5908275e..274f1b2dc 100755 --- a/tasmota/WiFiClientSecureLightBearSSL.h +++ b/tasmota/WiFiClientSecureLightBearSSL.h @@ -121,7 +121,12 @@ class WiFiClientSecure_light : public WiFiClient { bool _fingerprint_any; // accept all fingerprints const uint8_t *_fingerprint1; // fingerprint1 to be checked against const uint8_t *_fingerprint2; // fingerprint2 to be checked against +// **** Start patch Castellucci +/* uint8_t _recv_fingerprint[20]; // fingerprint received +*/ + uint8_t _recv_fingerprint[21]; // fingerprint received +// **** End patch Castellucci unsigned char *_recvapp_buf; size_t _recvapp_len; diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 7a7eae075..a24d51de3 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -637,6 +637,8 @@ void MqttReconnect(void) AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR("MFLN not supported by TLS server")); } #ifndef USE_MQTT_TLS_CA_CERT // don't bother with fingerprints if using CA validation +// **** Start patch Castellucci +/* // create a printable version of the fingerprint received char buf_fingerprint[64]; ToHex_P((unsigned char *)tlsClient->getRecvPubKeyFingerprint(), 20, buf_fingerprint, sizeof(buf_fingerprint), ' '); @@ -665,6 +667,35 @@ void MqttReconnect(void) SettingsSaveAll(); // save settings } } +*/ + const uint8_t *recv_fingerprint = tlsClient->getRecvPubKeyFingerprint(); + // create a printable version of the fingerprint received + char buf_fingerprint[64]; + ToHex_P(recv_fingerprint, 20, buf_fingerprint, sizeof(buf_fingerprint), ' '); + AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Server fingerprint: %s"), buf_fingerprint); + + bool learned = false; + + // If the fingerprint slot is marked for update, we'll do so. + // Otherwise, if the fingerprint slot had the magic trust-on-first-use + // value, we will save the current fingerprint there, but only if the other fingerprint slot + // *didn't* match it. + if (recv_fingerprint[20] & 0x1 || (learn_fingerprint1 && 0 != memcmp(recv_fingerprint, Settings.mqtt_fingerprint[1], 20))) { + memcpy(Settings.mqtt_fingerprint[0], recv_fingerprint, 20); + learned = true; + } + // As above, but for the other slot. + if (recv_fingerprint[20] & 0x2 || (learn_fingerprint2 && 0 != memcmp(recv_fingerprint, Settings.mqtt_fingerprint[0], 20))) { + memcpy(Settings.mqtt_fingerprint[1], recv_fingerprint, 20); + learned = true; + } + + if (learned) { + AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "Fingerprint learned: %s"), buf_fingerprint); + + SettingsSaveAll(); // save settings + } +// **** End patch Castellucci #endif // !USE_MQTT_TLS_CA_CERT #endif // USE_MQTT_TLS MqttConnected(); From 88138273766bceb6d16b36302aa45a900f03461a Mon Sep 17 00:00:00 2001 From: Walter Zengel Date: Thu, 16 Jul 2020 17:13:19 +0200 Subject: [PATCH 09/25] issues #8866 --- tasmota/xdrv_16_tuyamcu.ino | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 47adaaf65..982a5c796 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -62,9 +62,6 @@ struct TUYA { uint8_t data_len = 0; // Data lenght of command uint8_t wifi_state = -2; // Keep MCU wifi-status in sync with WifiState() uint8_t heartbeat_timer = 0; // 10 second heartbeat timer for tuya module -#ifdef USE_TUYA_TIME - uint8_t settime_timer = 0; // 60 second settime timer for tuya module -#endif //USE_TUYA_TIME #ifdef USE_ENERGY_SENSOR uint32_t lastPowerCheckTime = 0; // Time when last power was checked #endif // USE_ENERGY_SENSOR @@ -543,9 +540,6 @@ void TuyaNormalPowerModePacketProcess(void) if (Tuya.buffer[6] == 0) { AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart")); Tuya.wifi_state = -2; - #ifdef USE_TUYA_TIME - TuyaSetTime(); - #endif } break; @@ -885,12 +879,10 @@ bool Xdrv16(uint8_t function) TuyaSendCmd(TUYA_CMD_HEARTBEAT); } #ifdef USE_TUYA_TIME - Tuya.settime_timer++; - if (Tuya.settime_timer > 60) { - Tuya.settime_timer = 0; + if (!(uptime % 60)) { TuyaSetTime(); - } - #endif + } + #endif //USE_TUYA_TIME } else { TuyaSendLowPowerSuccessIfNeeded(); } From 2ad758117d18e7a91bd0706020f4aaac9602589d Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Thu, 16 Jul 2020 17:15:12 +0200 Subject: [PATCH 10/25] scripter add event result --- lib/LinkedList-1.2.3/LinkedList.h | 98 ++++++++++++++++++++++++++++++- tasmota/xdrv_10_scripter.ino | 26 ++++++-- 2 files changed, 118 insertions(+), 6 deletions(-) mode change 100644 => 100755 lib/LinkedList-1.2.3/LinkedList.h diff --git a/lib/LinkedList-1.2.3/LinkedList.h b/lib/LinkedList-1.2.3/LinkedList.h old mode 100644 new mode 100755 index 371b14ac7..64321cf01 --- a/lib/LinkedList-1.2.3/LinkedList.h +++ b/lib/LinkedList-1.2.3/LinkedList.h @@ -39,8 +39,11 @@ protected: ListNode* getNode(int index); + ListNode* findEndOfSortedString(ListNode *p, int (*cmp)(T &, T &)); + public: LinkedList(); + LinkedList(int sizeIndex, T _t); //initiate list size and default value ~LinkedList(); /* @@ -65,7 +68,6 @@ public: virtual bool unshift(T); /* Set the object at index, with T; - Increment _size; */ virtual bool set(int index, T); /* @@ -94,6 +96,16 @@ public: */ virtual void clear(); + /* + Sort the list, given a comparison function + */ + virtual void sort(int (*cmp)(T &, T &)); + + // add support to array brakets [] operator + inline T& operator[](int index); + inline T& operator[](size_t& i) { return this->get(i); } + inline const T& operator[](const size_t& i) const { return this->get(i); } + }; // Initialize LinkedList with false values @@ -157,7 +169,7 @@ ListNode* LinkedList::getNode(int index){ return current; } - return false; + return NULL; } template @@ -165,6 +177,13 @@ int LinkedList::size(){ return _size; } +template +LinkedList::LinkedList(int sizeIndex, T _t){ + for (int i = 0; i < sizeIndex; i++){ + add(_t); + } +} + template bool LinkedList::add(int index, T _t){ @@ -226,6 +245,12 @@ bool LinkedList::unshift(T _t){ return true; } + +template +T& LinkedList::operator[](int index) { + return getNode(index)->data; +} + template bool LinkedList::set(int index, T _t){ // Check if index position is in bounds @@ -322,4 +347,73 @@ void LinkedList::clear(){ shift(); } +template +void LinkedList::sort(int (*cmp)(T &, T &)){ + if(_size < 2) return; // trivial case; + + for(;;) { + + ListNode **joinPoint = &root; + + while(*joinPoint) { + ListNode *a = *joinPoint; + ListNode *a_end = findEndOfSortedString(a, cmp); + + if(!a_end->next ) { + if(joinPoint == &root) { + last = a_end; + isCached = false; + return; + } + else { + break; + } + } + + ListNode *b = a_end->next; + ListNode *b_end = findEndOfSortedString(b, cmp); + + ListNode *tail = b_end->next; + + a_end->next = NULL; + b_end->next = NULL; + + while(a && b) { + if(cmp(a->data, b->data) <= 0) { + *joinPoint = a; + joinPoint = &a->next; + a = a->next; + } + else { + *joinPoint = b; + joinPoint = &b->next; + b = b->next; + } + } + + if(a) { + *joinPoint = a; + while(a->next) a = a->next; + a->next = tail; + joinPoint = &a->next; + } + else { + *joinPoint = b; + while(b->next) b = b->next; + b->next = tail; + joinPoint = &b->next; + } + } + } +} + +template +ListNode* LinkedList::findEndOfSortedString(ListNode *p, int (*cmp)(T &, T &)) { + while(p->next && cmp(p->data, p->next->data) <= 0) { + p = p->next; + } + + return p; +} + #endif diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 06e482a4d..b885feadf 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -194,7 +194,7 @@ void LoadFile(const char *name,uint8_t *buf,uint32_t len) { #define EPOCH_OFFSET 1546300800 enum {OPER_EQU=1,OPER_PLS,OPER_MIN,OPER_MUL,OPER_DIV,OPER_PLSEQU,OPER_MINEQU,OPER_MULEQU,OPER_DIVEQU,OPER_EQUEQU,OPER_NOTEQU,OPER_GRTEQU,OPER_LOWEQU,OPER_GRT,OPER_LOW,OPER_PERC,OPER_XOR,OPER_AND,OPER_OR,OPER_ANDEQU,OPER_OREQU,OPER_XOREQU,OPER_PERCEQU}; -enum {SCRIPT_LOGLEVEL=1,SCRIPT_TELEPERIOD}; +enum {SCRIPT_LOGLEVEL=1,SCRIPT_TELEPERIOD,SCRIPT_EVENT_HANDLED}; #ifdef USE_SCRIPT_FATFS @@ -379,6 +379,7 @@ struct SCRIPT_MEM { #endif } glob_script_mem; +bool event_handeled = false; #ifdef USE_SCRIPT_GLOBVARS @@ -1573,6 +1574,11 @@ chknext: fvar=UtcTime()-(uint32_t)EPOCH_OFFSET; goto exit; } + if (!strncmp(vname,"eres",4)) { + fvar=event_handeled; + tind->index=SCRIPT_EVENT_HANDLED; + goto exit_settable; + } #ifdef USE_ENERGY_SENSOR if (!strncmp(vname,"enrg[",5)) { lp+=5; @@ -3901,6 +3907,9 @@ int16_t Run_script_sub(const char *type, int8_t tlen, JsonObject *jo) { if (*dfvar>300) *dfvar=300; Settings.tele_period=*dfvar; break; + case SCRIPT_EVENT_HANDLED: + event_handeled=*dfvar; + break; } sysv_type=0; } @@ -4063,7 +4072,9 @@ void ScripterEvery100ms(void) { Run_Scripter(">T",2, mqtt_data); } } - if (fast_script==99) Run_Scripter(">F",2,0); + if (Settings.rule_enabled) { + if (fast_script==99) Run_Scripter(">F",2,0); + } } //mems[5] is 50 bytes in 6.5 @@ -6619,6 +6630,7 @@ void cpy2lf(char *dst,uint32_t dstlen, char *src) { bool Xdrv10(uint8_t function) { bool result = false; + event_handeled = false; char *sprt; switch (function) { @@ -6778,11 +6790,17 @@ bool Xdrv10(uint8_t function) #ifdef SCRIPT_POWER_SECTION if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">P",2,0); #else - if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E",2,0); + if (bitRead(Settings.rule_enabled, 0)) { + Run_Scripter(">E",2,0); + result=event_handeled; + } #endif break; case FUNC_RULES_PROCESS: - if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E",2,mqtt_data); + if (bitRead(Settings.rule_enabled, 0)) { + Run_Scripter(">E",2,mqtt_data); + result=event_handeled; + } break; #ifdef USE_WEBSERVER case FUNC_WEB_ADD_BUTTON: From 031b04fb536c5f7dbb5985d401411b0eedf1e2f7 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 16 Jul 2020 17:28:47 +0200 Subject: [PATCH 11/25] Add check for valid time --- tasmota/xdrv_16_tuyamcu.ino | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 982a5c796..82bc4ef7f 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -802,8 +802,9 @@ void TuyaSetWifiLed(void) } #ifdef USE_TUYA_TIME -void TuyaSetTime(void) -{ +void TuyaSetTime(void) { + if (!RtcTime.valid) { return; } + uint16_t payload_len = 8; uint8_t payload_buffer[8]; payload_buffer[0] = 0x01; @@ -878,13 +879,13 @@ bool Xdrv16(uint8_t function) Tuya.heartbeat_timer = 0; TuyaSendCmd(TUYA_CMD_HEARTBEAT); } - #ifdef USE_TUYA_TIME +#ifdef USE_TUYA_TIME if (!(uptime % 60)) { TuyaSetTime(); } - #endif //USE_TUYA_TIME +#endif //USE_TUYA_TIME } else { - TuyaSendLowPowerSuccessIfNeeded(); + TuyaSendLowPowerSuccessIfNeeded(); } break; case FUNC_SET_CHANNELS: From 29e73b4291fc470981038fca1c6870ff1f2a25ab Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 16 Jul 2020 17:50:26 +0200 Subject: [PATCH 12/25] Fix GCC 10.1 warning --- tasmota/xsns_40_pn532.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/xsns_40_pn532.ino b/tasmota/xsns_40_pn532.ino index 8218d0b35..3c29d4c82 100644 --- a/tasmota/xsns_40_pn532.ino +++ b/tasmota/xsns_40_pn532.ino @@ -559,6 +559,7 @@ bool PN532_Command(void) return serviced; } } + return false; } #endif // USE_PN532_DATA_FUNCTION From 2705c8eb8bb44b6894e11d2c45260614250a841c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 16 Jul 2020 18:02:39 +0200 Subject: [PATCH 13/25] Fix GCC 10.1 warnings --- tasmota/xnrg_12_solaxX1.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/xnrg_12_solaxX1.ino b/tasmota/xnrg_12_solaxX1.ino index 418a92acb..513cf1317 100644 --- a/tasmota/xnrg_12_solaxX1.ino +++ b/tasmota/xnrg_12_solaxX1.ino @@ -236,6 +236,7 @@ uint8_t solaxX1_ParseErrorCode(uint32_t code){ if (ErrCode.TemperatureOverFault) return 6; if (ErrCode.FanFault) return 7; if (ErrCode.OtherDeviceFault) return 8; + return 0; } /*********************************************************************************************/ From 6b0870343ba6142e99335632382a8eef30f9c234 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 16 Jul 2020 18:21:19 +0200 Subject: [PATCH 14/25] Change to limited support of Arduino IDE Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE --- FIRMWARE.md | 4 ++-- README.md | 4 ++-- RELEASENOTES.md | 3 ++- tasmota/CHANGELOG.md | 4 ++++ tasmota/tasmota.ino | 27 +++++++++++++++------------ tasmota/tasmota_version.h | 2 +- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/FIRMWARE.md b/FIRMWARE.md index 4feb4126d..d66bd1ba1 100644 --- a/FIRMWARE.md +++ b/FIRMWARE.md @@ -1,14 +1,14 @@ ![Tasmota logo](https://github.com/arendst/Tasmota/blob/development/tools/logo/TASMOTA_FullLogo_Vector.svg) Alternative firmware for [ESP8266](https://en.wikipedia.org/wiki/ESP8266) based devices with **easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX**. -_Written for Arduino IDE and PlatformIO._ +_Written for PlatformIO with limited support for Arduino IDE._ [![GitHub version](https://img.shields.io/github/release/arendst/Tasmota.svg)](https://github.com/arendst/Tasmota/releases/latest) [![GitHub download](https://img.shields.io/github/downloads/arendst/Tasmota/total.svg)](https://github.com/arendst/Tasmota/releases/latest) [![License](https://img.shields.io/github/license/arendst/Tasmota.svg)](LICENSE.txt) [![Chat](https://img.shields.io/discord/479389167382691863.svg)](https://discord.gg/Ks2Kzd4) -If you like **Tasmota**, give it a star, or fork it and contribute! +If you like **Tasmota**, give it a star, or fork it and contribute! [![GitHub stars](https://img.shields.io/github/stars/arendst/Tasmota.svg?style=social&label=Star)](https://github.com/arendst/Tasmota/stargazers) [![GitHub forks](https://img.shields.io/github/forks/arendst/Tasmota.svg?style=social&label=Fork)](https://github.com/arendst/Tasmota/network) diff --git a/README.md b/README.md index f5d40a631..19fbff041 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ ![Tasmota logo](/tools/logo/TASMOTA_FullLogo_Vector.svg) Alternative firmware for [ESP8266](https://en.wikipedia.org/wiki/ESP8266) based devices with **easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX**. -_Written for Arduino IDE and PlatformIO._ +_Written for PlatformIO with limited support for Arduino IDE._ [![GitHub version](https://img.shields.io/github/release/arendst/Tasmota.svg)](https://github.com/arendst/Tasmota/releases/latest) [![GitHub download](https://img.shields.io/github/downloads/arendst/Tasmota/total.svg)](https://github.com/arendst/Tasmota/releases/latest) [![License](https://img.shields.io/github/license/arendst/Tasmota.svg)](LICENSE.txt) [![Chat](https://img.shields.io/discord/479389167382691863.svg)](https://discord.gg/Ks2Kzd4) -If you like **Tasmota**, give it a star, or fork it and contribute! +If you like **Tasmota**, give it a star, or fork it and contribute! [![GitHub stars](https://img.shields.io/github/stars/arendst/Tasmota.svg?style=social&label=Star)](https://github.com/arendst/Tasmota/stargazers) [![GitHub forks](https://img.shields.io/github/forks/arendst/Tasmota.svg?style=social&label=Fork)](https://github.com/arendst/Tasmota/network) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 12b3a5b24..57d7d68f0 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -52,8 +52,9 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ## Changelog -### Version 8.3.1.6 +### Version 8.3.1.7 +- Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE - Change IRremoteESP8266 library from v2.7.6 to v2.7.8 - Change Adafruit_SGP30 library from v1.0.3 to v1.2.0 (#8519) - Change Energy JSON Total field from ``"Total":[33.736,11.717,16.978]`` to ``"Total":33.736,"TotalTariff":[11.717,16.978]`` diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 854969579..e397e2cc3 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -1,5 +1,9 @@ ## Unreleased (development) +### 8.3.1.7 20200716 + +- Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE + ### 8.3.1.6 20200617 - Add command ``Module2`` to configure fallback module on fast reboot (#8464) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index bf669aed5..1da4e7606 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -16,19 +16,22 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/*==================================================== - Prerequisites: - - Change libraries/PubSubClient/src/PubSubClient.h - #define MQTT_MAX_PACKET_SIZE 1200 - Arduino IDE 1.8.12 and up parameters - - Select IDE Tools - Board: "Generic ESP8266 Module" - - Select IDE Tools - Flash Mode: "DOUT (compatible)" - - Select IDE Tools - Flash Size: "1M (FS:none OTA:~502KB)" - - Select IDE Tools - LwIP Variant: "v2 Higher Bandwidth (no feature)" - - Select IDE Tools - VTables: "Flash" - - Select IDE Tools - Espressif FW: "nonos-sdk-2.2.1+100 (190703)" - ====================================================*/ +/*********************************************************************************************\ + * Preferred IDE is Visual Studio Code with PlatformIO extension which doesn't need prerequisites + * + * Limited support for Arduino IDE needs Prerequisites: + * - Change libraries/PubSubClient/src/PubSubClient.h + * #define MQTT_MAX_PACKET_SIZE 1200 + * + * Arduino IDE 1.8.12 and up parameters for partly support + * - Select IDE Tools - Board: "Generic ESP8266 Module" + * - Select IDE Tools - Flash Mode: "DOUT (compatible)" + * - Select IDE Tools - Flash Size: "1M (FS:none OTA:~502KB)" + * - Select IDE Tools - LwIP Variant: "v2 Higher Bandwidth (no feature)" + * - Select IDE Tools - VTables: "Flash" + * - Select IDE Tools - Espressif FW: "nonos-sdk-2.2.1+100 (190703)" +\*********************************************************************************************/ // Location specific includes #include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index 6b64471b0..23105273e 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,7 +20,7 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x08030106; +const uint32_t VERSION = 0x08030107; // Lowest compatible version const uint32_t VERSION_COMPATIBLE = 0x07010006; From 934ca43463e33799ca023453a7b78757f09f7394 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Jul 2020 11:49:56 +0200 Subject: [PATCH 15/25] Remove Arduino ESP8266 Core support before 2.7.1 Remove Arduino ESP8266 Core support for versions before 2.7.1 --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/WiFiClientSecureLightBearSSL.cpp | 12 -- tasmota/sendemail.h | 4 - tasmota/settings.ino | 14 --- tasmota/support.ino | 8 +- tasmota/support_flash_log.ino | 4 - tasmota/support_float.ino | 4 - tasmota/support_legacy_cores.ino | 141 ----------------------- tasmota/support_tasmota.ino | 8 -- tasmota/support_wifi.ino | 11 -- tasmota/tasmota.ino | 9 +- tasmota/tasmota_configurations.h | 2 - tasmota/tasmota_globals.h | 4 +- tasmota/xdrv_01_webserver.ino | 34 +----- tasmota/xdrv_02_mqtt.ino | 4 - tasmota/xdrv_10_scripter.ino | 26 +---- tasmota/xdrv_26_ariluxrf.ino | 2 - tasmota/xdrv_99_debug.ino | 20 ---- tasmota/xsns_01_counter.ino | 18 +-- tasmota/xsns_35_tx20.ino | 6 +- tasmota/xsns_53_sml.ino | 19 +-- tasmota/xsns_68_windmeter.ino | 6 +- tasmota/xsns_74_lmt01.ino | 8 +- 24 files changed, 24 insertions(+), 342 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 57d7d68f0..ddb4bc8b2 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -54,6 +54,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ### Version 8.3.1.7 +- Remove Arduino ESP8266 Core support for versions before 2.7.1 - Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE - Change IRremoteESP8266 library from v2.7.6 to v2.7.8 - Change Adafruit_SGP30 library from v1.0.3 to v1.2.0 (#8519) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index e397e2cc3..b67609a80 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -2,6 +2,7 @@ ### 8.3.1.7 20200716 +- Remove Arduino ESP8266 Core support for versions before 2.7.1 - Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE ### 8.3.1.6 20200617 diff --git a/tasmota/WiFiClientSecureLightBearSSL.cpp b/tasmota/WiFiClientSecureLightBearSSL.cpp index 0d69ff810..7b92d4b6e 100755 --- a/tasmota/WiFiClientSecureLightBearSSL.cpp +++ b/tasmota/WiFiClientSecureLightBearSSL.cpp @@ -50,9 +50,7 @@ extern "C" { #include "c_types.h" #include -#ifndef ARDUINO_ESP8266_RELEASE_2_5_2 #undef DEBUG_TLS -#endif #ifdef DEBUG_TLS #include "coredecls.h" @@ -255,24 +253,14 @@ void WiFiClientSecure_light::setBufferSizes(int recv, int xmit) { } bool WiFiClientSecure_light::stop(unsigned int maxWaitMs) { -#ifdef ARDUINO_ESP8266_RELEASE_2_4_2 - WiFiClient::stop(); // calls our virtual flush() - _freeSSL(); - return true; -#else bool ret = WiFiClient::stop(maxWaitMs); // calls our virtual flush() _freeSSL(); return ret; -#endif } bool WiFiClientSecure_light::flush(unsigned int maxWaitMs) { (void) _run_until(BR_SSL_SENDAPP); -#ifdef ARDUINO_ESP8266_RELEASE_2_4_2 - WiFiClient::flush(); -#else return WiFiClient::flush(maxWaitMs); -#endif } int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port) { diff --git a/tasmota/sendemail.h b/tasmota/sendemail.h index d95ba9311..7b168b498 100644 --- a/tasmota/sendemail.h +++ b/tasmota/sendemail.h @@ -25,12 +25,8 @@ class SendEmail const bool ssl; const int auth_used; #ifdef ESP8266 -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) - WiFiClient* client; -#else // use bear ssl BearSSL::WiFiClientSecure_light *client; -#endif #else WiFiClient *client; #endif diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 1d7ab6d04..39b1249ad 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -159,14 +159,6 @@ extern "C" { #ifdef ESP8266 -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2) - -extern "C" uint32_t _SPIFFS_end; -// From libraries/EEPROM/EEPROM.cpp EEPROMClass -const uint32_t SPIFFS_END = ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE; - -#else // Core > 2.5.2 and STAGE - #if AUTOFLASHSIZE #include "flash_hal.h" @@ -187,8 +179,6 @@ const uint32_t SPIFFS_END = ((uint32_t)&_FS_end - 0x40200000) / SPI_FLASH_SEC_SI // Version 4.2 config = eeprom area const uint32_t SETTINGS_LOCATION = SPIFFS_END; // No need for SPIFFS as it uses EEPROM area -#endif // ESP8266 - // Version 5.2 allow for more flash space const uint8_t CFG_ROTATES = 8; // Number of flash sectors used (handles uploads) @@ -632,11 +622,7 @@ void EspErase(uint32_t start_sector, uint32_t end_sector) // bool result = EsptoolEraseSector(sector); // Esptool - erases flash completely (slow) if (serial_output) { -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 - Serial.printf(D_LOG_APPLICATION D_ERASED_SECTOR " %d %s\n", sector, (result) ? D_OK : D_ERROR); -#else Serial.printf_P(PSTR(D_LOG_APPLICATION D_ERASED_SECTOR " %d %s\n"), sector, (result) ? D_OK : D_ERROR); -#endif delay(10); } else { yield(); diff --git a/tasmota/support.ino b/tasmota/support.ino index 1d05ae2d1..50cc4f920 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1080,12 +1080,8 @@ int ResponseJsonEndEnd(void) * GPIO Module and Template management \*********************************************************************************************/ -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception -uint32_t Pin(uint32_t gpio, uint32_t index) ICACHE_RAM_ATTR; -#endif - -uint32_t Pin(uint32_t gpio, uint32_t index = 0); -uint32_t Pin(uint32_t gpio, uint32_t index) { +uint32_t ICACHE_RAM_ATTR Pin(uint32_t gpio, uint32_t index = 0); +uint32_t ICACHE_RAM_ATTR Pin(uint32_t gpio, uint32_t index) { #ifdef ESP8266 uint16_t real_gpio = gpio + index; #else // ESP32 diff --git a/tasmota/support_flash_log.ino b/tasmota/support_flash_log.ino index 5f73c4078..5055e5f21 100644 --- a/tasmota/support_flash_log.ino +++ b/tasmota/support_flash_log.ino @@ -112,11 +112,7 @@ DEBUG_SENSOR_LOG(PSTR("FLOG: init ...")); size = ESP.getSketchSize(); // round one sector up start = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2) -end = (uint32_t)&_SPIFFS_start - 0x40200000; -#else // Core > 2.5.2 and STAGE end = (uint32_t)&_FS_start - 0x40200000; -#endif num_sectors = (end - start)/FLASH_SECTOR_SIZE; DEBUG_SENSOR_LOG(PSTR("FLOG: size: 0x%lx, start: 0x%lx, end: 0x%lx, num_sectors(dec): %lu"), size, start, end, num_sectors ); _findFirstErasedSector(); diff --git a/tasmota/support_float.ino b/tasmota/support_float.ino index a72712632..b99b95cd2 100644 --- a/tasmota/support_float.ino +++ b/tasmota/support_float.ino @@ -17,9 +17,6 @@ along with this program. If not, see . */ -//#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 -// Functions not available in 2.3.0 - float fmodf(float x, float y) { // https://github.com/micropython/micropython/blob/master/lib/libm/fmodf.c @@ -83,7 +80,6 @@ float fmodf(float x, float y) ux.i = uxi; return ux.f; } -//#endif // ARDUINO_ESP8266_RELEASE_2_3_0 double FastPrecisePow(double a, double b) { diff --git a/tasmota/support_legacy_cores.ino b/tasmota/support_legacy_cores.ino index 46546ff1d..e9a78e5ee 100644 --- a/tasmota/support_legacy_cores.ino +++ b/tasmota/support_legacy_cores.ino @@ -17,147 +17,6 @@ along with this program. If not, see . */ -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 -/*********************************************************************************************\ - * Functions not available in core 2.3.0 -\*********************************************************************************************/ - -// http://clc-wiki.net/wiki/C_standard_library:string.h:memchr -void* memchr(const void* ptr, int value, size_t num) -{ - unsigned char *p = (unsigned char*)ptr; - while (num--) { - if (*p != (unsigned char)value) { - p++; - } else { - return p; - } - } - return 0; -} - -// http://clc-wiki.net/wiki/C_standard_library:string.h:strcspn -// Get span until any character in string -size_t strcspn(const char *str1, const char *str2) -{ - size_t ret = 0; - while (*str1) { - if (strchr(str2, *str1)) { // Slow - return ret; - } else { - str1++; - ret++; - } - } - return ret; -} - -// https://clc-wiki.net/wiki/C_standard_library:string.h:strpbrk -// Locate the first occurrence in the string pointed to by s1 of any character from the string pointed to by s2 -char* strpbrk(const char *s1, const char *s2) -{ - while(*s1) { - if (strchr(s2, *s1++)) { - return (char*)--s1; - } - } - return 0; -} - -// https://opensource.apple.com/source/Libc/Libc-583/stdlib/FreeBSD/strtoull.c -// Convert a string to an unsigned long long integer -#ifndef __LONG_LONG_MAX__ -#define __LONG_LONG_MAX__ 9223372036854775807LL -#endif -#ifndef ULLONG_MAX -#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1) -#endif - -unsigned long long strtoull(const char *__restrict nptr, char **__restrict endptr, int base) -{ - const char *s = nptr; - char c; - do { c = *s++; } while (isspace((unsigned char)c)); // Trim leading spaces - - int neg = 0; - if (c == '-') { // Set minus flag and/or skip sign - neg = 1; - c = *s++; - } else { - if (c == '+') { - c = *s++; - } - } - - if ((base == 0 || base == 16) && (c == '0') && (*s == 'x' || *s == 'X')) { // Set Hexadecimal - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) { base = (c == '0') ? 8 : 10; } // Set Octal or Decimal - - unsigned long long acc = 0; - int any = 0; - if (base > 1 && base < 37) { - unsigned long long cutoff = ULLONG_MAX / base; - int cutlim = ULLONG_MAX % base; - for ( ; ; c = *s++) { - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else - break; - - if (c >= base) - break; - - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = ULLONG_MAX; // Range error - } - else if (any && neg) { - acc = -acc; - } - } - - if (endptr != nullptr) { *endptr = (char *)(any ? s - 1 : nptr); } - - return acc; -} - -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 - - - -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2) -/*********************************************************************************************\ - * Functions not available in core before 2.6.0 -\*********************************************************************************************/ - -// https://github.com/arendst/Tasmota/issues/6856#issuecomment-554258914 -void* memmove_P(void *dest, const void *src, size_t n) -{ - if (src > (void*)0x40000000) { - return memcpy_P(dest, src, n); - } else { - return memmove(dest, src, n); - } -} - -#endif // ARDUINO_ESP8266_RELEASE < 2_6_0 - - - /*********************************************************************************************\ * Core overrides \*********************************************************************************************/ diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 70d7f66af..0fbcbb615 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -852,11 +852,8 @@ void PerformEverySecond(void) } } -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Wifi keep alive to send Gratuitous ARP wifiKeepAlive(); -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 - #ifdef ESP32 if (11 == uptime) { // Perform one-time ESP32 houskeeping @@ -1027,13 +1024,8 @@ void Every250mSeconds(void) } #endif // FIRMWARE_MINIMAL AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), mqtt_data); -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) - ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(mqtt_data)); -#else - // If using core stage or 2.5.0+ the syntax has changed WiFiClient OTAclient; ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, mqtt_data)); -#endif if (!ota_result) { #ifndef FIRMWARE_MINIMAL int ota_error = ESPhttpUpdate.getLastError(); diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index 75de2523f..3274cfc4b 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -153,14 +153,11 @@ void WiFiSetSleepMode(void) */ // Sleep explanation: https://github.com/esp8266/Arduino/blob/3f0c601cfe81439ce17e9bd5d28994a7ed144482/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp#L255 -#if defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) -#else // Enabled in 2.3.0, 2.4.0 and stage if (ssleep && Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times } else { WiFi.setSleepMode(WIFI_MODEM_SLEEP); // Disable sleep (Esp8288/Arduino core and sdk default) } -#endif WifiSetOutputPower(); } @@ -172,12 +169,6 @@ void WifiBegin(uint8_t flag, uint8_t channel) UdpDisconnect(); #endif // USE_EMULATION -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 // (!strncmp_P(ESP.getSdkVersion(),PSTR("1.5.3"),5)) - AddLog_P(LOG_LEVEL_DEBUG, S_LOG_WIFI, PSTR(D_PATCH_ISSUE_2186)); -// WiFi.mode(WIFI_OFF); // See https://github.com/esp8266/Arduino/issues/2186 - WifiSetMode(WIFI_OFF); -#endif - WiFi.persistent(false); // Solve possible wifi init errors (re-add at 6.2.1.16 #4044, #4083) WiFi.disconnect(true); // Delete SDK wifi config delay(200); @@ -652,7 +643,6 @@ void EspRestart(void) ESP_Restart(); } -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // // Gratuitous ARP, backported from https://github.com/esp8266/Arduino/pull/6889 // @@ -700,4 +690,3 @@ void wifiKeepAlive(void) { SetNextTimeInterval(wifiTimer, wifiTimerSec * 1000); } } -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 1da4e7606..43e019e33 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -34,7 +34,7 @@ \*********************************************************************************************/ // Location specific includes -#include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) +#include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_7_1) #include "tasmota_compat.h" #include "tasmota_version.h" // Tasmota version information #include "tasmota.h" // Enumeration used in my_user_config.h @@ -46,13 +46,6 @@ #include "i18n.h" // Language support configured by my_user_config.h #include "tasmota_template.h" // Hardware configuration -#ifdef ARDUINO_ESP8266_RELEASE_2_4_0 -#include "lwip/init.h" -#if LWIP_VERSION_MAJOR != 1 - #error Please use stable lwIP v1.4 -#endif -#endif - // Libraries #include // Ota #include // Ota diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 58d08d543..ad9d64d08 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -280,13 +280,11 @@ #define USE_SPI // Hardware SPI using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK) in addition to two user selectable GPIOs(CS and DC) #define USE_DISPLAY_ILI9341 // [DisplayModel 4] Enable ILI9341 Tft 480x320 display (+19k code) -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // There is not enough spare RAM with core 2.3.0 to support the following #define USE_DISPLAY_EPAPER_29 // [DisplayModel 5] Enable e-paper 2.9 inch display (+19k code) #define USE_DISPLAY_EPAPER_42 // [DisplayModel 6] Enable e-paper 4.2 inch display // #define USE_DISPLAY_ILI9488 // [DisplayModel 8] // #define USE_DISPLAY_SSD1351 // [DisplayModel 9] // #define USE_DISPLAY_RA8876 // [DisplayModel 10] -#endif #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index 42e63f206..e4312d0b3 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -128,8 +128,8 @@ String EthernetMacAddress(void); const uint16_t WEB_LOG_SIZE = 4000; // Max number of characters in weblog #endif -#if defined(USE_TLS) && defined(ARDUINO_ESP8266_RELEASE_2_3_0) - #error "TLS is no more supported on Core 2.3.0, use 2.4.2 or higher." +#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2) + #error "Arduino ESP8266 Core versions before 2.7.1 are not supported" #endif #ifndef MQTT_MAX_PACKET_SIZE diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 8ba98f91e..e42b17db4 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -913,14 +913,8 @@ void WifiManagerBegin(bool reset_only) int channel = WIFI_SOFT_AP_CHANNEL; if ((channel < 1) || (channel > 13)) { channel = 1; } -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 - // bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0); - WiFi.softAP(my_hostname, WIFI_AP_PASSPHRASE, channel, 0); -#else // bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4); WiFi.softAP(my_hostname, WIFI_AP_PASSPHRASE, channel, 0, 1); -#endif - delay(500); // Without delay I've seen the IP address blank /* Setup the DNS server redirecting all the domains to the apIP */ DnsServer->setErrorReplyCode(DNSReplyCode::NoError); @@ -992,10 +986,6 @@ void WSContentBegin(int code, int ctype) { Webserver->client().flush(); WSHeaderSend(); -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 - Webserver->sendHeader(F("Accept-Ranges"),F("none")); - Webserver->sendHeader(F("Transfer-Encoding"),F("chunked")); -#endif Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN); WSSend(code, ctype, ""); // Signal start of chunked content Web.chunk_buffer = ""; @@ -1004,15 +994,7 @@ void WSContentBegin(int code, int ctype) void _WSContentSend(const String& content) // Low level sendContent for all core versions { size_t len = content.length(); - -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 - const char * footer = "\r\n"; - char chunk_size[11]; - sprintf(chunk_size, "%x\r\n", len); - Webserver->sendContent(String() + chunk_size + content + footer); -#else Webserver->sendContent(content); -#endif #ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("WSContentSend")); @@ -1377,7 +1359,7 @@ void HandleRoot(void) "c", // c - Unique HTML id "#000", "#fff", // Black to White 4, // sl4 - Unique range HTML id - Used as source for Saturation begin color - Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% + Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% (SetOption77 - Do not power off if slider moved to far left) Settings.light_dimmer, 'd', 0); // d0 - Value id is related to lc("d0", value) and WebGetArg("d0", tmp, sizeof(tmp)); @@ -1389,7 +1371,7 @@ void HandleRoot(void) "f", // f - Unique HTML id "#000", "#fff", // Black to White 5, // sl5 - Unique range HTML id - Not used - Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% + Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% (SetOption77 - Do not power off if slider moved to far left) LightGetDimmer(2), 'w', 0); // w0 - Value id is related to lc("w0", value) and WebGetArg("w0", tmp, sizeof(tmp)); } @@ -2367,14 +2349,7 @@ void HandleBackupConfiguration(void) } } -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 - size_t written = myClient.write((const char*)settings_buffer, sizeof(Settings)); - if (written < sizeof(Settings)) { // https://github.com/esp8266/Arduino/issues/3218 - myClient.write((const char*)settings_buffer +written, sizeof(Settings) -written); - } -#else myClient.write((const char*)settings_buffer, sizeof(Settings)); -#endif SettingsBufferFree(); @@ -3152,14 +3127,9 @@ int WebSend(char *buffer) DEBUG_CORE_LOG(PSTR("WEB: Uri |%s|"), url.c_str()); -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) - HTTPClient http; - if (http.begin(UrlEncode(url))) { // UrlEncode(url) = |http://192.168.178.86/cm?cmnd=POWER1%20ON| -#else WiFiClient http_client; HTTPClient http; if (http.begin(http_client, UrlEncode(url))) { // UrlEncode(url) = |http://192.168.178.86/cm?cmnd=POWER1%20ON| -#endif int http_code = http.GET(); // Start connection and send HTTP header if (http_code > 0) { // http_code will be negative on error if (http_code == HTTP_CODE_OK || http_code == HTTP_CODE_MOVED_PERMANENTLY) { diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index a24d51de3..1f232cff8 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -1217,11 +1217,7 @@ void CmndTlsDump(void) { uint32_t end = start + tls_block_len -1; for (uint32_t pos = start; pos < end; pos += 0x10) { uint32_t* values = (uint32_t*)(pos); -#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 - Serial.printf("%08x: %08x %08x %08x %08x\n", pos, bswap32(values[0]), bswap32(values[1]), bswap32(values[2]), bswap32(values[3])); -#else Serial.printf_P(PSTR("%08x: %08x %08x %08x %08x\n"), pos, bswap32(values[0]), bswap32(values[1]), bswap32(values[2]), bswap32(values[3])); -#endif } } #endif // DEBUG_DUMP_TLS diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index b885feadf..922e75ebc 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -1164,11 +1164,9 @@ uint32_t pulse_ltime_hl; uint32_t pulse_ltime_lh; uint8_t pt_pin; -void MP_Timer(void) ICACHE_RAM_ATTR; - #define MPT_DEBOUNCE 10 -void MP_Timer(void) { +void ICACHE_RAM_ATTR MP_Timer(void) { uint32_t level = digitalRead(pt_pin&0x3f); uint32_t ms = millis(); uint32_t time; @@ -2899,19 +2897,6 @@ char *getop(char *lp, uint8_t *operand) { #ifdef ESP8266 -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) -// All version before core 2.4.2 -// https://github.com/esp8266/Arduino/issues/2557 -extern "C" { -#include - extern cont_t g_cont; -} -uint16_t GetStack(void) { - register uint32_t *sp asm("a1"); - return (4 * (sp - g_cont.stack)); -} - -#else extern "C" { #include extern cont_t* g_pcont; @@ -2920,7 +2905,6 @@ uint16_t GetStack(void) { register uint32_t *sp asm("a1"); return (4 * (sp - g_pcont->stack)); } -#endif #else uint16_t GetStack(void) { register uint8_t *sp asm("a1"); @@ -4349,18 +4333,10 @@ uint8_t reject(char *name) { if (*name=='_') return 1; if (*name=='.') return 1; -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 if (!strncasecmp(name,"SPOTLI~1",REJCMPL)) return 1; if (!strncasecmp(name,"TRASHE~1",REJCMPL)) return 1; if (!strncasecmp(name,"FSEVEN~1",REJCMPL)) return 1; if (!strncasecmp(name,"SYSTEM~1",REJCMPL)) return 1; -#else - if (!strcasecmp(name,"SPOTLI~1")) return 1; - if (!strcasecmp(name,"TRASHE~1")) return 1; - if (!strcasecmp(name,"FSEVEN~1")) return 1; - if (!strcasecmp(name,"SYSTEM~1")) return 1; -#endif - if (!strncasecmp(name,"System Volume",13)) return 1; return 0; } diff --git a/tasmota/xdrv_26_ariluxrf.ino b/tasmota/xdrv_26_ariluxrf.ino index 5027dfdcb..b0f20e8a6 100644 --- a/tasmota/xdrv_26_ariluxrf.ino +++ b/tasmota/xdrv_26_ariluxrf.ino @@ -45,11 +45,9 @@ struct ARILUX { uint8_t rf_toggle = 0; } Arilux; -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception #ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves RF misses void AriluxRfInterrupt(void) ICACHE_RAM_ATTR; // As iram is tight and it works this way too #endif // USE_WS2812_DMA -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 void AriluxRfInterrupt(void) { diff --git a/tasmota/xdrv_99_debug.ino b/tasmota/xdrv_99_debug.ino index 08f451c30..7471d3095 100644 --- a/tasmota/xdrv_99_debug.ino +++ b/tasmota/xdrv_99_debug.ino @@ -189,24 +189,6 @@ void CpuLoadLoop(void) /*******************************************************************************************/ #ifdef ESP8266 -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) -// All version before core 2.4.2 -// https://github.com/esp8266/Arduino/issues/2557 - -extern "C" { -#include - extern cont_t g_cont; -} - -void DebugFreeMem(void) -{ - register uint32_t *sp asm("a1"); - -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d, UnmodifiedStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_cont.stack), cont_get_free_stack(&g_cont), XdrvMailbox.data); - AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_cont.stack), XdrvMailbox.data); -} - -#else // All version from core 2.4.2 // https://github.com/esp8266/Arduino/pull/5018 // https://github.com/esp8266/Arduino/pull/4553 @@ -223,8 +205,6 @@ void DebugFreeMem(void) AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data); } -#endif // ARDUINO_ESP8266_RELEASE_2_x_x - #else // ESP32 void DebugFreeMem(void) diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index ae03ef324..48452752f 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -47,15 +47,7 @@ struct COUNTER { uint32_t last_cycle; uint32_t cycle_time; -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception -void CounterUpdate(uint8_t index) ICACHE_RAM_ATTR; -void CounterUpdate1(void) ICACHE_RAM_ATTR; -void CounterUpdate2(void) ICACHE_RAM_ATTR; -void CounterUpdate3(void) ICACHE_RAM_ATTR; -void CounterUpdate4(void) ICACHE_RAM_ATTR; -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 - -void CounterUpdate(uint8_t index) +void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) { uint32_t time = micros(); uint32_t debounce_time; @@ -125,22 +117,22 @@ void CounterUpdate(uint8_t index) } } -void CounterUpdate1(void) +void ICACHE_RAM_ATTR CounterUpdate1(void) { CounterUpdate(0); } -void CounterUpdate2(void) +void ICACHE_RAM_ATTR CounterUpdate2(void) { CounterUpdate(1); } -void CounterUpdate3(void) +void ICACHE_RAM_ATTR CounterUpdate3(void) { CounterUpdate(2); } -void CounterUpdate4(void) +void ICACHE_RAM_ATTR CounterUpdate4(void) { CounterUpdate(3); } diff --git a/tasmota/xsns_35_tx20.ino b/tasmota/xsns_35_tx20.ino index cf41a41fb..3ab33e402 100644 --- a/tasmota/xsns_35_tx20.ino +++ b/tasmota/xsns_35_tx20.ino @@ -150,11 +150,7 @@ uint32_t tx2x_last_available = 0; uint32_t tx23_stage = 0; #endif // USE_TX23_WIND_SENSOR -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception -void TX2xStartRead(void) ICACHE_RAM_ATTR; // As iram is tight and it works this way too -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 - -void TX2xStartRead(void) +void ICACHE_RAM_ATTR TX2xStartRead(void) { /** * La Crosse TX20 Anemometer datagram every 2 seconds diff --git a/tasmota/xsns_53_sml.ino b/tasmota/xsns_53_sml.ino index a75a8fbd8..66981d2ba 100755 --- a/tasmota/xsns_53_sml.ino +++ b/tasmota/xsns_53_sml.ino @@ -1811,16 +1811,7 @@ struct SML_COUNTER { #endif } sml_counters[MAX_COUNTERS]; - -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception -void SML_CounterUpd(uint8_t index) ICACHE_RAM_ATTR; -void SML_CounterUpd1(void) ICACHE_RAM_ATTR; -void SML_CounterUpd2(void) ICACHE_RAM_ATTR; -void SML_CounterUpd3(void) ICACHE_RAM_ATTR; -void SML_CounterUpd4(void) ICACHE_RAM_ATTR; -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 - -void SML_CounterUpd(uint8_t index) { +void ICACHE_RAM_ATTR SML_CounterUpd(uint8_t index) { uint8_t level=digitalRead(meter_desc_p[sml_counters[index].sml_cnt_old_state].srcpin); if (!level) { @@ -1838,19 +1829,19 @@ void SML_CounterUpd(uint8_t index) { } } -void SML_CounterUpd1(void) { +void ICACHE_RAM_ATTR SML_CounterUpd1(void) { SML_CounterUpd(0); } -void SML_CounterUpd2(void) { +void ICACHE_RAM_ATTR SML_CounterUpd2(void) { SML_CounterUpd(1); } -void SML_CounterUpd3(void) { +void ICACHE_RAM_ATTR SML_CounterUpd3(void) { SML_CounterUpd(2); } -void SML_CounterUpd4(void) { +void ICACHE_RAM_ATTR SML_CounterUpd4(void) { SML_CounterUpd(3); } diff --git a/tasmota/xsns_68_windmeter.ino b/tasmota/xsns_68_windmeter.ino index 5487c898c..677cfc8b3 100644 --- a/tasmota/xsns_68_windmeter.ino +++ b/tasmota/xsns_68_windmeter.ino @@ -72,11 +72,7 @@ struct WINDMETER { #endif // USE_WINDMETER_NOSTATISTICS } WindMeter; -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception -void WindMeterUpdateSpeed(void) ICACHE_RAM_ATTR; -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 - -void WindMeterUpdateSpeed(void) +void ICACHE_RAM_ATTR WindMeterUpdateSpeed(void) { uint32_t time = micros(); uint32_t time_diff = time - WindMeter.counter_time; diff --git a/tasmota/xsns_74_lmt01.ino b/tasmota/xsns_74_lmt01.ino index d52e6dae2..522b82281 100644 --- a/tasmota/xsns_74_lmt01.ino +++ b/tasmota/xsns_74_lmt01.ino @@ -40,13 +40,9 @@ void LMT01_Init(void) { } } -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception -void LMT01_countPulse(void) ICACHE_RAM_ATTR; -#endif // ARDUINO_ESP8266_RELEASE_2_3_0 - volatile int lmt01_pulseCount = 0; -void LMT01_countPulse(void) { +void ICACHE_RAM_ATTR LMT01_countPulse(void) { lmt01_pulseCount++; } @@ -81,7 +77,7 @@ int LMT01_getPulses(void) { hold = lmt01_pulseCount; delay(1); } - // discard spurious low counts + // discard spurious low counts if (timeout > 0 && hold >= 10) { return hold; } From a9b05b08842d31b343b5da2239fb583712748d7a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Jul 2020 12:37:21 +0200 Subject: [PATCH 16/25] Change to attachInterruptArg() Change to attachInterruptArg() saving 76 bytes --- tasmota/xsns_01_counter.ino | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 48452752f..dde9a420e 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -36,6 +36,8 @@ const char kCounterCommands[] PROGMEM = D_PRFX_COUNTER "|" // Prefix void (* const CounterCommand[])(void) PROGMEM = { &CmndCounter, &CmndCounterType, &CmndCounterDebounce, &CmndCounterDebounceLow, &CmndCounterDebounceHigh }; +uint8_t ctr_index[MAX_COUNTERS] = { 0, 1, 2, 3 }; + struct COUNTER { uint32_t timer[MAX_COUNTERS]; // Last counter time in micro seconds uint32_t timer_low_high[MAX_COUNTERS]; // Last low/high counter time in micro seconds @@ -47,8 +49,10 @@ struct COUNTER { uint32_t last_cycle; uint32_t cycle_time; -void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) -{ +//void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) { +void ICACHE_RAM_ATTR CounterIsrArg(void *arg) { + uint32_t index = *static_cast(arg); + uint32_t time = micros(); uint32_t debounce_time; @@ -116,7 +120,7 @@ void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) } } } - +/* void ICACHE_RAM_ATTR CounterUpdate1(void) { CounterUpdate(0); @@ -136,7 +140,7 @@ void ICACHE_RAM_ATTR CounterUpdate4(void) { CounterUpdate(3); } - +*/ /********************************************************************************************/ bool CounterPinState(void) @@ -151,8 +155,8 @@ bool CounterPinState(void) void CounterInit(void) { - typedef void (*function) () ; - function counter_callbacks[] = { CounterUpdate1, CounterUpdate2, CounterUpdate3, CounterUpdate4 }; +// typedef void (*function) () ; +// function counter_callbacks[] = { CounterUpdate1, CounterUpdate2, CounterUpdate3, CounterUpdate4 }; for (uint32_t i = 0; i < MAX_COUNTERS; i++) { if (PinUsed(GPIO_CNTR1, i)) { @@ -160,10 +164,12 @@ void CounterInit(void) pinMode(Pin(GPIO_CNTR1, i), bitRead(Counter.no_pullup, i) ? INPUT : INPUT_PULLUP); if ((0 == Settings.pulse_counter_debounce_low) && (0 == Settings.pulse_counter_debounce_high) && !Settings.flag4.zerocross_dimmer) { Counter.pin_state = 0; - attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], FALLING); +// attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], FALLING); + attachInterruptArg(Pin(GPIO_CNTR1, i), CounterIsrArg, &ctr_index[i], FALLING); } else { Counter.pin_state = 0x8f; - attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], CHANGE); +// attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], CHANGE); + attachInterruptArg(Pin(GPIO_CNTR1, i), CounterIsrArg, &ctr_index[i], CHANGE); } } } From 25dcf447f3fc6f71cf2e409af88fe08867a168dc Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Jul 2020 12:49:42 +0200 Subject: [PATCH 17/25] First try to fix counter interrupt storm First try to fix counter interrupt storm during OTA (#8928) --- tasmota/xdrv_01_webserver.ino | 6 ++++++ tasmota/xsns_01_counter.ino | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index e42b17db4..7f510271c 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2598,6 +2598,9 @@ void HandleUploadDone(void) WifiConfigCounter(); restart_flag = 0; MqttRetryCounter(0); +#ifdef USE_COUNTER + CounterInterruptDisable(false); +#endif WSContentStart_P(S_INFORMATION); if (!Web.upload_error) { @@ -2673,6 +2676,9 @@ void HandleUploadLoop(void) } } else { MqttRetryCounter(60); +#ifdef USE_COUNTER + CounterInterruptDisable(true); +#endif #ifdef USE_EMULATION UdpDisconnect(); #endif // USE_EMULATION diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index dde9a420e..0337e17e5 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -44,6 +44,7 @@ struct COUNTER { uint8_t no_pullup = 0; // Counter input pullup flag (1 = No pullup) uint8_t pin_state = 0; // LSB0..3 Last state of counter pin; LSB7==0 IRQ is FALLING, LSB7==1 IRQ is CHANGE bool any_counter = false; + bool disable = false; } Counter; uint32_t last_cycle; @@ -51,6 +52,8 @@ uint32_t cycle_time; //void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) { void ICACHE_RAM_ATTR CounterIsrArg(void *arg) { + if (Counter.disable) { return; } + uint32_t index = *static_cast(arg); uint32_t time = micros(); @@ -143,6 +146,10 @@ void ICACHE_RAM_ATTR CounterUpdate4(void) */ /********************************************************************************************/ +void CounterInterruptDisable(bool state) { + Counter.disable = state; +} + bool CounterPinState(void) { if ((XdrvMailbox.index >= AGPIO(GPIO_CNTR1_NP)) && (XdrvMailbox.index < (AGPIO(GPIO_CNTR1_NP) + MAX_COUNTERS))) { From 8dbe3c90da3da17ab9e49f8e71f11653a24c0f80 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Jul 2020 16:18:07 +0200 Subject: [PATCH 18/25] Second try to fix counter interrupt storm Second try to fix counter interrupt storm during OTA (#8928) --- tasmota/xdrv_01_webserver.ino | 3 +++ tasmota/xsns_01_counter.ino | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 7f510271c..112b9ac7f 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2874,6 +2874,9 @@ void HandleUploadLoop(void) } else if (UPLOAD_FILE_ABORTED == upload.status) { restart_flag = 0; MqttRetryCounter(0); +#ifdef USE_COUNTER + CounterInterruptDisable(false); +#endif Web.upload_error = 7; // Upload aborted if (UPL_TASMOTA == Web.upload_file_type) { Update.end(); } } diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 0337e17e5..73c19322e 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -44,7 +44,6 @@ struct COUNTER { uint8_t no_pullup = 0; // Counter input pullup flag (1 = No pullup) uint8_t pin_state = 0; // LSB0..3 Last state of counter pin; LSB7==0 IRQ is FALLING, LSB7==1 IRQ is CHANGE bool any_counter = false; - bool disable = false; } Counter; uint32_t last_cycle; @@ -52,8 +51,6 @@ uint32_t cycle_time; //void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) { void ICACHE_RAM_ATTR CounterIsrArg(void *arg) { - if (Counter.disable) { return; } - uint32_t index = *static_cast(arg); uint32_t time = micros(); @@ -147,7 +144,20 @@ void ICACHE_RAM_ATTR CounterUpdate4(void) /********************************************************************************************/ void CounterInterruptDisable(bool state) { - Counter.disable = state; + if (state) { // Disable interrupts + if (Counter.any_counter) { + for (uint32_t i = 0; i < MAX_COUNTERS; i++) { + if (PinUsed(GPIO_CNTR1, i)) { + detachInterrupt(Pin(GPIO_CNTR1, i)); + } + } + Counter.any_counter = false; + } + } else { // Enable interrupts + if (!Counter.any_counter) { + CounterInit(); + } + } } bool CounterPinState(void) From 7d0d9b7782a9ce1c5b2e4b34666754ca3ad6aa43 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Jul 2020 18:00:17 +0200 Subject: [PATCH 19/25] Remove Arduino ESP8266 Core support before 2.7.1 --- .../README.md | 0 .../examples/swsertest/swsertest.ino | 0 .../keywords.txt | 0 .../library.json | 2 +- .../library.properties | 2 +- .../src/TasmotaSerial.cpp | 89 ++----------------- .../src/TasmotaSerial.h | 5 -- 7 files changed, 10 insertions(+), 88 deletions(-) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/README.md (100%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/examples/swsertest/swsertest.ino (100%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/keywords.txt (100%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/library.json (94%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/library.properties (94%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/src/TasmotaSerial.cpp (79%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/src/TasmotaSerial.h (91%) diff --git a/lib/TasmotaSerial-3.0.0/README.md b/lib/TasmotaSerial-3.1.0/README.md similarity index 100% rename from lib/TasmotaSerial-3.0.0/README.md rename to lib/TasmotaSerial-3.1.0/README.md diff --git a/lib/TasmotaSerial-3.0.0/examples/swsertest/swsertest.ino b/lib/TasmotaSerial-3.1.0/examples/swsertest/swsertest.ino similarity index 100% rename from lib/TasmotaSerial-3.0.0/examples/swsertest/swsertest.ino rename to lib/TasmotaSerial-3.1.0/examples/swsertest/swsertest.ino diff --git a/lib/TasmotaSerial-3.0.0/keywords.txt b/lib/TasmotaSerial-3.1.0/keywords.txt similarity index 100% rename from lib/TasmotaSerial-3.0.0/keywords.txt rename to lib/TasmotaSerial-3.1.0/keywords.txt diff --git a/lib/TasmotaSerial-3.0.0/library.json b/lib/TasmotaSerial-3.1.0/library.json similarity index 94% rename from lib/TasmotaSerial-3.0.0/library.json rename to lib/TasmotaSerial-3.1.0/library.json index 19197cce4..17764a8f2 100644 --- a/lib/TasmotaSerial-3.0.0/library.json +++ b/lib/TasmotaSerial-3.1.0/library.json @@ -1,6 +1,6 @@ { "name": "TasmotaSerial", - "version": "3.0.0", + "version": "3.1.0", "keywords": [ "serial", "io", "TasmotaSerial" ], diff --git a/lib/TasmotaSerial-3.0.0/library.properties b/lib/TasmotaSerial-3.1.0/library.properties similarity index 94% rename from lib/TasmotaSerial-3.0.0/library.properties rename to lib/TasmotaSerial-3.1.0/library.properties index d1d9e718a..8229443e9 100644 --- a/lib/TasmotaSerial-3.0.0/library.properties +++ b/lib/TasmotaSerial-3.1.0/library.properties @@ -1,5 +1,5 @@ name=TasmotaSerial -version=3.0.0 +version=3.1.0 author=Theo Arends maintainer=Theo Arends sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32. diff --git a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.cpp b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp similarity index 79% rename from lib/TasmotaSerial-3.0.0/src/TasmotaSerial.cpp rename to lib/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp index 6982779d5..0ceed70f5 100644 --- a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.cpp +++ b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp @@ -29,66 +29,19 @@ extern "C" { #ifdef ESP8266 -// for STAGE and pre-2.6, we can have a single wrapper using attachInterruptArg() void ICACHE_RAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); }; // As the Arduino attachInterrupt has no parameter, lists of objects // and callbacks corresponding to each possible GPIO pins have to be defined TasmotaSerial *tms_obj_list[16]; -#ifdef TM_SERIAL_USE_IRAM -void ICACHE_RAM_ATTR tms_isr_0() { tms_obj_list[0]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_1() { tms_obj_list[1]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_2() { tms_obj_list[2]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_3() { tms_obj_list[3]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_4() { tms_obj_list[4]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_5() { tms_obj_list[5]->rxRead(); }; -// Pin 6 to 11 can not be used -void ICACHE_RAM_ATTR tms_isr_12() { tms_obj_list[12]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_13() { tms_obj_list[13]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_14() { tms_obj_list[14]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_15() { tms_obj_list[15]->rxRead(); }; -#else -void tms_isr_0() { tms_obj_list[0]->rxRead(); }; -void tms_isr_1() { tms_obj_list[1]->rxRead(); }; -void tms_isr_2() { tms_obj_list[2]->rxRead(); }; -void tms_isr_3() { tms_obj_list[3]->rxRead(); }; -void tms_isr_4() { tms_obj_list[4]->rxRead(); }; -void tms_isr_5() { tms_obj_list[5]->rxRead(); }; -// Pin 6 to 11 can not be used -void tms_isr_12() { tms_obj_list[12]->rxRead(); }; -void tms_isr_13() { tms_obj_list[13]->rxRead(); }; -void tms_isr_14() { tms_obj_list[14]->rxRead(); }; -void tms_isr_15() { tms_obj_list[15]->rxRead(); }; -#endif // TM_SERIAL_USE_IRAM - -static void (*ISRList[16])() = { - tms_isr_0, - tms_isr_1, - tms_isr_2, - tms_isr_3, - tms_isr_4, - tms_isr_5, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - tms_isr_12, - tms_isr_13, - tms_isr_14, - tms_isr_15 -}; - #else // ESP32 - static int tasmota_serial_index = 2; // Allow UART2 and UART1 only +static int tasmota_serial_index = 2; // Allow UART2 and UART1 only #endif // ESP8266 -TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) -{ +TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) { m_valid = false; m_hardserial = false; m_hardswap = false; @@ -118,11 +71,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_bit_start_time = m_bit_time + m_bit_time/3 - 500; // pre-compute first wait pinMode(m_rx_pin, INPUT); tms_obj_list[m_rx_pin] = this; -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_2) - attachInterrupt(m_rx_pin, ISRList[m_rx_pin], (m_nwmode) ? CHANGE : FALLING); -#else attachInterruptArg(m_rx_pin, callRxRead, this, (m_nwmode) ? CHANGE : FALLING); -#endif } if (m_tx_pin > -1) { pinMode(m_tx_pin, OUTPUT); @@ -136,8 +85,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_valid = true; } -TasmotaSerial::~TasmotaSerial() -{ +TasmotaSerial::~TasmotaSerial() { #ifdef ESP8266 if (!m_hardserial) { if (m_rx_pin > -1) { @@ -151,8 +99,7 @@ TasmotaSerial::~TasmotaSerial() #endif // ESP8266 } -bool TasmotaSerial::isValidGPIOpin(int pin) -{ +bool TasmotaSerial::isValidGPIOpin(int pin) { return (pin >= -1 && pin <= 5) || (pin >= 12 && pin <= 15); } @@ -234,8 +181,7 @@ int TasmotaSerial::peek() { } } -int TasmotaSerial::read() -{ +int TasmotaSerial::read() { if (m_hardserial) { #ifdef ESP8266 return Serial.read(); @@ -250,8 +196,7 @@ int TasmotaSerial::read() } } -int TasmotaSerial::available() -{ +int TasmotaSerial::available() { if (m_hardserial) { #ifdef ESP8266 return Serial.available(); @@ -265,23 +210,12 @@ int TasmotaSerial::available() } } -#ifdef TM_SERIAL_USE_IRAM #define TM_SERIAL_WAIT_SND { while (ESP.getCycleCount() < (wait + start)) if (!m_high_speed) optimistic_yield(1); wait += m_bit_time; } // Watchdog timeouts #define TM_SERIAL_WAIT_SND_FAST { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } #define TM_SERIAL_WAIT_RCV { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } #define TM_SERIAL_WAIT_RCV_LOOP { while (ESP.getCycleCount() < (wait + start)); } -#else -#define TM_SERIAL_WAIT_SND { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } -#define TM_SERIAL_WAIT_SND_FAST { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } -#define TM_SERIAL_WAIT_RCV { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } -#define TM_SERIAL_WAIT_RCV_LOOP { while (ESP.getCycleCount() < (wait + start)); } -#endif -#ifdef TM_SERIAL_USE_IRAM void ICACHE_RAM_ATTR TasmotaSerial::_fast_write(uint8_t b) { -#else -void TasmotaSerial::_fast_write(uint8_t b) { -#endif uint32_t wait = m_bit_time; uint32_t start = ESP.getCycleCount(); // Start bit; @@ -299,8 +233,7 @@ void TasmotaSerial::_fast_write(uint8_t b) { } } -size_t TasmotaSerial::write(uint8_t b) -{ +size_t TasmotaSerial::write(uint8_t b) { if (m_hardserial) { #ifdef ESP8266 return Serial.write(b); @@ -337,13 +270,7 @@ size_t TasmotaSerial::write(uint8_t b) } } -#ifdef TM_SERIAL_USE_IRAM -void ICACHE_RAM_ATTR TasmotaSerial::rxRead() -{ -#else -void TasmotaSerial::rxRead() -{ -#endif +void ICACHE_RAM_ATTR TasmotaSerial::rxRead() { if (!m_nwmode) { int32_t loop_read = m_very_high_speed ? serial_buffer_size : 1; // Advance the starting point for the samples but compensate for the diff --git a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.h b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.h similarity index 91% rename from lib/TasmotaSerial-3.0.0/src/TasmotaSerial.h rename to lib/TasmotaSerial-3.1.0/src/TasmotaSerial.h index 42a3f120e..bc5161d65 100644 --- a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.h +++ b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.h @@ -28,11 +28,6 @@ #define TM_SERIAL_BAUDRATE 9600 // Default baudrate #define TM_SERIAL_BUFFER_SIZE 64 // Receive buffer size -#include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 - #define TM_SERIAL_USE_IRAM // Enable to use iram (+368 bytes) -#endif - #include #include From d2198ad8b6482381c7431d7efa21412168329bb8 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Jul 2020 18:40:06 +0200 Subject: [PATCH 20/25] Fix esp32 compile error --- tasmota/settings.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 39b1249ad..2e8852ae5 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -174,11 +174,11 @@ const uint32_t SPIFFS_END = ((uint32_t)&_FS_end - 0x40200000) / SPI_FLASH_SEC_SI #endif // AUTOFLASHSIZE -#endif // All cores < pre-2.6.0 - // Version 4.2 config = eeprom area const uint32_t SETTINGS_LOCATION = SPIFFS_END; // No need for SPIFFS as it uses EEPROM area +#endif // ESP8266 + // Version 5.2 allow for more flash space const uint8_t CFG_ROTATES = 8; // Number of flash sectors used (handles uploads) From 2c6198f27ca196614d9d80ec6798ef4379dc72c5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 18 Jul 2020 18:51:13 +0200 Subject: [PATCH 21/25] Fix spelling Fix spelling (#3410) --- tasmota/i18n.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index eeedbfc57..70ca42a7e 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -616,7 +616,7 @@ // xsns_70_veml6075.ino #define D_JSON_UVA_INTENSITY "UvaIntensity" -#define D_JSON_UVB_INTENSITY "UvbItensity" +#define D_JSON_UVB_INTENSITY "UvbIntensity" #define D_CMND_VEML6075_POWER "power" #define D_CMND_VEML6075_DYNAMIC "dynamic" #define D_CMND_VEML6075_INTTIME "inttime" From a7e057b8ba765364b0bc72b4c474588150090fd8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Jul 2020 13:21:45 +0200 Subject: [PATCH 22/25] Use Tasmota Stage Core 2.7.3.1... for Tasmota Stage build. Core is based on (soon released) Arduino ESP core 2.7.3. --- platformio_override_sample.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 01aa03601..b938fb888 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -88,7 +88,7 @@ extra_scripts = ${scripts_defaults.extra_scripts} [tasmota_stage] ; *** Esp8266 core for Arduino version Tasmota stage platform = espressif8266@2.5.1 -platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.7.2.1/esp8266-2.7.2.1.zip +platform_packages = framework-arduinoespressif8266 @ https://github.com/Jason2866/Arduino/releases/download/2.7.3.1/esp8266-2.7.3.1.zip build_unflags = ${esp_defaults.build_unflags} build_flags = ${esp82xx_defaults.build_flags} From 528fe5333d7196f1e761f0dde7a8830a4b838379 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 19 Jul 2020 13:33:57 +0200 Subject: [PATCH 23/25] Shrink minimal a bit --- tasmota/tasmota_configurations.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index ad9d64d08..61baee7aa 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -176,7 +176,7 @@ #define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k code, 0k3 mem, 48 iram) #define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram) -#define USE_LMT01 // Add support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code) +#define USE_LMT01 // Add support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code) #define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k code) #define USE_TM1638 // Add support for TM1638 switches copying Switch1 .. Switch8 (+1k code) #define USE_HX711 // Add support for HX711 load cell (+1k5 code) @@ -537,16 +537,17 @@ #undef CODE_IMAGE_STR #define CODE_IMAGE_STR "minimal" -#undef FIRMWARE_LITE // Disable tasmota-lite with no sensors -#undef FIRMWARE_SENSORS // Disable tasmota-sensors with useful sensors enabled -#undef FIRMWARE_KNX_NO_EMULATION // Disable tasmota-knx with KNX but without Emulation -#undef FIRMWARE_DISPLAYS // Disable tasmota-display with display drivers enabled -#undef FIRMWARE_IR // Disable tasmota-ir with IR full protocols activated -#undef FIRMWARE_IR_CUSTOM // Disable tasmota customizable with special marker to add all IR protocols +#undef FIRMWARE_LITE // Disable tasmota-lite with no sensors +#undef FIRMWARE_SENSORS // Disable tasmota-sensors with useful sensors enabled +#undef FIRMWARE_KNX_NO_EMULATION // Disable tasmota-knx with KNX but without Emulation +#undef FIRMWARE_DISPLAYS // Disable tasmota-display with display drivers enabled +#undef FIRMWARE_IR // Disable tasmota-ir with IR full protocols activated +#undef FIRMWARE_IR_CUSTOM // Disable tasmota customizable with special marker to add all IR protocols #undef USE_ARDUINO_OTA // Disable support for Arduino OTA #undef USE_DOMOTICZ // Disable Domoticz #undef USE_HOME_ASSISTANT // Disable Home Assistant +#undef USE_TELEGRAM // Disable support for Telegram protocol (+49k code, +7.0k mem and +4.8k additional during connection handshake) //#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set #undef USE_KNX // Disable KNX IP Protocol Support //#undef USE_WEBSERVER // Disable Webserver @@ -559,6 +560,8 @@ #undef USE_TIMERS // Disable support for up to 16 timers #undef USE_TIMERS_WEB // Disable support for timer webpage #undef USE_SUNRISE // Disable support for Sunrise and sunset tools +#undef USE_PING // Disable Ping command (+2k code) +#undef USE_UNISHOX_COMPRESSION // Disable support for string compression in Rules or Scripts #undef USE_RULES // Disable support for rules #undef USE_SCRIPT // Disable support for script @@ -592,6 +595,7 @@ #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control #undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller #undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code) +#undef USE_DGR_LIGHT_SEQUENCE // Disable support for device group light sequencing (requires USE_DEVICE_GROUPS) (+0k2 code) #undef USE_COUNTER // Disable counters #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices @@ -607,6 +611,7 @@ #undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor #undef USE_HPMA // Disable support for Honeywell HPMA115S0 particle concentration sensor #undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge +#undef USE_TCP_BRIDGE // DIsable support for Serial to TCP bridge (+1.3k code) #undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop #undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger #undef USE_PN532_HSU // Disable support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem) @@ -631,11 +636,14 @@ #undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code) #undef USE_SOLAX_X1 // Disable support for Solax X1 series Modbus log info (+3k1 code) #undef USE_LE01MR // Disable support for F&F LE-01MR Modbus energy meter (+2k code) +#undef USE_BL0940 // Disable support for BL0940 Energy monitor as used in Blitzwolf SHP-10 (+1k6 code) #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_DHT // Disable support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor #undef USE_MAX31855 // Disable MAX31855 K-Type thermocouple sensor using softSPI #undef USE_MAX31865 // Disable support for MAX31865 RTD sensors using softSPI +#undef USE_LMT01 // Disable support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code) #undef USE_IR_REMOTE // Disable IR driver #undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices #undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8 @@ -648,6 +656,7 @@ #undef USE_HRE // Disable support for Badger HR-E Water Meter (+1k4 code) #undef USE_A4988_STEPPER // Disable support for A4988_Stepper #undef USE_THERMOSTAT // Disable support for Thermostat +#undef USE_PROMETHEUS // Disable support for https://prometheus.io/ metrics exporting over HTTP /metrics endpoint #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code #endif // FIRMWARE_MINIMAL From 27ff269bcb332a5ebec3ef15add560c996ed268c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Jul 2020 13:43:08 +0200 Subject: [PATCH 24/25] Fix regression build flags from #8932 --- platformio_override_sample.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index b938fb888..57d7498cb 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -90,7 +90,11 @@ extra_scripts = ${scripts_defaults.extra_scripts} platform = espressif8266@2.5.1 platform_packages = framework-arduinoespressif8266 @ https://github.com/Jason2866/Arduino/releases/download/2.7.3.1/esp8266-2.7.3.1.zip build_unflags = ${esp_defaults.build_unflags} + -std=c17 + -std=gnu++17 build_flags = ${esp82xx_defaults.build_flags} + -std=gnu99 + -std=c++11 ; *********** Alternative Options, enable only if you know exactly what you do ******** ; NONOSDK221 From 23da6285c12c8fb99100b795e32c247aaa4d9a4d Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 19 Jul 2020 15:57:37 +0200 Subject: [PATCH 25/25] Add command ``SetOption100 0/1`` Add command ``SetOption100 0/1`` to remove ``ZbReceived`` value from ``{"ZbReceived":{xxx:yyy}}`` JSON message --- RELEASENOTES.md | 2 ++ tasmota/CHANGELOG.md | 2 ++ tasmota/settings.h | 4 ++-- tasmota/xdrv_23_zigbee_2_devices.ino | 18 +++++++++++++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ddb4bc8b2..5e5e3e549 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -70,6 +70,8 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add command ``SetOption94 0/1`` to select MAX31855 or MAX6675 thermocouple support (#8616) - Add command ``SetOption97 0/1`` to switch between Tuya serial speeds 9600 bps (0) or 115200 bps (1) - Add command ``SetOption98 0/1`` to provide rotary rule triggers (1) instead of controlling light (0) +- Add command ``SetOption99 0/1`` to enable zero cross detection on PWM dimmer +- Add command ``SetOption100 0/1`` to remove ``ZbReceived`` value from ``{"ZbReceived":{xxx:yyy}}`` JSON message - Add command ``Module2`` to configure fallback module on fast reboot (#8464) - Add commands ``LedPwmOn 0..255``, ``LedPwmOff 0..255`` and ``LedPwmMode1 0/1`` to control led brightness by George (#8491) - Add ESP32 ethernet commands ``EthType 0/1``, ``EthAddress 0..31`` and ``EthClockMode 0..3`` diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index b67609a80..7dbad0a37 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -4,12 +4,14 @@ - Remove Arduino ESP8266 Core support for versions before 2.7.1 - Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE +- Add command ``SetOption100 0/1`` to remove ``ZbReceived`` value from ``{"ZbReceived":{xxx:yyy}}`` JSON message ### 8.3.1.6 20200617 - Add command ``Module2`` to configure fallback module on fast reboot (#8464) - Add command ``SetOption97 0/1`` to switch between Tuya serial speeds 9600 bps (0) or 115200 bps (1) - Add command ``SetOption98 0/1`` to provide rotary rule triggers (1) instead of controlling light (0) +- Add command ``SetOption99 0/1`` to enable zero cross detection on PWM dimmer - Add support for Energy sensor (Denky) for French Smart Metering meter provided by global Energy Providers, need a adaptater. See dedicated full [blog](http://hallard.me/category/tinfo/) about French teleinformation stuff - Add library to be used for decoding Teleinfo (French Metering Smart Meter) - Add support for single wire LMT01 temperature Sensor by justifiably (#8713) diff --git a/tasmota/settings.h b/tasmota/settings.h index cc0fd9bf3..9d4466028 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -118,8 +118,8 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t network_ethernet : 1; // bit 14 (v8.3.1.3) - CMND_ETHERNET uint32_t tuyamcu_baudrate : 1; // bit 15 (v8.3.1.6) - SetOption97 - Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200) uint32_t rotary_uses_rules : 1; // bit 16 (v8.3.1.6) - SetOption98 - Use rules instead of light control - uint32_t zerocross_dimmer : 1; // bit 17 (v8.3.1.4) = SetOption99 - Enable zerocross dimmer on PWM DIMMER - uint32_t spare18 : 1; + uint32_t zerocross_dimmer : 1; // bit 17 (v8.3.1.4) - SetOption99 - Enable zerocross dimmer on PWM DIMMER + uint32_t remove_zbreceived : 1; // bit 18 (v8.3.1.7) - SetOption100 - Remove ZbReceived form JSON message uint32_t spare19 : 1; uint32_t spare20 : 1; uint32_t spare21 : 1; diff --git a/tasmota/xdrv_23_zigbee_2_devices.ino b/tasmota/xdrv_23_zigbee_2_devices.ino index d570c4560..abcf6440c 100644 --- a/tasmota/xdrv_23_zigbee_2_devices.ino +++ b/tasmota/xdrv_23_zigbee_2_devices.ino @@ -102,7 +102,7 @@ typedef struct Z_Deferred { uint16_t groupaddr; // group address (if needed) uint16_t cluster; // cluster to use for the timer uint8_t endpoint; // endpoint to use for timer - uint8_t category; // which category of deferred is it + uint8_t category; // which category of deferred is it uint32_t value; // any raw value to use for the timer Z_DeviceTimer func; // function to call when timer occurs } Z_Deferred; @@ -213,7 +213,7 @@ public: private: std::vector _devices = {}; std::vector _deferred = {}; // list of deferred calls - uint32_t _saveTimer = 0; + uint32_t _saveTimer = 0; uint8_t _seqNumber = 0; // global seqNumber if device is unknown template < typename T> @@ -738,7 +738,7 @@ bool Z_Devices::getHueState(uint16_t shortaddr, void Z_Devices::resetTimersForDevice(uint16_t shortaddr, uint16_t groupaddr, uint8_t category) { // iterate the list of deferred, and remove any linked to the shortaddr for (auto it = _deferred.begin(); it != _deferred.end(); it++) { - // Notice that the iterator is decremented after it is passed + // Notice that the iterator is decremented after it is passed // to erase() but before erase() is executed // see https://www.techiedelight.com/remove-elements-vector-inside-loop-cpp/ if ((it->shortaddr == shortaddr) && (it->groupaddr == groupaddr)) { @@ -937,9 +937,17 @@ void Z_Devices::jsonPublishFlush(uint16_t shortaddr) { zigbee_devices.jsonClear(shortaddr); if (use_fname) { - Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname, msg.c_str()); + if (Settings.flag4.remove_zbreceived) { + Response_P(PSTR("{\"%s\":%s}"), fname, msg.c_str()); + } else { + Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname, msg.c_str()); + } } else { - Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str()); + if (Settings.flag4.remove_zbreceived) { + Response_P(PSTR("{\"0x%04X\":%s}"), shortaddr, msg.c_str()); + } else { + Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str()); + } } if (Settings.flag4.zigbee_distinct_topics) { char subtopic[16];