From c71e5018786d96378212c09e9a68031b42281923 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 8 Jan 2022 18:01:16 +0100 Subject: [PATCH 1/7] Add log to TS for calibration --- tasmota/xdrv_55_touch.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tasmota/xdrv_55_touch.ino b/tasmota/xdrv_55_touch.ino index 269f775af..1016cc467 100644 --- a/tasmota/xdrv_55_touch.ino +++ b/tasmota/xdrv_55_touch.ino @@ -142,7 +142,7 @@ void Touch_Check(void(*rotconvert)(int16_t *x, int16_t *y)) { #endif // USE_XPT2046 if (touched) { - + AddLog(LOG_LEVEL_DEBUG_MORE, "TS : touched x=%i y=%i", touch_xp, touch_yp); #ifdef USE_TOUCH_BUTTONS #ifdef USE_M5STACK_CORE2 // handle 3 built in touch buttons @@ -317,9 +317,12 @@ bool Xdrv55(uint8_t function) { } return result; } -#else + +#else // #if defined(USE_FT5206) || defined(USE_XPT2046) || defined(USE_LILYGO47) || defined(USE_TOUCH_BUTTONS) + // dummy for LVGL without a touch controller uint32_t Touch_Status(uint32_t sel) { -return 0; + return 0; } + #endif // #if defined(USE_FT5206) || defined(USE_XPT2046) || defined(USE_LILYGO47) || defined(USE_TOUCH_BUTTONS) From 2900ee741c8560c7165174682ae45cdc28ce5d4c Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 8 Jan 2022 18:06:06 +0100 Subject: [PATCH 2/7] Berry report iram memory --- tasmota/xdrv_52_3_berry_tasmota.ino | 61 ++++++++++++++++++----------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/tasmota/xdrv_52_3_berry_tasmota.ino b/tasmota/xdrv_52_3_berry_tasmota.ino index 6279e4877..db8ab31d9 100644 --- a/tasmota/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/xdrv_52_3_berry_tasmota.ino @@ -68,34 +68,45 @@ const uint32_t BERRY_MAX_REPL_LOGS = 1024; // max number of print output recor * \*********************************************************************************************/ extern "C" { - // Berry: `tasmota.publish(topic, payload [,retain]) -> nil`` + // Berry: `tasmota.publish(topic, payload [, retain:bool, start:int, len:int]) -> nil`` // int32_t l_publish(struct bvm *vm); int32_t l_publish(struct bvm *vm) { int32_t top = be_top(vm); // Get the number of arguments - if (top >= 3 && be_isstring(vm, 2) && (be_isstring(vm, 3) || be_isinstance(vm, 3))) { // 2 mandatory string arguments - if (top == 3 || (top == 4 && be_isbool(vm, 4))) { // 3rd optional argument must be bool - const char * topic = be_tostring(vm, 2); - const char * payload = nullptr; - size_t payload_len = 0; - if (be_isstring(vm, 3)) { - payload = be_tostring(vm, 3); - payload_len = strlen(payload); - } else { - be_getglobal(vm, "bytes"); /* get the bytes class */ /* TODO eventually replace with be_getbuiltin */ - if (be_isderived(vm, 3)) { - payload = (const char *) be_tobytes(vm, 3, &payload_len); - } - } - bool retain = false; - if (top == 4) { - retain = be_tobool(vm, 4); - } - if (!payload) { be_raise(vm, "value_error", "Empty payload"); } - be_pop(vm, be_top(vm)); - MqttPublishPayload(topic, payload, payload_len, retain); - be_return_nil(vm); // Return + if (top >= 3 && be_isstring(vm, 2) && (be_isstring(vm, 3) || be_isbytes(vm, 3))) { // 2 mandatory string arguments + bool retain = false; + int32_t payload_start = 0; + int32_t len = -1; // send all of it + if (top >= 4) { retain = be_tobool(vm, 4); } + if (top >= 5) { + payload_start = be_toint(vm, 5); + if (payload_start < 0) payload_start = 0; } + if (top >= 6) { len = be_toint(vm, 6); } + const char * topic = be_tostring(vm, 2); + const char * payload = nullptr; + size_t payload_len = 0; + + if (be_isstring(vm, 3)) { + payload = be_tostring(vm, 3); + payload_len = strlen(payload); + } else { + payload = (const char *) be_tobytes(vm, 3, &payload_len); + } + if (!payload) { be_raise(vm, "value_error", "Empty payload"); } + + // adjust start and len + if (payload_start >= payload_len) { len = 0; } // send empty packet + else if (len < 0) { len = payload_len - payload_start; } // send all packet, adjust len + else if (payload_start + len > payload_len) { len = payload_len - payload_start; } // len is too long, adjust + // adjust start + payload = payload + payload_start; + + be_pop(vm, be_top(vm)); // clear stack to avoid any indirect warning message in subsequent calls to Berry + + MqttPublishPayload(topic, payload, len, retain); + + be_return_nil(vm); // Return } be_raise(vm, kTypeError, nullptr); } @@ -206,6 +217,10 @@ extern "C" { if (UsePSRAM()) { be_map_insert_int(vm, "psram", ESP.getPsramSize() / 1024); be_map_insert_int(vm, "psram_free", ESP.getFreePsram() / 1024); + } else { + // IRAM information + int32_t iram_free = (int32_t)heap_caps_get_free_size(MALLOC_CAP_32BIT) - (int32_t)heap_caps_get_free_size(MALLOC_CAP_8BIT); + be_map_insert_int(vm, "iram_free", iram_free / 1024); } be_pop(vm, 1); be_return(vm); From 3c3ccfa6604037de954444f120c0e6cc299ce478 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 8 Jan 2022 18:10:17 +0100 Subject: [PATCH 3/7] TLS ESP32, if max packet size is more than 2000, extend TLS buffers to 4K --- tasmota/xdrv_02_9_mqtt.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasmota/xdrv_02_9_mqtt.ino b/tasmota/xdrv_02_9_mqtt.ino index d245a1964..a86d0328c 100644 --- a/tasmota/xdrv_02_9_mqtt.ino +++ b/tasmota/xdrv_02_9_mqtt.ino @@ -211,7 +211,11 @@ void MqttInit(void) { if (Mqtt.mqtt_tls) { #ifdef ESP32 + #if MQTT_MAX_PACKET_SIZE > 2000 + tlsClient = new BearSSL::WiFiClientSecure_light(4096,4096); + #else tlsClient = new BearSSL::WiFiClientSecure_light(2048,2048); + #endif #else // ESP32 - ESP8266 tlsClient = new BearSSL::WiFiClientSecure_light(1024,1024); #endif From 8406d11ce4e8aa19636eb658b605b525bf9d357e Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 8 Jan 2022 18:13:50 +0100 Subject: [PATCH 4/7] Berry add 200ms and 250ms messages --- tasmota/xdrv_52_9_berry.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tasmota/xdrv_52_9_berry.ino b/tasmota/xdrv_52_9_berry.ino index dcbde05ca..91b7ff4bf 100644 --- a/tasmota/xdrv_52_9_berry.ino +++ b/tasmota/xdrv_52_9_berry.ino @@ -777,6 +777,12 @@ bool Xdrv52(uint8_t function) case FUNC_EVERY_100_MSECOND: callBerryEventDispatcher(PSTR("every_100ms"), nullptr, 0, nullptr); break; + case FUNC_EVERY_200_MSECOND: + callBerryEventDispatcher(PSTR("every_200ms"), nullptr, 0, nullptr); + break; + case FUNC_EVERY_250_MSECOND: + callBerryEventDispatcher(PSTR("every_250ms"), nullptr, 0, nullptr); + break; case FUNC_EVERY_SECOND: callBerryEventDispatcher(PSTR("every_second"), nullptr, 0, nullptr); break; From b2463b6df92dae6bff15828e95cd680864c4cb4d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 8 Jan 2022 23:16:11 +0100 Subject: [PATCH 5/7] enable autoconf for all esp32 builds --- platformio_tasmota_env32.ini | 10 +++++----- tasmota/my_user_config.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index 5a5321706..efc42f80c 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -63,12 +63,12 @@ lib_extra_dirs = lib/libesp32 [env:tasmota32-odroidgo] extends = env:tasmota32_base board = esp32-odroid -build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_ODROID_GO -DUSE_UNIVERSAL_DISPLAY -DUSE_AUTOCONF +build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_ODROID_GO -DUSE_UNIVERSAL_DISPLAY [env:tasmota32-core2] extends = env:tasmota32_base board = esp32-m5core2 -build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_M5STACK_CORE2 -DUSE_UNIVERSAL_DISPLAY -DUSE_AUTOCONF +build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_M5STACK_CORE2 -DUSE_UNIVERSAL_DISPLAY lib_extra_dirs = lib/libesp32, lib/libesp32_lvgl, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display, lib/lib_audio [env:tasmota32-bluetooth] @@ -83,7 +83,7 @@ lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_display [env:tasmota32-lvgl] extends = env:tasmota32_base -build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_LVGL -DUSE_AUTOCONF +build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_LVGL board_build.f_cpu = 160000000L lib_extra_dirs = lib/libesp32, lib/libesp32_lvgl, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display @@ -97,7 +97,7 @@ extends = env:tasmota32_base board = esp32c3 build_unflags = ${env:tasmota32_base.build_unflags} -mtarget-align -build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 -DUSE_AUTOCONF +build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 lib_ignore = TTGO TWatch Library Micro-RTSP @@ -106,7 +106,7 @@ lib_ignore = [env:tasmota32s2] extends = env:tasmota32_base board = esp32s2 -build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32 -DUSE_AUTOCONF +build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32 lib_ignore = TTGO TWatch Library NimBLE-Arduino diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 099248267..590e6dce6 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -1004,7 +1004,7 @@ //#define USE_IBEACON_ESP32 //#define USE_WEBCAM // Add support for webcam -// #define USE_AUTOCONF // Enable Esp32 autoconf feature, requires USE_BERRY and USE_WEBCLIENT_HTTPS (12KB Flash) +#define USE_AUTOCONF // Enable Esp32 autoconf feature, requires USE_BERRY and USE_WEBCLIENT_HTTPS (12KB Flash) #define USE_BERRY // Enable Berry scripting language #define USE_BERRY_PYTHON_COMPAT // Enable by default `import python_compat` #define USE_BERRY_TIMEOUT 4000 // Timeout in ms, will raise an exception if running time exceeds this timeout From 3702654055fe50edd35f262e6f599b82c6577eb6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 8 Jan 2022 23:22:34 +0100 Subject: [PATCH 6/7] Update platformio_tasmota_env32.ini --- platformio_tasmota_env32.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index efc42f80c..bdb2d7b5e 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -58,7 +58,7 @@ build_flags = ${core32solo1.build_flags} -DFIRMWARE_TASMOTA32 extends = env:tasmota32_base board = esp32-cam build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_WEBCAM -lib_extra_dirs = lib/libesp32 +lib_extra_dirs = lib/lib_ssl, lib/libesp32 [env:tasmota32-odroidgo] extends = env:tasmota32_base @@ -79,7 +79,7 @@ lib_extra_dirs = lib/libesp32, lib/libesp32_div, lib/lib_basic, lib/lib [env:tasmota32-display] extends = env:tasmota32_base build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_DISPLAYS -lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_display +lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_display, lib/lib_ssl [env:tasmota32-lvgl] extends = env:tasmota32_base @@ -90,7 +90,7 @@ lib_extra_dirs = lib/libesp32, lib/libesp32_lvgl, lib/lib_basic, lib/li [env:tasmota32-ir] extends = env:tasmota32_base build_flags = ${env:tasmota32_base.build_flags} -DUSE_IR_REMOTE_FULL -DFIRMWARE_IR -lib_extra_dirs = lib/libesp32, lib/lib_basic +lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_ssl [env:tasmota32c3] extends = env:tasmota32_base From c52a9353a44a3bc65af02467a0e3cd1ff72d1fb7 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 8 Jan 2022 23:33:00 +0100 Subject: [PATCH 7/7] enable Berry for webcam --- tasmota/tasmota_configurations_ESP32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h index ece3096c8..7062dd38a 100644 --- a/tasmota/tasmota_configurations_ESP32.h +++ b/tasmota/tasmota_configurations_ESP32.h @@ -51,7 +51,7 @@ #undef USE_DS18x20 #undef USE_WS2812 #undef USE_ENERGY_SENSOR -#undef USE_BERRY // Disable Berry scripting language +//#undef USE_BERRY // Disable Berry scripting language #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #endif // FIRMWARE_WEBCAM