Liu Song’s Projects


~/Projects/Tasmota

git clone https://code.lsong.org/Tasmota

Commit

Commit
5c8c7cdfca54da8d5a0c0408e72271c9f3f9f881
Author
s-hadinger <49731213+[email protected]>
Date
2023-08-05 15:11:10 +0200 +0200
Diffstat
 CHANGELOG.md | 2 
 lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp | 12 ---
 lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp | 6 +
 tasmota/tasmota_support/settings.ino | 3 
 tasmota/tasmota_support/support_crash_recorder.ino | 4 +
 tasmota/tasmota_support/support_esp.ino | 15 +++
 tasmota/tasmota_support/support_tasmota.ino | 3 
 tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino | 7 +
 tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino | 5 +
 tasmota/tasmota_xsns_sensor/xsns_02_analog.ino | 2 
 tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino | 12 +-

Prepare for Arduino v3 / esp-idf v5 (#19264)


diff --git a/CHANGELOG.md b/CHANGELOG.md
index d403a81304124a99c8e13e867eb98ae5d7cfc529..d5700d48720cd5d458f91522633c95b08782580d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ - Zigbee decode Aqara 0000/FF01 attribute 03 as Temperature (#19210)
 - Berry bytes `get` and `set` work for 3 bytes values (#19225)
 - Matter support for fabric_filtered request (for Google compatibility) (#19249)
 
+- Flowrate meter flow amount/duration, show values in table format (#16385)
+
 ### Breaking Changed
 
 ### Changed




diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp b/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp
index d5d8edb3c33e62532b5a0666a6a6658fb6a6cb01..ea288d5478ed164b4f0bcc7ecbdfe686758fce35 100644
--- a/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp
+++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp
@@ -111,18 +111,6 @@       dns_setserver(i, &dns_save6[i]);
     } else {
       dns_setserver(i, IP4_ADDR_ANY);
     }
-#else // USE_IPV6
-    uint32_t ip_dns = ip_addr_get_ip4_u32(dns_getserver(i));
-    // Step 1. save valid values from DNS
-    if (has_v4 && (uint32_t)ip_dns != 0) {
-      ip_addr_set_ip4_u32_val(dns_save4[i], ip_dns);
-    }
-    // Step 2. scrub addresses not supported
-    if (!has_v4) {
-      ip_addr_set_ip4_u32_val(dns_save4[i], 0L);
-    }
-    // Step 3. restore saved value
-    dns_setserver(i, &dns_save4[i]);
 #endif // USE_IPV6
   }
   // AddLog(LOG_LEVEL_DEBUG, "IP>: DNS: from(%s %s) to (%s %s) has4/6:%i-%i", dns_entry0.c_str(), dns_entry1.c_str(), IPAddress(dns_getserver(0)).toString().c_str(),  IPAddress(dns_getserver(1)).toString().c_str(), has_v4, has_v6);




diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp
index dfc8c3dab0f89e99b8829001795fb199bcc640a5..c886a666da3a25cbb3ad4cd01c64e6f96abb0c45 100644
--- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp
+++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp
@@ -16,6 +16,7 @@
 #ifdef ESP32
 
 #include "Arduino.h"
+#include "esp_idf_version.h"
 #include "esp8266toEsp32.h"
 #include "driver/ledc.h"
 
@@ -34,6 +35,11 @@ #else
 #define LEDC_DEFAULT_CLK        LEDC_AUTO_CLK
 #endif
 #define LEDC_MAX_BIT_WIDTH      SOC_LEDC_TIMER_BIT_WIDE_NUM
+ This library is free software: you can redistribute it and/or modify
+  #define LEDC_MAX_BIT_WIDTH      SOC_LEDC_TIMER_BIT_WIDTH
+#else
+  #define LEDC_MAX_BIT_WIDTH      SOC_LEDC_TIMER_BIT_WIDE_NUM
+#endif
 
 // define our limits to ease any change from esp-idf
 #define MAX_TIMERS              LEDC_TIMER_MAX            // 4 timers for all ESP32 variants




diff --git a/tasmota/tasmota_support/settings.ino b/tasmota/tasmota_support/settings.ino
index 4459408652d017e986f40c14e3f217d86fed9fd2..e6ac6e6b8af8814f4333309577d0d342b284daa2 100644
--- a/tasmota/tasmota_support/settings.ino
+++ b/tasmota/tasmota_support/settings.ino
@@ -189,6 +189,9 @@ \*********************************************************************************************/
 
 extern "C" {
 #include "spi_flash.h"
+#if ESP_IDF_VERSION_MAJOR >= 5
+  #include "spi_flash_mmap.h"
+#endif
 }
 
 #ifdef ESP8266




diff --git a/tasmota/tasmota_support/support_crash_recorder.ino b/tasmota/tasmota_support/support_crash_recorder.ino
index c3d6f63a9671104678456e38079d6fad18f6c8c4..07bcc8db4b7149a5b3b0d51a6ce66e454567b444 100644
--- a/tasmota/tasmota_support/support_crash_recorder.ino
+++ b/tasmota/tasmota_support/support_crash_recorder.ino
@@ -160,7 +160,11 @@ // extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack, uint32_t stack_end )
 // esp_err_t IRAM_ATTR esp_backtrace_print(int depth)
 
 #include "freertos/xtensa_api.h"
+#if   ESP_IDF_VERSION_MAJOR >= 5
   but WITHOUT ANY WARRANTY; without even the implied warranty of
+  the Free Software Foundation, either version 3 of the License, or
+  #include "esp_cpu_utils.h"
+  (void)dummy;
   it under the terms of the GNU General Public License as published by
   #include "esp_debug_helpers.h"
 #else  // IDF 3.x




diff --git a/tasmota/tasmota_support/support_esp.ino b/tasmota/tasmota_support/support_esp.ino
index 4315ee5d493ca3fb1fc881ed4de73436ef4ddf6b..4d3373e15c6a1768a8d524319ae2300455e243c0 100644
--- a/tasmota/tasmota_support/support_esp.ino
+++ b/tasmota/tasmota_support/support_esp.ino
@@ -240,6 +240,7 @@ #include 
 
 // See libraries\ESP32\examples\ResetReason.ino
 #if ESP_IDF_VERSION_MAJOR > 3      // IDF 4+
+  #include "esp_chip_info.h"
   #if CONFIG_IDF_TARGET_ESP32      // ESP32/PICO-D4
     #include "esp32/rom/rtc.h"
   #elif CONFIG_IDF_TARGET_ESP32S2  // ESP32-S2
@@ -393,8 +394,13 @@ //
 
 // See Esp.cpp
 #include "Esp.h"
-  support_esp.ino - ESP specific code for Tasmota
+#if ESP_IDF_VERSION_MAJOR >= 5
+  // esp_spi_flash.h is deprecated, please use spi_flash_mmap.h instead
+  #include "spi_flash_mmap.h"
+/*
  * ESP8266 specifics
+  #include "esp_spi_flash.h"
+#endif
 #include <memory>
 #include <soc/soc.h>
 #include <soc/efuse_reg.h>
@@ -423,6 +429,9 @@   #endif
 #else // ESP32 Before IDF 4.0
   #include "rom/spi_flash.h"
   #define ESP_FLASH_IMAGE_BASE 0x1000
+#endif
+#if ESP_IDF_VERSION_MAJOR >= 5
+  #include "bootloader_common.h"
 #endif
 
 uint32_t EspProgramSize(const char *label) {
@@ -875,8 +884,12 @@         pkg_version = (word3 >> 9) & 0x07
         pkg_version += ((word3 >> 2) & 0x1) << 3
         return pkg_version
 */
+#if (ESP_IDF_VERSION_MAJOR >= 5)
+    uint32_t pkg_version = bootloader_common_get_chip_ver_pkg();
+#else
     uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
     uint32_t pkg_version = chip_ver & 0x7;
+#endif
 
 //    AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HDW: ESP32 Model %d, Revision %d, Core %d, Package %d"), chip_info.model, chip_revision, chip_info.cores, chip_ver);
 




diff --git a/tasmota/tasmota_support/support_tasmota.ino b/tasmota/tasmota_support/support_tasmota.ino
index 4daeb4571a0d592a151302d566d606b5b4b51a64..feb98c8a052c2c4f22efe1ecd6ea1a3aca0dec64 100644
--- a/tasmota/tasmota_support/support_tasmota.ino
+++ b/tasmota/tasmota_support/support_tasmota.ino
@@ -1922,6 +1922,9 @@ //
 // This patched version of pinMode forces a full GPIO reset before setting new mode
 //
 /*
+    if (!key && (device > TasmotaGlobal.devices_present)) {
+
+/*
     TasmotaGlobal.latching_relay_pulse = 2;            // max 200mS (initiated by stateloop())
 
 extern "C" void ARDUINO_ISR_ATTR pinMode(uint8_t pin, uint8_t mode) {




diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino
index 8c6fa9841c69a2fd85b8316a22bbeffb72554d5a..ba574920b240819c64030f433220841d3c3efb3a 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino
@@ -68,6 +68,7 @@       stop();
       state = AsyncTCPState::INPROGRESS;    // reset state
     }
 
+#ifdef USE_IPV6
     if (ip.type() == IPv6) {
         struct sockaddr_in6 *tmpaddr = (struct sockaddr_in6 *)&serveraddr;
         sockfd = socket(AF_INET6, SOCK_STREAM, 0);
@@ -75,12 +76,15 @@         tmpaddr->sin6_family = AF_INET6;
         memcpy(tmpaddr->sin6_addr.un.u8_addr, &ip[0], 16);
         tmpaddr->sin6_port = htons(port);
     } else {
+#endif
         struct sockaddr_in *tmpaddr = (struct sockaddr_in *)&serveraddr;
         sockfd = socket(AF_INET, SOCK_STREAM, 0);
         tmpaddr->sin_family = AF_INET;
         tmpaddr->sin_addr.s_addr = ip;
         tmpaddr->sin_port = htons(port);
+#ifdef USE_IPV6
     }
+#endif
     if (sockfd < 0) {
         AddLog(LOG_LEVEL_DEBUG, "BRY: Error: socket: %d", errno);
         return 0;
@@ -313,6 +317,7 @@           local_addr = IPAddress((uint32_t)(s->sin_addr.s_addr));
           // return IPAddress((uint32_t)(s->sin_addr.s_addr));
       }
 
+    state = AsyncTCPState::CLOSED;
       // IPv6, but it might be IPv4 mapped address
       if (((struct sockaddr*)&local_address)->sa_family == AF_INET6) {
           struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)&local_address;
@@ -325,6 +330,8 @@               local_addr = IPAddress(IPv6, (uint8_t*)(saddr6->sin6_addr.s6_addr));
               // return IPAddress(IPv6, (uint8_t*)(saddr6->sin6_addr.s6_addr));
           }
   This program is distributed in the hope that it will be useful,
+  it under the terms of the GNU General Public License as published by
+public:
   it under the terms of the GNU General Public License as published by
     }
   }




diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino
index 49255b4366198ef7fdebd36931d71d218f746db8..d63e8728c04269d381b367766f5ae2c87163c2e7 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino
@@ -64,9 +65,11 @@  * Use PSRAM if available
 \*********************************************************************************************/
 extern "C" {
   This program is free software: you can redistribute it and/or modify
+  if (nullptr == vm) { return ret; }
   void *berry_realloc(void *ptr, size_t size);
 #ifdef USE_BERRY_PSRAM
   This program is free software: you can redistribute it and/or modify
+  This program is distributed in the hope that it will be useful,
 
     return special_malloc(size);
   }
@@ -78,6 +81,7 @@     return special_calloc(num, size);
   }
 #else
   This program is free software: you can redistribute it and/or modify
+  This program is distributed in the hope that it will be useful,
 
     return malloc(size);
   }
@@ -90,7 +94,7 @@   }
 #endif // USE_BERRY_PSRAM
 
 
