Allow HTTPS on non-PSRAM devices

This commit is contained in:
iranl
2025-06-19 10:10:32 +02:00
parent da837599d3
commit b5ad96f747
9 changed files with 89 additions and 103 deletions

View File

@@ -709,7 +709,7 @@ If you have enabled "Allow updating using MQTT" you can also use the Home Assist
<br> <br>
Alternatively you can select a binary file from your file system to update Nuki Hub or the Nuki Hub updator manually<br> Alternatively you can select a binary file from your file system to update Nuki Hub or the Nuki Hub updator manually<br>
You can only update Nuki Hub from the Nuki Hub updater and update the updater only from Nuki Hub<br> You can only update Nuki Hub from the Nuki Hub updater and update the updater only from Nuki Hub<br>
You can reboot from Nuki Hub to the updater and vice versa by selecting the reboot option from the "Firware update" page<br> You can reboot from Nuki Hub to the updater and vice versa by selecting the reboot option from the "Firmware update" page<br>
When you are on the right application you can upload the new binary by clicking on "Browse" and select the new "nuki_hub\[board\].bin" or "nuki_hub_updater\[board\].bin" file and select "Upload file".<br> When you are on the right application you can upload the new binary by clicking on "Browse" and select the new "nuki_hub\[board\].bin" or "nuki_hub_updater\[board\].bin" file and select "Upload file".<br>
After about a minute the new firmware should be installed afterwhich the ESP will reboot automatically to the updated binary.<br> After about a minute the new firmware should be installed afterwhich the ESP will reboot automatically to the updated binary.<br>
Selecting the wrong binary will lead to an unsuccessfull update<br> Selecting the wrong binary will lead to an unsuccessfull update<br>

View File

