From 9bb322daf8af22cbec3155a9b70ab097fe35c2c8 Mon Sep 17 00:00:00 2001
From: bwynants
Date: Tue, 2 May 2023 15:07:07 +0200
Subject: [PATCH] [OTA] Capability to disable Firmware Update on ESP32 WEB
(#1621)
* disabling Firmware Update on ESP32
---------
Co-authored-by: Bert Wynants
---
environments.ini | 1 +
main/ZwebUI.ino | 5 ++++-
main/config_WebContent.h | 7 +++++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/environments.ini b/environments.ini
index a330d88..5e363e5 100644
--- a/environments.ini
+++ b/environments.ini
@@ -117,6 +117,7 @@ build_flags =
'-DDEEP_SLEEP_IN_US=120000000' ; Deep sleep for a period of time to conserve battery
'-DESP32_EXT0_WAKE_PIN=GPIO_NUM_14' ;Should a water leak be detected immediatly wake the ESP32 and report the problem
'-DESP32_EXT0_WAKE_PIN_STATE=0' ;Should a water leak be detected immediatly wake the ESP32 and report the problem, sensor state to look for wakeup
+ '-UMQTT_HTTPS_FW_UPDATE' ;disable HTTPS firmware updating
[env:esp32dev-rf]
platform = ${com.esp32_platform}
board = esp32dev
diff --git a/main/ZwebUI.ino b/main/ZwebUI.ino
index 0d88558..8268cbf 100644
--- a/main/ZwebUI.ino
+++ b/main/ZwebUI.ino
@@ -1056,6 +1056,7 @@ void handleIN() {
}
}
+# if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE)
/**
* @brief /UP - Firmware Upgrade Page
*
@@ -1121,6 +1122,7 @@ void handleUP() {
response += String(buffer);
server.send(200, "text/html", response);
}
+# endif
void sendRestartPage() {
char jsonChar[100];
@@ -1257,8 +1259,9 @@ void WebUISetup() {
server.on("/in", handleIN); // Information
server.on("/cs", handleCS); // Console
+# if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE)
server.on("/up", handleUP); // Firmware Upgrade
-
+# endif
server.on("/cn", handleCN); // Configuration
server.on("/wi", handleWI); // Configure Wifi
server.on("/mq", handleMQ); // Configure MQTT
diff --git a/main/config_WebContent.h b/main/config_WebContent.h
index 64796d0..ef0f010 100644
--- a/main/config_WebContent.h
+++ b/main/config_WebContent.h
@@ -34,8 +34,11 @@
#define body_footer_config_menu "
"
#define body_header "%s
%s
"
-#define button_upgrade "
"
-
+#if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE)
+# define button_upgrade "
"
+#else
+# define button_upgrade ""
+#endif
// Configuration Menu
#define configure_1 "
"