From 0744bf7f2b4c03ac85fb4b121de661cb5db651de Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Mon, 11 Nov 2024 15:17:22 +0100
Subject: [PATCH] Save 6k code from ESP32 safeboot
---
tasmota/tasmota_support/settings.ino | 4 +-
.../xdrv_01_9_webserver.ino | 47 +++++++------------
.../tasmota_xdrv_driver/xdrv_06_snfbridge.ino | 4 ++
.../xdrv_16_tuyamcu_v1.ino | 4 ++
.../xdrv_16_tuyamcu_v2.ino | 4 ++
.../tasmota_xlgt_light/xlgt_07_lsc_mcsl.ino | 4 ++
6 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/tasmota/tasmota_support/settings.ino b/tasmota/tasmota_support/settings.ino
index c509f5cba..09376bb05 100644
--- a/tasmota/tasmota_support/settings.ino
+++ b/tasmota/tasmota_support/settings.ino
@@ -687,9 +687,11 @@ char* SettingsText(uint32_t index) {
if (index >= SET_MAX) { // Index above SET_MAX are not stored in Settings
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
if (SET_BUTTON17 <= index && index <= SET_BUTTON32)
return (char*)GetWebButton(index-SET_BUTTON17+16);
-#endif
+#endif // not FIRMWARE_MINIMAL
+#endif // USE_WEBSERVER
position += settings_text_size -1; // Setting not supported - internal error - return empty string
} else {
SettingsUpdateFinished();
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
index 888f7f8fd..a7c391b81 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
@@ -582,10 +582,8 @@ const WebServerDispatch_t WebServerDispatch[] PROGMEM = {
{ "dl", HTTP_ANY, HandleBackupConfiguration },
{ "rs", HTTP_ANY, HandleRestoreConfiguration },
{ "rt", HTTP_ANY, HandleResetConfiguration },
+ { "in", HTTP_ANY, HandleInformation }
#endif // Not FIRMWARE_MINIMAL
-#ifndef FIRMWARE_MINIMAL_ONLY
- { "in", HTTP_ANY, HandleInformation },
-#endif // Not FIRMWARE_MINIMAL_ONLY
};
void WebServer_on(const char * prefix, void (*func)(void), uint8_t method = HTTP_ANY) {
@@ -1521,14 +1519,7 @@ void HandleRoot(void) {
if (HTTP_ADMIN == Web.state) {
#ifdef FIRMWARE_MINIMAL
-#ifdef ESP32
-#ifndef FIRMWARE_MINIMAL_ONLY
- WSContentSpaceButton(BUTTON_INFORMATION);
- WSContentButton(BUTTON_FIRMWARE_UPGRADE);
-#endif // FIRMWARE_MINIMAL_ONLY
-#else // ESP8266
WSContentSpaceButton(BUTTON_FIRMWARE_UPGRADE);
-#endif // ESP32
WSContentButton(BUTTON_CONSOLE);
#else // Not FIRMWARE_MINIMAL
WSContentSpaceButton(BUTTON_CONFIGURATION);
@@ -1912,7 +1903,7 @@ void HandleTemplateConfiguration(void) {
if (!FlashPin(i)) {
WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", template_gp.io[i]);
}
-#endif
+#endif // CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
}
WSContentSend_P(PSTR("}1%d}1%d"), flag, Settings->user_template_base); // FLAG: 1 BASE: 17
WSContentEnd();
@@ -1966,7 +1957,7 @@ void HandleTemplateConfiguration(void) {
RedPin(i) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? PSTR(" style='width:146px'") : "", i, i);
WSContentSend_P(PSTR("
| "), i);
}
-#endif
+#endif // CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
}
WSContentSend_P(PSTR(""));
@@ -2202,7 +2193,7 @@ void HandleWifiConfiguration(void) {
WebRestart(3);
#else
HandleRoot();
-#endif
+#endif // RESTART_AFTER_INITIAL_WIFI_CONFIG
}
}
@@ -2365,7 +2356,7 @@ void HandleWifiConfiguration(void) {
WSContentSend_P(HTTP_FORM_WIFI_PART2, SettingsTextEscaped(SET_STASSID2).c_str(), WIFI_HOSTNAME, WIFI_HOSTNAME, SettingsTextEscaped(SET_HOSTNAME).c_str(), SettingsTextEscaped(SET_CORS).c_str());
#else
WSContentSend_P(HTTP_FORM_WIFI_PART2, SettingsTextEscaped(SET_STASSID2).c_str(), WIFI_HOSTNAME, WIFI_HOSTNAME, SettingsTextEscaped(SET_HOSTNAME).c_str());
-#endif
+#endif // USE_CORS
}
WSContentSend_P(HTTP_FORM_END);
@@ -2400,7 +2391,7 @@ void WifiSaveSettings(void) {
cmnd += AddWebCommand(PSTR(D_CMND_HOSTNAME), PSTR("h"), PSTR("1"));
#ifdef USE_CORS
cmnd += AddWebCommand(PSTR(D_CMND_CORS), PSTR("c"), PSTR("1"));
-#endif
+#endif // USE_CORS
cmnd += AddWebCommand(PSTR(D_CMND_SSID "1"), PSTR("s1"), PSTR("1"));
cmnd += AddWebCommand(PSTR(D_CMND_SSID "2"), PSTR("s2"), PSTR("1"));
cmnd += AddWebCommand(PSTR(D_CMND_PASSWORD "3"), PSTR("p1"), PSTR("\""));
@@ -2617,12 +2608,6 @@ void HandleRestoreConfiguration(void)
Web.upload_file_type = UPL_SETTINGS;
}
-#endif // Not FIRMWARE_MINIMAL
-
-/*-------------------------------------------------------------------------------------------*/
-
-#ifndef FIRMWARE_MINIMAL_ONLY
-
void WSContentSeparatorI(uint32_t size) {
WSContentSend_P(PSTR(" "), (1 == size)?" size=1":"");
// WSContentSend_P(PSTR(" |
"), size);
@@ -2873,7 +2858,8 @@ void HandleInformation(void) {
WSContentSpaceButton(BUTTON_MAIN);
WSContentStop();
}
-#endif // Not FIRMWARE_MINIMAL_ONLY
+
+#endif // Not FIRMWARE_MINIMAL
/*-------------------------------------------------------------------------------------------*/
@@ -2939,7 +2925,7 @@ void HandleUpgradeFirmware(void) {
}
#else
WSContentSend_P(HTTP_FORM_RST_UPG, PSTR(D_START_UPGRADE));
-#endif
+#endif // ESP32
WSContentSpaceButton(BUTTON_MAIN);
WSContentStop();
@@ -3169,7 +3155,7 @@ void HandleUploadLoop(void) {
uint32_t upload_size = (!strlen(tmp)) ? 0 : atoi(tmp);
AddLog(LOG_LEVEL_DEBUG, D_LOG_UPLOAD "Freespace %i Filesize %i", ESP.getFreeSketchSpace(), upload_size);
if (upload_size > ESP.getFreeSketchSpace()) { // TODO revisit this test
-#endif
+#endif // ESP8266
Web.upload_error = 4; // Program flash size is larger than real flash size
return;
}
@@ -3565,6 +3551,8 @@ bool CaptivePortal(void)
/*********************************************************************************************/
+#ifndef FIRMWARE_MINIMAL
+
enum {QUERY_DEFAULT=0, QUERY_RUN};
int WebQuery(char *buffer, int query_function);
@@ -3727,7 +3715,6 @@ int WebQuery(char *buffer, int query_function = 0)
return status;
}
-
int WebSend(char *buffer)
{
// [tasmota] POWER1 ON --> Sends http://tasmota/cm?cmnd=POWER1 ON
@@ -3878,7 +3865,6 @@ const char kWebCmndStatus[] PROGMEM = D_JSON_DONE "|" D_JSON_WRONG_PARAMETERS "|
const char kWebCommands[] PROGMEM = "|" // No prefix
D_CMND_WEBLOG "|"
-#ifndef FIRMWARE_MINIMAL_ONLY
D_CMND_WEBTIME "|"
#ifdef USE_EMULATION
D_CMND_EMULATION "|"
@@ -3897,12 +3883,10 @@ const char kWebCommands[] PROGMEM = "|" // No prefix
#ifdef USE_CORS
"|" D_CMND_CORS
#endif
-#endif // FIRMWARE_MINIMAL_ONLY
;
void (* const WebCommand[])(void) PROGMEM = {
&CmndWeblog,
-#ifndef FIRMWARE_MINIMAL_ONLY
&CmndWebTime,
#ifdef USE_EMULATION
&CmndEmulation,
@@ -3921,7 +3905,6 @@ void (* const WebCommand[])(void) PROGMEM = {
#ifdef USE_CORS
, &CmndCors
#endif
-#endif // FIRMWARE_MINIMAL_ONLY
};
/*********************************************************************************************/
@@ -4174,7 +4157,9 @@ void CmndCors(void)
}
ResponseCmndChar(SettingsText(SET_CORS));
}
-#endif
+#endif // USE_CORS
+
+#endif // not FIRMWARE_MINIMAL
/*********************************************************************************************\
* Interface
@@ -4263,9 +4248,11 @@ bool Xdrv01(uint32_t function)
}
}
break;
+#ifndef FIRMWARE_MINIMAL
case FUNC_COMMAND:
result = DecodeCommand(kWebCommands, WebCommand);
break;
+#endif // FIRMWARE_MINIMAL
case FUNC_ACTIVE:
result = true;
break;
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_06_snfbridge.ino b/tasmota/tasmota_xdrv_driver/xdrv_06_snfbridge.ino
index 19b5b728c..8bbaeef56 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_06_snfbridge.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_06_snfbridge.ino
@@ -512,6 +512,7 @@ void CmndRfTimeout(void) {
}
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
void SonoffBridgeAddButton(void) {
WSContentSend_P(HTTP_TABLE100);
@@ -539,6 +540,7 @@ void SonoffBridgeWebGetArg(void) {
}
}
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
/*********************************************************************************************\
@@ -559,12 +561,14 @@ bool Xdrv06(uint32_t function)
result = DecodeCommand(kSonoffBridgeCommands, SonoffBridgeCommand);
break;
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
case FUNC_WEB_ADD_MAIN_BUTTON:
SonoffBridgeAddButton();
break;
case FUNC_WEB_GET_ARG:
SonoffBridgeWebGetArg();
break;
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
case FUNC_INIT:
if (Settings->rf_duplicate_time < 10) {
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino
index 869bf6141..d4ab71400 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino
@@ -1619,6 +1619,7 @@ void TuyaSensorsShow(bool json)
}
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
#define WEB_HANDLE_TUYA "d16"
@@ -1646,6 +1647,7 @@ void TuyaWebGetArg(void) {
}
}
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
/*********************************************************************************************\
@@ -1735,6 +1737,7 @@ bool Xdrv16(uint32_t function) {
TuyaSensorsShow(1);
break;
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
case FUNC_WEB_ADD_MAIN_BUTTON:
TuyaAddButton();
break;
@@ -1744,6 +1747,7 @@ bool Xdrv16(uint32_t function) {
case FUNC_WEB_SENSOR:
TuyaSensorsShow(0);
break;
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
case FUNC_ACTIVE:
result = true;
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino
index 31b47e286..0684718e2 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino
@@ -2412,6 +2412,7 @@ void TuyaSensorsShow(bool json)
}
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
#define WEB_HANDLE_TUYA "d16"
@@ -2439,6 +2440,7 @@ void TuyaWebGetArg(void) {
}
}
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
/*********************************************************************************************\
@@ -2570,6 +2572,7 @@ bool Xdrv16(uint32_t function) {
TuyaSensorsShow(1);
break;
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
case FUNC_WEB_ADD_MAIN_BUTTON:
TuyaAddButton();
break;
@@ -2579,6 +2582,7 @@ bool Xdrv16(uint32_t function) {
case FUNC_WEB_SENSOR:
TuyaSensorsShow(0);
break;
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
case FUNC_ACTIVE:
result = true;
diff --git a/tasmota/tasmota_xlgt_light/xlgt_07_lsc_mcsl.ino b/tasmota/tasmota_xlgt_light/xlgt_07_lsc_mcsl.ino
index 4270fc665..8bcefb940 100644
--- a/tasmota/tasmota_xlgt_light/xlgt_07_lsc_mcsl.ino
+++ b/tasmota/tasmota_xlgt_light/xlgt_07_lsc_mcsl.ino
@@ -246,6 +246,7 @@ void LscMcModuleSelected(void) {
}
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
#ifdef USE_LSC_MCSL_GUI
void LscMcAddFuctionButtons(void) {
@@ -287,6 +288,7 @@ void LscMcWebGetArg(void) {
}
#endif // USE_LSC_MCSL_GUI
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
@@ -306,6 +308,7 @@ bool Xlgt07(uint32_t function)
result = LscMcMultiButtonPressed();
break;
#ifdef USE_WEBSERVER
+#ifndef FIRMWARE_MINIMAL
#ifdef USE_LSC_MCSL_GUI
case FUNC_WEB_ADD_MAIN_BUTTON:
LscMcAddFuctionButtons();
@@ -314,6 +317,7 @@ bool Xlgt07(uint32_t function)
LscMcWebGetArg();
break;
#endif // USE_LSC_MCSL_GUI
+#endif // not FIRMWARE_MINIMAL
#endif // USE_WEBSERVER
case FUNC_MODULE_INIT:
LscMcModuleSelected();
|