From d280dc535f605817f18f26be919e084f89617793 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 4 May 2022 10:07:24 +0200 Subject: [PATCH] Add features to SafeMode binary --- tasmota/my_user_config.h | 4 ++- tasmota/support_command.ino | 8 ++--- tasmota/tasmota_configurations.h | 2 ++ tasmota/tasmota_configurations_ESP32.h | 43 ++++++++++++++++++-------- tasmota/xdrv_01_webserver.ino | 10 ++---- tasmota/xdrv_02_9_mqtt.ino | 8 ++--- tasmota/xsns_127_esp32_sensors.ino | 2 ++ 7 files changed, 48 insertions(+), 29 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index a3344e41f..54ae4d6ae 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -999,6 +999,8 @@ #define SET_ESP32_STACK_SIZE (8 * 1024) // Set the stack size for Tasmota. The default value is 8192 for Arduino, some builds might need to increase it +#define USE_ESP32_SENSORS // Add support for ESP32 temperature and optional hall effect sensor + //#define USE_SONOFF_SPM // Add support for ESP32 based Sonoff Smart Stackable Power Meter (+11k code) //#define USE_ETHERNET // Add support for ethernet (+20k code) @@ -1084,7 +1086,7 @@ #define BE_LV_WIDGET_SPINNER #define BE_LV_WIDGET_QRCODE - + #endif // ESP32 /*********************************************************************************************\ diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 7a568e4a2..33c055caf 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -22,7 +22,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix D_SO_WIFINOSLEEP "|" // Other commands D_CMND_UPGRADE "|" D_CMND_UPLOAD "|" D_CMND_OTAURL "|" D_CMND_SERIALLOG "|" D_CMND_RESTART "|" -#ifndef FIRMWARE_MINIMAL +#ifndef FIRMWARE_MINIMAL_ONLY D_CMND_BACKLOG "|" D_CMND_DELAY "|" D_CMND_POWER "|" D_CMND_STATUS "|" D_CMND_STATE "|" D_CMND_SLEEP "|" D_CMND_POWERONSTATE "|" D_CMND_PULSETIME "|" D_CMND_BLINKTIME "|" D_CMND_BLINKCOUNT "|" D_CMND_SAVEDATA "|" D_CMND_SO "|" D_CMND_SETOPTION "|" D_CMND_TEMPERATURE_RESOLUTION "|" D_CMND_HUMIDITY_RESOLUTION "|" D_CMND_PRESSURE_RESOLUTION "|" D_CMND_POWER_RESOLUTION "|" @@ -48,7 +48,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix #ifdef ESP32 "|Info|" D_CMND_TOUCH_CAL "|" D_CMND_TOUCH_THRES "|" D_CMND_TOUCH_NUM "|" D_CMND_CPU_FREQUENCY #endif // ESP32 -#endif //FIRMWARE_MINIMAL +#endif //FIRMWARE_MINIMAL_ONLY ; SO_SYNONYMS(kTasmotaSynonyms, @@ -57,7 +57,7 @@ SO_SYNONYMS(kTasmotaSynonyms, void (* const TasmotaCommand[])(void) PROGMEM = { &CmndUpgrade, &CmndUpgrade, &CmndOtaUrl, &CmndSeriallog, &CmndRestart, -#ifndef FIRMWARE_MINIMAL +#ifndef FIRMWARE_MINIMAL_ONLY &CmndBacklog, &CmndDelay, &CmndPower, &CmndStatus, &CmndState, &CmndSleep, &CmndPowerOnState, &CmndPulsetime, &CmndBlinktime, &CmndBlinkcount, &CmndSavedata, &CmndSetoption, &CmndSetoption, &CmndTemperatureResolution, &CmndHumidityResolution, &CmndPressureResolution, &CmndPowerResolution, @@ -83,7 +83,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = { #ifdef ESP32 , &CmndInfo, &CmndTouchCal, &CmndTouchThres, &CmndTouchNum, &CmndCpuFrequency #endif // ESP32 -#endif //FIRMWARE_MINIMAL +#endif //FIRMWARE_MINIMAL_ONLY }; const char kWifiConfig[] PROGMEM = diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index d97569395..f6b7682c4 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -778,6 +778,8 @@ #undef CODE_IMAGE_STR #define CODE_IMAGE_STR "minimal" +#define FIRMWARE_MINIMAL_ONLY + #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 diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h index d85b93e09..39a6c39c2 100644 --- a/tasmota/tasmota_configurations_ESP32.h +++ b/tasmota/tasmota_configurations_ESP32.h @@ -25,26 +25,15 @@ /*********************************************************************************************\ * [tasmota32x-safemode.bin] * Provide an image with useful supported sensors enabled + * + * Is a copy of FIRMWARE_MINIMAL with some additional features enabled \*********************************************************************************************/ #ifdef FIRMWARE_SAFEMODE -#define FIRMWARE_MINIMAL #undef CODE_IMAGE_STR #define CODE_IMAGE_STR "safemode" -#define USE_TLS -#define USE_WEBSERVER -#define USE_WEBCLIENT -#define USE_WEBCLIENT_HTTPS - -#undef USE_UFILESYS -#undef GUI_TRASH_FILE -#undef GUI_EDIT_FILE -#undef USE_PING -#undef USE_AUTOCONF -#undef USE_BERRY - #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 @@ -55,6 +44,10 @@ #undef FIRMWARE_LVGL #undef FIRMWARE_TASMOTA32 +/*-------------------------------------------------------------------------------------------*\ + * Start copy of all undefines from FIRMWARE_MINIMAL +\*-------------------------------------------------------------------------------------------*/ + #undef USE_IMPROV // Disable support for IMPROV serial protocol as used by esp-web-tools (+2k code) #undef USE_TASMESH // Disable Tasmota Mesh using ESP-NOW (+11k code) #undef USE_ARDUINO_OTA // Disable support for Arduino OTA @@ -164,6 +157,30 @@ #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code #undef USE_AC_ZERO_CROSS_DIMMER // Disable support for AC_ZERO_CROSS_DIMMER + +/*-------------------------------------------------------------------------------------------*\ + * End copy of all undefines from FIRMWARE_MINIMAL + * + * Start FIRMWARE_SAFEMODE specific additions +\*-------------------------------------------------------------------------------------------*/ + +#define FIRMWARE_MINIMAL + +#undef FIRMWARE_MINIMAL_ONLY + +#undef USE_ESP32_SENSORS +#undef USE_UFILESYS +#undef GUI_TRASH_FILE +#undef GUI_EDIT_FILE +#undef USE_PING +#undef USE_AUTOCONF +#undef USE_BERRY + +#define USE_TLS +#define USE_WEBSERVER +#define USE_WEBCLIENT +#define USE_WEBCLIENT_HTTPS + #endif // FIRMWARE_SAFEMODE /*********************************************************************************************\ diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 2c1646ab9..eebed27fe 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -244,11 +244,11 @@ const char HTTP_HEAD_STYLE3[] PROGMEM = "