@@ -75,6 +75,7 @@ extra_scripts =
build_flags = build_flags =
${env.build_flags} ${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
-DNUKI_HUB_HTTPS_SERVER
[env:esp32-gl-s10] [env:esp32-gl-s10]
extends = env:esp32 extends = env:esp32
@@ -90,6 +91,9 @@ extends = env:esp32
board = esp32-c3-devkitc-02 board = esp32-c3-devkitc-02
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.singlecore.defaults" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.singlecore.defaults"
build_flags =
${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
[env:esp32-s3] [env:esp32-s3]
extends = env:esp32 extends = env:esp32
@@ -102,7 +106,7 @@ extends = env:esp32
board = nuki-esp32-s3-oct board = nuki-esp32-s3-oct
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32-s3-oct" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32-s3-oct"
[env:esp32-c5] [env:esp32-c5]
extends = env:esp32 extends = env:esp32
board_build.partitions = partitions_c5.csv board_build.partitions = partitions_c5.csv
@@ -115,6 +119,10 @@ extends = env:esp32
board = esp32-c6-devkitm-1 board = esp32-c6-devkitm-1
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.singlecore.defaults" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.singlecore.defaults"
build_flags =
${env:esp32.build_flags}
-DNUKI_HUB_HTTPS_SERVER
-DFORCE_NUKI_HUB_HTTPS_SERVER
[env:esp32-h2] [env:esp32-h2]
extends = env:esp32 extends = env:esp32
@@ -131,12 +139,18 @@ lib_ignore =
ESPAsyncTCP-esphome ESPAsyncTCP-esphome
AsyncTCP_RP2040W AsyncTCP_RP2040W
WiFiManager WiFiManager
build_flags =
${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
[env:esp32-solo1] [env:esp32-solo1]
extends = env:esp32 extends = env:esp32
board = nuki-esp32solo1 board = nuki-esp32solo1
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.singlecore.defaults;sdkconfig.defaults.esp32-solo1" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.singlecore.defaults;sdkconfig.defaults.esp32-solo1"
build_flags =
${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
[env:esp32-p4] [env:esp32-p4]
extends = env:esp32 extends = env:esp32
@@ -144,9 +158,6 @@ board_build.embed_txtfiles =
board = esp32-p4 board = esp32-p4
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32-p4" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32-p4"
build_flags =
${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
[env:esp32_dbg] [env:esp32_dbg]
extends = env:esp32 extends = env:esp32
@@ -157,6 +168,7 @@ build_flags =
${env.build_flags} ${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DDEBUG_NUKIHUB -DDEBUG_NUKIHUB
-DNUKI_HUB_HTTPS_SERVER
[env:esp32-gl-s10_dbg] [env:esp32-gl-s10_dbg]
extends = env:esp32-gl-s10 extends = env:esp32-gl-s10
@@ -185,9 +197,7 @@ custom_build = debug
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-c5;sdkconfig.defaults.esp32-c5dbg;sdkconfig.singlecore.defaults" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-c5;sdkconfig.defaults.esp32-c5dbg;sdkconfig.singlecore.defaults"
build_flags = build_flags =
${env.build_flags} ${env:esp32_dbg.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DDEBUG_NUKIHUB
[env:esp32-c6_dbg] [env:esp32-c6_dbg]
extends = env:esp32-c6 extends = env:esp32-c6
@@ -195,9 +205,8 @@ custom_build = debug
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.singlecore.defaults" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.singlecore.defaults"
build_flags = build_flags =
${env.build_flags} ${env:esp32_dbg.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DFORCE_NUKI_HUB_HTTPS_SERVER
-DDEBUG_NUKIHUB
[env:esp32-h2_dbg] [env:esp32-h2_dbg]
extends = env:esp32-h2 extends = env:esp32-h2
@@ -216,9 +225,7 @@ custom_build = debug
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-s3" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-s3"
build_flags = build_flags =
${env.build_flags} ${env:esp32_dbg.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DDEBUG_NUKIHUB
[env:esp32-s3-oct_dbg] [env:esp32-s3-oct_dbg]
extends = env:esp32-s3-oct extends = env:esp32-s3-oct
@@ -226,9 +233,7 @@ custom_build = debug
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-s3-oct" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-s3-oct"
build_flags = build_flags =
${env.build_flags} ${env:esp32_dbg.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DDEBUG_NUKIHUB
[env:esp32-solo1_dbg] [env:esp32-solo1_dbg]
extends = env:esp32-solo1 extends = env:esp32-solo1
@@ -246,6 +251,4 @@ custom_build = debug
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-p4" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32-p4"
build_flags = build_flags =
${env.build_flags} ${env:esp32_dbg.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DDEBUG_NUKIHUB

View File

@@ -5,7 +5,7 @@
#define NUKI_HUB_VERSION "9.11" #define NUKI_HUB_VERSION "9.11"
#define NUKI_HUB_VERSION_INT (uint32_t)911 #define NUKI_HUB_VERSION_INT (uint32_t)911
#define NUKI_HUB_BUILD "unknownbuildnr" #define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2025-06-18" #define NUKI_HUB_DATE "2025-06-19"
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"

View File

@@ -9,6 +9,8 @@
#include "esp_random.h" #include "esp_random.h"
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED #ifdef CONFIG_SOC_SPIRAM_SUPPORTED
#include "esp_psram.h" #include "esp_psram.h"
#endif
#ifdef NUKI_HUB_HTTPS_SERVER
#include "util/SSLCert.hpp" #include "util/SSLCert.hpp"
#endif #endif
#ifndef CONFIG_IDF_TARGET_ESP32H2 #ifndef CONFIG_IDF_TARGET_ESP32H2
@@ -2697,8 +2699,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S
} }
} }
} }
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED else if(key == "HTTPCRT" && nuki_hub_https_server_enabled)
else if(key == "HTTPCRT")
{ {
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
Log->println("SPIFFS Mount Failed"); Log->println("SPIFFS Mount Failed");
@@ -2734,7 +2735,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S
} }
} }
} }
else if(key == "HTTPKEY") else if(key == "HTTPKEY" && nuki_hub_https_server_enabled)
{ {
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
Log->println("SPIFFS Mount Failed"); Log->println("SPIFFS Mount Failed");
@@ -2770,14 +2771,15 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S
} }
} }
} }
else if(key == "HTTPGEN") else if(key == "HTTPGEN" && nuki_hub_https_server_enabled)
{ {
#ifdef NUKI_HUB_HTTPS_SERVER
createSSLCertificate(); createSSLCertificate();
#endif
Log->print("Setting changed: "); Log->print("Setting changed: ");
Log->println(key); Log->println(key);
configChanged = true; configChanged = true;
} }
#endif
else if(key == "UPTIME") else if(key == "UPTIME")
{ {
if(_preferences->getBool(preference_update_time, false) != (value == "1")) if(_preferences->getBool(preference_update_time, false) != (value == "1"))
@@ -4809,12 +4811,10 @@ esp_err_t WebCfgServer::buildImportExportHtml(PsychicRequest *request, PsychicRe
response.print("<button title=\"Basic export\" onclick=\" window.open('/get?page=export', '_self'); return false;\">Basic export</button>"); response.print("<button title=\"Basic export\" onclick=\" window.open('/get?page=export', '_self'); return false;\">Basic export</button>");
response.print("<br><br><button title=\"Export with redacted settings\" onclick=\" window.open('/get?page=export&redacted=1'); return false;\">Export with redacted settings</button>"); response.print("<br><br><button title=\"Export with redacted settings\" onclick=\" window.open('/get?page=export&redacted=1'); return false;\">Export with redacted settings</button>");
response.print("<br><br><button title=\"Export with redacted settings and pairing data\" onclick=\" window.open('/get?page=export&redacted=1&pairing=1'); return false;\">Export with redacted settings and pairing data</button>"); response.print("<br><br><button title=\"Export with redacted settings and pairing data\" onclick=\" window.open('/get?page=export&redacted=1&pairing=1'); return false;\">Export with redacted settings and pairing data</button>");
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED if(nuki_hub_https_server_enabled)
if(esp_psram_get_size() > 0)
{ {
response.print("<br><br><button title=\"Export HTTP SSL certificate and key\" onclick=\" window.open('/get?page=export&type=https'); return false;\">Export HTTP SSL certificate and key</button>"); response.print("<br><br><button title=\"Export HTTP SSL certificate and key\" onclick=\" window.open('/get?page=export&type=https'); return false;\">Export HTTP SSL certificate and key</button>");
} }
#endif
response.print("<br><br><button title=\"Export MQTT SSL CA, client certificate and client key\" onclick=\" window.open('/get?page=export&type=mqtts'); return false;\">Export MQTT SSL CA, client certificate and client key</button>"); response.print("<br><br><button title=\"Export MQTT SSL CA, client certificate and client key\" onclick=\" window.open('/get?page=export&type=mqtts'); return false;\">Export MQTT SSL CA, client certificate and client key</button>");
response.print("<br><br><button title=\"Export Coredump\" onclick=\" window.open('/get?page=coredump'); return false;\">Export Coredump</button>"); response.print("<br><br><button title=\"Export Coredump\" onclick=\" window.open('/get?page=coredump'); return false;\">Export Coredump</button>");
response.print("</div></body></html>"); response.print("</div></body></html>");
@@ -5121,15 +5121,13 @@ esp_err_t WebCfgServer::buildNetworkConfigHtml(PsychicRequest *request, PsychicR
printCheckBox(&response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect), ""); printCheckBox(&response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect), "");
printCheckBox(&response, "CHECKUPDATE", "Check for Firmware Updates every 24h", _preferences->getBool(preference_check_updates), ""); printCheckBox(&response, "CHECKUPDATE", "Check for Firmware Updates every 24h", _preferences->getBool(preference_check_updates), "");
printCheckBox(&response, "FINDBESTRSSI", "Find WiFi AP with strongest signal", _preferences->getBool(preference_find_best_rssi, false), ""); printCheckBox(&response, "FINDBESTRSSI", "Find WiFi AP with strongest signal", _preferences->getBool(preference_find_best_rssi, false), "");
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED if(nuki_hub_https_server_enabled)
if(esp_psram_get_size() > 0)
{ {
response.print("<tr><td>Set HTTP SSL Certificate</td><td><button title=\"Set HTTP SSL Certificate\" onclick=\" window.open('/get?page=httpcrtconfig', '_self'); return false;\">Change</button></td></tr>"); response.print("<tr><td>Set HTTP SSL Certificate</td><td><button title=\"Set HTTP SSL Certificate\" onclick=\" window.open('/get?page=httpcrtconfig', '_self'); return false;\">Change</button></td></tr>");
response.print("<tr><td>Set HTTP SSL Key</td><td><button title=\"Set HTTP SSL Key\" onclick=\" window.open('/get?page=httpkeyconfig', '_self'); return false;\">Change</button></td></tr>"); response.print("<tr><td>Set HTTP SSL Key</td><td><button title=\"Set HTTP SSL Key\" onclick=\" window.open('/get?page=httpkeyconfig', '_self'); return false;\">Change</button></td></tr>");
response.print("<tr><td>Generate self-signed HTTP SSL Certificate and key</td><td><button title=\"Generate HTTP SSL Certificate and key\" onclick=\" window.open('/get?page=selfsignhttps', '_self'); return false;\">Generate</button></td></tr>"); response.print("<tr><td>Generate self-signed HTTP SSL Certificate and key</td><td><button title=\"Generate HTTP SSL Certificate and key\" onclick=\" window.open('/get?page=selfsignhttps', '_self'); return false;\">Generate</button></td></tr>");
printInputField(&response, "HTTPSFQDN", "Nuki Hub FQDN for HTTP redirect", _preferences->getString(preference_https_fqdn, "").c_str(), 255, ""); printInputField(&response, "HTTPSFQDN", "Nuki Hub FQDN for HTTP redirect", _preferences->getString(preference_https_fqdn, "").c_str(), 255, "");
} }
#endif
response.print("</table>"); response.print("</table>");
response.print("<h3>IP Address assignment</h3>"); response.print("<h3>IP Address assignment</h3>");
response.print("<table>"); response.print("<table>");
@@ -5326,7 +5324,6 @@ esp_err_t WebCfgServer::buildHttpSSLConfigHtml(PsychicRequest *request, PsychicR
{ {
bool found = false; bool found = false;
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
Log->println("SPIFFS Mount Failed"); Log->println("SPIFFS Mount Failed");
} }
@@ -5350,7 +5347,7 @@ esp_err_t WebCfgServer::buildHttpSSLConfigHtml(PsychicRequest *request, PsychicR
found = true; found = true;
} }
} }
#endif
if (!found) if (!found)
{ {
printTextarea(&response, "HTTPCRT", "HTTP SSL Certificate (*, optional)", "", 4400, true, true); printTextarea(&response, "HTTPCRT", "HTTP SSL Certificate (*, optional)", "", 4400, true, true);
@@ -5360,7 +5357,6 @@ esp_err_t WebCfgServer::buildHttpSSLConfigHtml(PsychicRequest *request, PsychicR
{ {
bool found = false; bool found = false;
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
Log->println("SPIFFS Mount Failed"); Log->println("SPIFFS Mount Failed");
} }
@@ -5384,7 +5380,7 @@ esp_err_t WebCfgServer::buildHttpSSLConfigHtml(PsychicRequest *request, PsychicR
found = true; found = true;
} }
} }
#endif
if (!found) if (!found)
{ {
printTextarea(&response, "HTTPKEY", "HTTP SSL Key (*, optional)", "", 2200, true, true); printTextarea(&response, "HTTPKEY", "HTTP SSL Key (*, optional)", "", 2200, true, true);
@@ -5941,7 +5937,7 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse*
response.print(ESP.getFreeHeap()); response.print(ESP.getFreeHeap());
response.print("\nTotal internal heap: "); response.print("\nTotal internal heap: ");
response.print(ESP.getHeapSize()); response.print(ESP.getHeapSize());
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED #ifdef CONFIG_SOC_SPIRAM_SUPPORTED
if(esp_psram_get_size() > 0) if(esp_psram_get_size() > 0)
{ {
response.print("\nPSRAM Available: Yes"); response.print("\nPSRAM Available: Yes");
@@ -5958,9 +5954,9 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse*
{ {
response.print("\nPSRAM Available: No"); response.print("\nPSRAM Available: No");
} }
#else #else
response.print("\nPSRAM Available: No"); response.print("\nPSRAM Available: No");
#endif #endif
response.print("\nNetwork task stack high watermark: "); response.print("\nNetwork task stack high watermark: ");
response.print(uxTaskGetStackHighWaterMark(networkTaskHandle)); response.print(uxTaskGetStackHighWaterMark(networkTaskHandle));
response.print("\nNuki task stack high watermark: "); response.print("\nNuki task stack high watermark: ");
@@ -6028,30 +6024,19 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse*
response.print("\nWeb configurator enabled: "); response.print("\nWeb configurator enabled: ");
response.print(_preferences->getBool(preference_webserver_enabled, true) ? "Yes" : "No"); response.print(_preferences->getBool(preference_webserver_enabled, true) ? "Yes" : "No");
response.print("\nHTTP SSL: "); response.print("\nHTTP SSL: ");
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED if (!SPIFFS.begin(true) || !nuki_hub_https_server_enabled) {
if(esp_psram_get_size() > 0) response.print("Disabled");
{
if (!SPIFFS.begin(true)) {
response.print("Disabled");
}
else
{
File file = SPIFFS.open("/http_ssl.crt");
File file2 = SPIFFS.open("/http_ssl.key");
response.print((!file || file.isDirectory() || !file2 || file2.isDirectory()) ? "Disabled" : "Enabled");
file.close();
file2.close();
response.print("\nNuki Hub FQDN for HTTP redirect: ");
response.print(_preferences->getString(preference_https_fqdn, "").length() > 0 ? "***" : "Not set");
}
} }
else else
{ {
response.print("Disabled"); File file = SPIFFS.open("/http_ssl.crt");
File file2 = SPIFFS.open("/http_ssl.key");
response.print((!file || file.isDirectory() || !file2 || file2.isDirectory()) ? "Disabled" : "Enabled");
file.close();
file2.close();
response.print("\nNuki Hub FQDN for HTTP redirect: ");
response.print(_preferences->getString(preference_https_fqdn, "").length() > 0 ? "***" : "Not set");
} }
#else
response.print("Disabled");
#endif
response.print("\nAdvanced menu enabled: "); response.print("\nAdvanced menu enabled: ");
response.print(_preferences->getBool(preference_enable_debug_mode, false) ? "Yes" : "No"); response.print(_preferences->getBool(preference_enable_debug_mode, false) ? "Yes" : "No");
response.print("\nPublish free heap over MQTT: "); response.print("\nPublish free heap over MQTT: ");
@@ -7052,7 +7037,7 @@ const String WebCfgServer::getPreselectionForGpio(const uint8_t &pin) const
return String((int8_t)PinRole::Disabled); return String((int8_t)PinRole::Disabled);
} }
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED #ifdef NUKI_HUB_HTTPS_SERVER
void WebCfgServer::createSSLCertificate() void WebCfgServer::createSSLCertificate()
{ {
SSLCert* cert; SSLCert* cert;

View File

@@ -18,6 +18,7 @@
#include "ImportExport.h" #include "ImportExport.h"
extern TaskHandle_t nukiTaskHandle; extern TaskHandle_t nukiTaskHandle;
extern bool nuki_hub_https_server_enabled;
enum class TokenType enum class TokenType
{ {
@@ -86,7 +87,7 @@ private:
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32P4) #if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32P4)
const std::vector<std::pair<String, String>> getNetworkCustomCLKOptions() const; const std::vector<std::pair<String, String>> getNetworkCustomCLKOptions() const;
#endif #endif
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED #ifdef NUKI_HUB_HTTPS_SERVER
void createSSLCertificate(); void createSSLCertificate();
#endif #endif
const String getPreselectionForGpio(const uint8_t& pin) const; const String getPreselectionForGpio(const uint8_t& pin) const;

View File

@@ -9,7 +9,7 @@ dependencies:
espressif/libsodium: "^1.0.20~2" espressif/libsodium: "^1.0.20~2"
espressif/esp_hosted: espressif/esp_hosted:
version: "*" version: 2.0.10
rules: rules:
- if: "target in [esp32p4]" - if: "target in [esp32p4]"

View File

@@ -15,6 +15,11 @@
#include "FS.h" #include "FS.h"
#include "SPIFFS.h" #include "SPIFFS.h"
//#include <ESPmDNS.h> //#include <ESPmDNS.h>
#ifdef NUKI_HUB_HTTPS_SERVER
bool nuki_hub_https_server_enabled = true;
#else
bool nuki_hub_https_server_enabled = false;
#endif
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED #ifdef CONFIG_SOC_SPIRAM_SUPPORTED
#include "esp_psram.h" #include "esp_psram.h"
#endif #endif
@@ -249,24 +254,20 @@ void cbSyncTime(struct timeval *tv) {
#ifndef NUKI_HUB_UPDATER #ifndef NUKI_HUB_UPDATER
void startWebServer() void startWebServer()
{ {
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED bool failed = true;
bool failed = false;
if (esp_psram_get_size() <= 0) { if (!nuki_hub_https_server_enabled) {
Log->println("Not running on PSRAM enabled device"); Log->println("Not running on PSRAM enabled device");
failed = true;
} }
else else
{ {
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
Log->println("SPIFFS Mount Failed"); Log->println("SPIFFS Mount Failed");
failed = true;
} }
else else
{ {
File file = SPIFFS.open("/http_ssl.crt"); File file = SPIFFS.open("/http_ssl.crt");
if (!file || file.isDirectory()) { if (!file || file.isDirectory()) {
failed = true;
Log->println("http_ssl.crt not found"); Log->println("http_ssl.crt not found");
} }
else else
@@ -281,7 +282,6 @@ void startWebServer()
File file2 = SPIFFS.open("/http_ssl.key"); File file2 = SPIFFS.open("/http_ssl.key");
if (!file2 || file2.isDirectory()) { if (!file2 || file2.isDirectory()) {
failed = true;
Log->println("http_ssl.key not found"); Log->println("http_ssl.key not found");
} }
else else
@@ -319,6 +319,7 @@ void startWebServer()
}); });
psychicSSLServer->begin(); psychicSSLServer->begin();
webSSLStarted = true; webSSLStarted = true;
failed = false;
} }
} }
} }
@@ -326,7 +327,6 @@ void startWebServer()
if (failed) if (failed)
{ {
#endif
psychicServer = new PsychicHttpServer; psychicServer = new PsychicHttpServer;
psychicServer->config.stack_size = HTTPD_TASK_SIZE; psychicServer->config.stack_size = HTTPD_TASK_SIZE;
webCfgServer = new WebCfgServer(nuki, nukiOpener, network, gpio, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer, importExport); webCfgServer = new WebCfgServer(nuki, nukiOpener, network, gpio, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer, importExport);
@@ -336,9 +336,7 @@ void startWebServer()
}); });
psychicServer->begin(); psychicServer->begin();
webStarted = true; webStarted = true;
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
} }
#endif
} }
void startNuki(bool lock) void startNuki(bool lock)
@@ -1042,6 +1040,15 @@ void logCoreDump()
void setup() void setup()
{ {
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
#ifndef FORCE_NUKI_HUB_HTTPS_SERVER
if(esp_psram_get_size() <= 0)
{
nuki_hub_https_server_enabled = false;
}
#endif
#endif
//Set Log level to error for all TAGS //Set Log level to error for all TAGS
esp_log_level_set("*", ESP_LOG_ERROR); esp_log_level_set("*", ESP_LOG_ERROR);
//Set Log level to none for mqtt TAG //Set Log level to none for mqtt TAG
@@ -1050,14 +1057,13 @@ void setup()
Serial.begin(115200); Serial.begin(115200);
Log = &Serial; Log = &Serial;
#if !defined(NUKI_HUB_UPDATER) && !defined(CONFIG_IDF_TARGET_ESP32C5) #if !defined(NUKI_HUB_UPDATER) && !defined(CONFIG_IDF_TARGET_ESP32C5)
//
stdout = funopen(NULL, NULL, &write_fn, NULL, NULL); stdout = funopen(NULL, NULL, &write_fn, NULL, NULL);
static char linebuf[1024]; static char linebuf[1024];
setvbuf(stdout, linebuf, _IOLBF, sizeof(linebuf)); setvbuf(stdout, linebuf, _IOLBF, sizeof(linebuf));
esp_rom_install_channel_putc(1, &ets_putc_handler); esp_rom_install_channel_putc(1, &ets_putc_handler);
//ets_install_putc1(&ets_putc_handler); //ets_install_putc1(&ets_putc_handler);
#endif #endif
preferences = new Preferences(); preferences = new Preferences();
preferences->begin("nukihub", false); preferences->begin("nukihub", false);
@@ -1121,24 +1127,20 @@ void setup()
if(!doOta) if(!doOta)
{ {
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED bool failed = true;
bool failed = false;
if (esp_psram_get_size() <= 0) { if (!nuki_hub_https_server_enabled) {
Log->println("Not running on PSRAM enabled device"); Log->println("Not running on HTTPS server enabled device");
failed = true;
} }
else else
{ {
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
Log->println("SPIFFS Mount Failed"); Log->println("SPIFFS Mount Failed");
failed = true;
} }
else else
{ {
File file = SPIFFS.open("/http_ssl.crt"); File file = SPIFFS.open("/http_ssl.crt");
if (!file || file.isDirectory()) { if (!file || file.isDirectory()) {
failed = true;
Log->println("http_ssl.crt not found"); Log->println("http_ssl.crt not found");
} }
else else
@@ -1153,7 +1155,6 @@ void setup()
File file2 = SPIFFS.open("/http_ssl.key"); File file2 = SPIFFS.open("/http_ssl.key");
if (!file2 || file2.isDirectory()) { if (!file2 || file2.isDirectory()) {
failed = true;
Log->println("http_ssl.key not found"); Log->println("http_ssl.key not found");
} }
else else
@@ -1191,6 +1192,7 @@ void setup()
}); });
psychicSSLServer->begin(); psychicSSLServer->begin();
webSSLStarted = true; webSSLStarted = true;
failed = false;
} }
} }
} }
@@ -1198,7 +1200,6 @@ void setup()
if (failed) if (failed)
{ {
#endif
psychicServer = new PsychicHttpServer; psychicServer = new PsychicHttpServer;
psychicServer->config.stack_size = HTTPD_TASK_SIZE; psychicServer->config.stack_size = HTTPD_TASK_SIZE;
webCfgServer = new WebCfgServer(network, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer, importExport); webCfgServer = new WebCfgServer(network, preferences, network->networkDeviceType() == NetworkDeviceType::WiFi, partitionType, psychicServer, importExport);
@@ -1208,9 +1209,7 @@ void setup()
}); });
psychicServer->begin(); psychicServer->begin();
webStarted = true; webStarted = true;
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
} }
#endif
} }
#else #else
if(preferences->getBool(preference_enable_bootloop_reset, false)) if(preferences->getBool(preference_enable_bootloop_reset, false))

