diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index 5a5321706..bdb2d7b5e 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -58,17 +58,17 @@ 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 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] @@ -79,25 +79,25 @@ 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 -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 [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 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 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 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 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); 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; 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)