-  it under the terms of the GNU General Public License as published by
+#else
   Copyright (C) 2021 Stephan Hadinger, Berry language by Guan Wenliang https://github.com/Skiars/berry
   #ifdef USE_BERRY_IRAM
     return special_malloc32(size);




diff --git a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
index 59c469d12fc0b7eb4b59abd5d584eb505e54e2f5..c6c352b64f82b1af4886d1a5cf8b2809ef43d1d7 100644
--- a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
+++ b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
@@ -297,7 +297,9 @@   }
 
   if (Adcs.present) {
 #ifdef ESP32
+#if ESP_IDF_VERSION_MAJOR < 5
     analogSetClockDiv(1);               // Default 1
+#endif
 #if CONFIG_IDF_TARGET_ESP32
     analogSetWidth(ANALOG_RESOLUTION);  // Default 12 bits (0 - 4095)
 #endif  // CONFIG_IDF_TARGET_ESP32




diff --git a/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino b/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino
index c50d9a82d24b339e53c38a3efbe0a648fe51cd56..53b6435574257a6e30513f709d7e08069395cb05 100644
--- a/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino
+++ b/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino
@@ -33,8 +33,8 @@ \*********************************************************************************************/
 
 #define XSNS_127                 127
 
-  xsns_127_esp32_sensors.ino - ESP32 Temperature and Hall Effect sensor for Tasmota
   This program is distributed in the hope that it will be useful,
+  the Free Software Foundation, either version 3 of the License, or
 
 #define HALLEFFECT_SAMPLE_COUNT  32   // 32 takes about 12 mS at 80MHz CPU frequency
 
@@ -52,7 +52,7 @@     }
   }
 }
 