View File

@@ -7,20 +7,9 @@
#include "SPIFFS.h" #include "SPIFFS.h"
#include "../MqttTopics.h" #include "../MqttTopics.h"
#include "PreferencesKeys.h" #include "PreferencesKeys.h"
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
#include "esp_psram.h"
#endif
void NetworkDevice::init() void NetworkDevice::init()
{ {
#ifdef CONFIG_SOC_SPIRAM_SUPPORTED
if(esp_psram_get_size() > 0)
{
//_mqttInternal = true;
_mqttInternal = false;
}
#endif
if(_preferences->getBool(preference_mqtt_ssl_enabled, false)) { if(_preferences->getBool(preference_mqtt_ssl_enabled, false)) {
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
Log->println("SPIFFS Mount Failed"); Log->println("SPIFFS Mount Failed");

View File

@@ -66,6 +66,9 @@ extra_scripts =
post:pio_package_post.py post:pio_package_post.py
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32"
build_flags =
${env.build_flags}
-DNUKI_HUB_HTTPS_SERVER
[env:updater_esp32-gl-s10] [env:updater_esp32-gl-s10]
extends = env:updater_esp32 extends = env:updater_esp32
@@ -73,12 +76,14 @@ board = nuki-esp32gls10
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32;sdkconfig.gls10.defaults" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32;sdkconfig.gls10.defaults"
build_flags = build_flags =
${env.build_flags} ${env:updater_esp32.build_flags}
-DNUKI_TARGET_GL_S10=y -DNUKI_TARGET_GL_S10=y
[env:updater_esp32-c3] [env:updater_esp32-c3]
extends = env:updater_esp32 extends = env:updater_esp32
board = esp32-c3-devkitc-02 board = esp32-c3-devkitc-02
build_flags =
${env.build_flags}
[env:updater_esp32-s3] [env:updater_esp32-s3]
extends = env:updater_esp32 extends = env:updater_esp32
@@ -95,10 +100,13 @@ board_build.cmake_extra_args =
[env:updater_esp32-c6] [env:updater_esp32-c6]
extends = env:updater_esp32 extends = env:updater_esp32
board = esp32-c6-devkitm-1 board = esp32-c6-devkitm-1
build_flags =
${env:updater_esp32.build_flags}
-DFORCE_NUKI_HUB_HTTPS_SERVER
[env:updater_esp32-c5] [env:updater_esp32-c5]
board_build.partitions = partitions_c5.csv
extends = env:updater_esp32 extends = env:updater_esp32
board_build.partitions = partitions_c5.csv
board = nuki-esp32-c5 board = nuki-esp32-c5
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-c5" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-c5"
@@ -109,18 +117,19 @@ board_build.embed_txtfiles =
board = esp32-p4 board = esp32-p4
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-p4" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-p4"
build_flags =
${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
[env:updater_esp32-h2] [env:updater_esp32-h2]
extends = env:updater_esp32 extends = env:updater_esp32
board = esp32-h2-devkitm-1 board = esp32-h2-devkitm-1
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DNUKI_TARGET_H2=y -DNUKI_TARGET_H2=y
build_flags =
${env.build_flags}
[env:updater_esp32-solo1] [env:updater_esp32-solo1]
extends = env:updater_esp32 extends = env:updater_esp32
board = nuki-esp32solo1 board = nuki-esp32solo1
board_build.cmake_extra_args = board_build.cmake_extra_args =
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-solo1" -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-solo1"
build_flags =
${env.build_flags}