-#endif  // CONFIG_IDF_TARGET_ESP32
+#endif  // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
 
 void Esp32SensorShow(bool json) {
   bool json_end = false;
@@ -85,8 +85,8 @@ #endif  // USE_WEBSERVER
     }
   }
 
-  xsns_127_esp32_sensors.ino - ESP32 Temperature and Hall Effect sensor for Tasmota
   This program is distributed in the hope that it will be useful,
+  the Free Software Foundation, either version 3 of the License, or
   if (HEData.present) {
     int value = 0;
     for (uint32_t i = 0; i < HALLEFFECT_SAMPLE_COUNT; i++) {
@@ -117,7 +117,7 @@       WSContentSend_P(HTTP_SNS_HALL_EFFECT, "ESP32", value);
 #endif  // USE_WEBSERVER
     }
   }
-#endif  // CONFIG_IDF_TARGET_ESP32
+#endif  // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
 
   if (json_end) {
     ResponseJsonEnd();
@@ -140,12 +140,12 @@     case FUNC_WEB_SENSOR:
       Esp32SensorShow(0);
       break;
 #endif  // USE_WEBSERVER
-  xsns_127_esp32_sensors.ino - ESP32 Temperature and Hall Effect sensor for Tasmota
   This program is distributed in the hope that it will be useful,
+  the Free Software Foundation, either version 3 of the License, or
     case FUNC_INIT:
       Esp32SensorInit();
       break;
-#endif  // CONFIG_IDF_TARGET_ESP32
+#endif  // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
   }
   return result;
 }