From e708be14334ce064e8dad121d6e76e33a6a38ec0 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 21 Mar 2025 21:42:42 +0100 Subject: [PATCH 01/15] Arduino 3.2.0-RC2 and P4 builds --- .github/workflows/beta.yml | 3 +-- .github/workflows/build.yml | 3 +-- .github/workflows/nightly.yml | 3 +-- .github/workflows/release.yml | 3 +-- platformio.ini | 2 +- src/idf_component.yml | 2 +- updater/platformio.ini | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index db11241..8a3723d 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -12,8 +12,7 @@ jobs: strategy: fail-fast: false matrix: - #board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] - board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] build: [release] env: BOARD: ${{ matrix.board }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5728308..6c03299 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,7 @@ jobs: strategy: fail-fast: false matrix: - #board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] - board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] build: [release] env: BOARD: ${{ matrix.board }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f493baf..8a607bf 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -34,8 +34,7 @@ jobs: strategy: fail-fast: false matrix: - #board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] - board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] build: [release] env: BOARD: ${{ matrix.board }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 953a8a2..1c25a80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,8 +12,7 @@ jobs: strategy: fail-fast: false matrix: - #board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] - board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10] + board: [esp32, esp32-s3, esp32-s3-oct, esp32-c3, esp32-c6, esp32-h2, esp32-solo1, esp32-gl-s10, esp32-p4] build: [release] env: BOARD: ${{ matrix.board }} diff --git a/platformio.ini b/platformio.ini index 0b7fa51..22a8574 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,7 +13,7 @@ default_envs = esp32 boards_dir = boards [env] -platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.13/platform-espressif32.zip +platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc2/platform-espressif32.zip platform_packages = framework = arduino, espidf board_build.embed_txtfiles = diff --git a/src/idf_component.yml b/src/idf_component.yml index d174900..21eb4e5 100644 --- a/src/idf_component.yml +++ b/src/idf_component.yml @@ -4,7 +4,7 @@ dependencies: esp-nimble-cpp: git: https://github.com/h2zero/esp-nimble-cpp.git - version: 88c5d0c7b7cadb1fa328dbfa80eb14f7f4cc9e52 + version: 723cdf0a66587bba30c8694b38267a91a530f024 espressif/libsodium: "^1.0.20~2" diff --git a/updater/platformio.ini b/updater/platformio.ini index 66f12cf..3c49ee6 100644 --- a/updater/platformio.ini +++ b/updater/platformio.ini @@ -13,7 +13,7 @@ default_envs = updater_esp32 boards_dir = ../boards [env] -platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.13/platform-espressif32.zip +platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc2/platform-espressif32.zip platform_packages = framework = arduino, espidf board_build.embed_txtfiles = From a3de0741316e66c292d859651fdaafe484676d1e Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 21 Mar 2025 21:50:18 +0100 Subject: [PATCH 02/15] Nuki Lock 5th Gen (Pro/Go) support --- HYBRID.md | 6 +++--- README.md | 24 ++++++++++++++---------- src/WebCfgServer.cpp | 10 +++++----- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/HYBRID.md b/HYBRID.md index f79b99b..4906a47 100644 --- a/HYBRID.md +++ b/HYBRID.md @@ -22,13 +22,13 @@ In hybrid mode Nuki Hub will automatically choose the best way to communicate wi When compared to regular/bridge mode this leads to speed increases in getting state changes and pushing state changes (because we can send and receive usefull information directly over MQTT without having to connect over BLE) When compared to the official MQTT implementation this adds many many features that are not available in the official MQTT implementation and would normally require you to use the app or Web API (which has its own issues, downtime and cloud requirement). -**As the Nuki Smartlock Ultra has no support for the Nuki Bridge it is mandatory to setup Hybrid mode to receive prompt state changes from the lock in Nuki Hub.** +**As the Nuki Smartlock Ultra/5th gen Pro has no support for the Nuki Bridge it is mandatory to setup Hybrid mode to receive prompt state changes from the lock in Nuki Hub.** ### Requirements ### - ESP32 running Nuki Hub 9.08 or higher -- For WiFi: Nuki lock 3.0 Pro, Nuki Lock 4.0 Pro or Nuki Lock Ultra -- For Thread: Nuki Lock 4.0, Nuki Lock 4.0 Pro or Nuki Lock Ultra. Note that you do ***NOT*** need to buy the remote access addon for the Nuki Lock 4.0 +- For WiFi: Nuki lock 3.0 Pro, Nuki Lock 4.0 Pro, Nuki Lock 5.0 Pro, Nuki Lock Go or Nuki Lock Ultra +- For Thread: Nuki Lock 4.0, Nuki Lock 4.0 Pro, Nuki Lock 5.0 Pro, Nuki Lock Go or Nuki Lock Ultra. Note that you do ***NOT*** need to buy the remote access addon for the Nuki Lock 4.0 or Nuki Lock Go - For Thread: The Nuki Lock needs to have network access to the same MQTT server as the one that Nuki Hub is conected to. Depending if the MQTT server is reachable over IPv6 you might need an OpenThread Border router that supports NAT64 and has this enabled. Currently this means an Apple Device or Home Assistant with the Matter server and OpenThread Border Router - The Nuki Opener does not have WiFI or Thread and thus doesn't benefit from the hybrid solutions added speed. You can however use and connect a Nuki Opener as usual which will function over regular BLE and can still connect Nuki Hub as a bridge to an Opener. diff --git a/README.md b/README.md index 9504260..22a6422 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ Feel free to join us on Discord: https://discord.gg/9nPq85bP4p - Nuki Keypad 1.0 - Nuki Keypad 2.0 +Probably supported Nuki devices (untested): +- Nuki Smart Lock 5.0 Pro +- Nuki Smart Lock Go + Supported Ethernet devices:
As an alternative to Wi-Fi (which is available on any supported ESP32), the following ESP32 modules with built-in wired ethernet are supported: - [Olimex ESP32-POE](https://www.olimex.com/Products/IoT/ESP32/ESP32-POE/open-source-hardware) @@ -161,21 +165,21 @@ MQTT nodes like lock state and battery level should now reflect the reported val This is not recommended (unless when using [hybrid mode](/HYBRID.md)) and will lead to excessive battery drain and can lead to either device missing updates. Enable "Register as app" before pairing to allow this. Otherwise the Bridge will be unregistered when pairing the Nuki Hub. -## Pairing with a Nuki Lock Ultra +## Pairing with a Nuki Lock Ultra / 5th gen Pro Make sure "Bluetooth pairing" is enabled for the Nuki device by enabling this setting in the official Nuki App in "Settings" > "Features & Configuration" > "Button and LED". -Before enabling pairing mode using the button on the Lock Ultra first setup Nuki Hub as follows: -- Enable both "Nuki Smartlock enabled" and "Nuki Smartlock Ultra enabled" settings on the "Basic Nuki Configuration" page and Save. Setting the "Nuki Smartlock Ultra enabled" will change multiple other NukiHub settings. -- Input your 6-digit Nuki Lock Ultra PIN on the "Credentials" page and Save +Before enabling pairing mode using the button on the Lock Ultra / 5th gen Pro first setup Nuki Hub as follows: +- Enable both "Nuki Smartlock enabled" and "Nuki Smartlock Ultra/5th gen enabled" settings on the "Basic Nuki Configuration" page and Save. Setting the "Nuki Smartlock Ultra/5th gen enabled" will change multiple other NukiHub settings. +- Input your 6-digit Nuki Lock Ultra/5th gen PIN on the "Credentials" page and Save - Press the button on the Nuki device for a few seconds until the LED ring lights up and remains lit. -- It is **strongly** recommended(/mandatory) to setup and enable Hybrid mode over Thread/WiFi + official MQTT as Nuki Hub works best in Hybrid or Bridge mode and the Ultra does not support Bridge mode +- It is **strongly** recommended(/mandatory) to setup and enable Hybrid mode over Thread/WiFi + official MQTT as Nuki Hub works best in Hybrid or Bridge mode and the Ultra/5th gen Pro does not support Bridge mode When pairing is successful, the web interface should show "Paired: Yes".
## Hybrid mode -Hybrid mode allows you to use the official Nuki MQTT implemenation on a Nuki Lock 3.0 Pro, Nuki Lock 4.0, Nuki Lock 4.0 Pro or Nuki Lock Ultra in conjunction with Nuki Hub.
+Hybrid mode allows you to use the official Nuki MQTT implemenation on a Nuki Lock 3.0 Pro, Nuki Lock 4.0, Nuki Lock 4.0 Pro, Nuki Lock 5.0 Pro, Nuki Lock Go or Nuki Lock Ultra in conjunction with Nuki Hub.
See [hybrid mode](/HYBRID.md) for more information. ## Memory constraints @@ -270,7 +274,7 @@ In a browser navigate to the IP address assigned to the ESP32. #### Basic Nuki Configuration - Nuki Smartlock enabled: Enable if you want Nuki Hub to connect to a Nuki Lock (1.0-4.0 and Ultra) -- Nuki Smartlock Ultra enabled: Enable if you want Nuki Hub to connect to a Nuki Lock Ultra +- Nuki Smartlock Ultra/5th gen enabled: Enable if you want Nuki Hub to connect to a Nuki Lock Ultra/5th gen Pro - Nuki Opener enabled: Enable if you want Nuki Hub to connect to a Nuki Opener - New Nuki Bluetooth connection mode (disable if there are connection issues): Enable to use the latest Nuki BLE connection mode (recommended). Disable if you have issues communicating with the lock/opener @@ -345,7 +349,7 @@ Note: All of the following requires the Nuki security code / PIN to be set, see #### Nuki Lock PIN / Nuki Opener PIN - PIN Code: Fill with the Nuki Security Code of the Nuki Lock and/or Nuki Opener. Required for functions that require the security code to be sent to the lock/opener such as setting lock permissions/adding keypad codes, viewing the activity log or changing the Nuki device configuration. Set to "#" to remove the security code from the Nuki Hub configuration. -- PIN Code Ultra: Fill with the 6-digit Nuki Security Code of the Nuki Lock Ultra. Required for pairing (and many other functions) +- PIN Code Ultra/5th gen: Fill with the 6-digit Nuki Security Code of the Nuki Lock Ultra/5th gen Pro. Required for pairing (and many other functions) #### Unpair Nuki Lock / Unpair Nuki Opener @@ -615,8 +619,8 @@ Changing settings has to enabled first in the configuration portal. Check the se | autoLockEnabled | Whether auto lock is enabled. | 1 = enabled, 0 = disabled |`{ "autoLockEnabled": "1" }` | | immediateAutoLockEnabled | Whether auto lock should be performed immediately after the door has been closed. | 1 = enabled, 0 = disabled |`{ "immediateAutoLockEnabled": "1" }`| | autoUpdateEnabled | Whether automatic firmware updates should be enabled. | 1 = enabled, 0 = disabled |`{ "autoUpdateEnabled": "1" }` | -| motorSpeed | The desired motor speed (Ultra only) | "Standard", "Insane", "Gentle" |`{ "motorSpeed": "Standard" }` | -| enableSlowSpeedDuringNightMode | Whether the slow speed should be applied during Night Mode (Ultra only) | 1 = enabled, 0 = disabled |`{ "enableSlowSpeedDuringNightMode": "1" }` | +| motorSpeed | The desired motor speed (Ultra/5th gen Pro only) | "Standard", "Insane", "Gentle" |`{ "motorSpeed": "Standard" }` | +| enableSlowSpeedDuringNightMode | Whether the slow speed should be applied during Night Mode (Ultra/5th gen Pro only) | 1 = enabled, 0 = disabled |`{ "enableSlowSpeedDuringNightMode": "1" }` | | rebootNuki | Reboot the Nuki device immediately | 1 = reboot nuki |`{ "rebootNuki": "1" }` | ### Nuki Opener Configuration diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 5d3d0bb..dde3de7 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -4412,7 +4412,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S { if (_preferences->getBool(preference_lock_gemini_enabled, false)) { - message = "Nuki Lock Ultra PIN cleared"; + message = "Nuki Lock Ultra/5th gen PIN cleared"; _nuki->setUltraPin(0xffffffff); _preferences->putInt(preference_lock_gemini_pin, 0); } @@ -4431,7 +4431,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S { if(_nuki->getUltraPin() != value.toInt()) { - message = "Nuki Lock Ultra PIN saved"; + message = "Nuki Lock Ultra/5th gen PIN saved"; _nuki->setUltraPin(value.toInt()); _preferences->putInt(preference_lock_gemini_pin, value.toInt()); Log->print("Setting changed: "); @@ -5781,7 +5781,7 @@ esp_err_t WebCfgServer::buildNukiConfigHtml(PsychicRequest *request, PsychicResp response.print("

Basic Nuki Configuration

"); response.print(""); printCheckBox(&response, "LOCKENA", "Nuki Lock enabled", _preferences->getBool(preference_lock_enabled, true), ""); - printCheckBox(&response, "GEMINIENA", "Nuki Smartlock Ultra enabled", _preferences->getBool(preference_lock_gemini_enabled, false), ""); + printCheckBox(&response, "GEMINIENA", "Nuki Smartlock Ultra/5th gen enabled", _preferences->getBool(preference_lock_gemini_enabled, false), ""); printCheckBox(&response, "OPENA", "Nuki Opener enabled", _preferences->getBool(preference_opener_enabled, false), ""); printCheckBox(&response, "CONNMODE", "New Nuki Bluetooth connection mode (disable if there are connection issues)", _preferences->getBool(preference_connect_mode, true), ""); response.print("

"); @@ -6268,7 +6268,7 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse* else { response.print("\nLock enabled: Yes"); - response.print("\nLock Ultra enabled: "); + response.print("\nLock Ultra/5th gen enabled: "); response.print(_preferences->getBool(preference_lock_gemini_enabled, false) ? "Yes" : "No"); response.print("\nPaired: "); response.print(_nuki->isPaired() ? "Yes" : "No"); @@ -6466,7 +6466,7 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse* uint32_t authorizationIdInt = authorizationId[0] + 256U*authorizationId[1] + 65536U*authorizationId[2] + 16777216U*authorizationId[3]; response.print("\nAuthorizationId (UINT32_T): "); response.print(authorizationIdInt); - response.print("\nPaired to Nuki Lock Ultra: "); + response.print("\nPaired to Nuki Lock Ultra/5th gen: "); response.print(nukiBlePref.getBool("isUltra", false) ? "Yes" : "No"); } } From 9e59e42995799e4df78e4554fc74d98f5c60dfdf Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Mar 2025 21:09:19 +0100 Subject: [PATCH 03/15] Python 3.10 --- .github/workflows/beta.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/release.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 8a3723d..edda08a 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -36,7 +36,7 @@ jobs: key: ${{ runner.os }}-pio-${{ matrix.board }} - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - name: Install dependencies run: make deps - name: Add version info diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c03299..98196f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: key: ${{ runner.os }}-pio-${{ matrix.board }} - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - name: Install dependencies run: make deps - name: Add version info diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 8a607bf..a53d0f6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -58,7 +58,7 @@ jobs: key: ${{ runner.os }}-pio-${{ matrix.board }} - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - name: Install dependencies run: make deps - name: Add version info diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1c25a80..3f4bafc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: key: ${{ runner.os }}-pio-${{ matrix.board }} - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - name: Install dependencies run: make deps - name: Add version info From 896ea2615575422496e841bf8a9bfcc36aa3cad0 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Mar 2025 21:28:19 +0100 Subject: [PATCH 04/15] Fix P4 --- resources/how-to-flash.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/how-to-flash.txt b/resources/how-to-flash.txt index 4e9fe8d..b550583 100644 --- a/resources/how-to-flash.txt +++ b/resources/how-to-flash.txt @@ -123,7 +123,11 @@ esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 921600 --before default_res ## ESP32-H2 -esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32h2.bin 0x280000 nuki_hub_updater_esp32h2.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32h2 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32h2.bin 0x280000 nuki_hub_updater_esp32h2.bin 0x8000 nuki_hub.partitions.bin + +## ESP32-P4 + +esptool.py --chip esp32p4 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32p4.bin 0x280000 nuki_hub_updater_esp32p4.bin 0x8000 nuki_hub.partitions.bin ## ESP32-SOLO1 From b14a5d1659142461fb39c0211ba62e6fe3e7cf8e Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 24 Mar 2025 22:16:08 +0100 Subject: [PATCH 05/15] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 22a6422..70a8b79 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ Feel free to join us on Discord: https://discord.gg/9nPq85bP4p - Nuki Keypad 2.0 Probably supported Nuki devices (untested): -- Nuki Smart Lock 5.0 Pro -- Nuki Smart Lock Go +- Nuki Smart Lock 5.0 Pro (See https://github.com/technyon/nuki_hub/issues/642) +- Nuki Smart Lock Go (See https://github.com/technyon/nuki_hub/issues/643) Supported Ethernet devices:
As an alternative to Wi-Fi (which is available on any supported ESP32), the following ESP32 modules with built-in wired ethernet are supported: @@ -212,7 +212,7 @@ Webflash will automatically flash the no/Quad SPI PSRAM build when an ESP32-S3 i If your ESP32-S3 device has PSRAM but it is not detected please switch to the other S3 binary.
You can do this by flashing the correct binaries manually or by selecting the option to switch S3 binary build from the Firmware Update page of the Web Configurator. -Note that there are also is a separate build of Nuki Hub available for the GL-S10 ESP32 which is needed to enable PSRAM on this device (BETA).
+Note that there are also is a separate build of Nuki Hub available for the GL-S10 ESP32 which is needed to enable PSRAM on this device.
## Configuration From 9cd236b4b9a9cdf0972dff5523c1532cd3e88086 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 24 Mar 2025 22:31:02 +0100 Subject: [PATCH 06/15] LilyGO T-ETH-Lite-ESP32S3 --- src/WebCfgServer.cpp | 1 + src/enums/NetworkDeviceType.h | 1 + src/networkDevices/W5500Definitions.h | 69 ++++++++++++++------------ src/util/NetworkDeviceInstantiator.cpp | 12 +++++ src/util/NetworkUtil.cpp | 2 + 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index dde3de7..18765ce 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -6975,6 +6975,7 @@ const std::vector> WebCfgServer::getNetworkDetectionOp options.push_back(std::make_pair("8", "GL-S10")); options.push_back(std::make_pair("9", "ETH01-Evo")); options.push_back(std::make_pair("13", "Waveshare ESP32-S3-ETH / ESP32-S3-ETH-POE")); + options.push_back(std::make_pair("14", "LilyGO T-ETH-Lite-ESP32S3")); options.push_back(std::make_pair("11", "Custom LAN module")); return options; diff --git a/src/enums/NetworkDeviceType.h b/src/enums/NetworkDeviceType.h index 18a8054..68e2f69 100644 --- a/src/enums/NetworkDeviceType.h +++ b/src/enums/NetworkDeviceType.h @@ -14,5 +14,6 @@ enum class NetworkDeviceType GL_S10, ETH01_Evo, Waveshare_ESP32_S3_ETH, + LilyGO_T_ETH_Lite_S3, CUSTOM }; \ No newline at end of file diff --git a/src/networkDevices/W5500Definitions.h b/src/networkDevices/W5500Definitions.h index e564add..5bf9604 100644 --- a/src/networkDevices/W5500Definitions.h +++ b/src/networkDevices/W5500Definitions.h @@ -2,40 +2,47 @@ #include -#define ETH_PHY_TYPE_W5500 ETH_PHY_W5500 -#define ETH_PHY_ADDR_W5500 1 -#define ETH_PHY_IRQ_M5_W5500 -1 -#define ETH_PHY_RST_M5_W5500 -1 -#define ETH_PHY_CS_M5_W5500 19 -#define ETH_PHY_SPI_SCK_M5_W5500 22 -#define ETH_PHY_SPI_MISO_M5_W5500 23 -#define ETH_PHY_SPI_MOSI_M5_W5500 33 +#define ETH_PHY_TYPE_W5500 ETH_PHY_W5500 +#define ETH_PHY_ADDR_W5500 1 +#define ETH_PHY_IRQ_M5_W5500 -1 +#define ETH_PHY_RST_M5_W5500 -1 +#define ETH_PHY_CS_M5_W5500 19 +#define ETH_PHY_SPI_SCK_M5_W5500 22 +#define ETH_PHY_SPI_MISO_M5_W5500 23 +#define ETH_PHY_SPI_MOSI_M5_W5500 33 -#define ETH_PHY_CS_M5_W5500_S3 6 -#define ETH_PHY_SPI_SCK_M5_W5500_S3 5 -#define ETH_PHY_SPI_MISO_M5_W5500_S3 7 -#define ETH_PHY_SPI_MOSI_M5_W5500_S3 8 +#define ETH_PHY_CS_M5_W5500_S3 6 +#define ETH_PHY_SPI_SCK_M5_W5500_S3 5 +#define ETH_PHY_SPI_MISO_M5_W5500_S3 7 +#define ETH_PHY_SPI_MOSI_M5_W5500_S3 8 -#define ETH_PHY_IRQ_ELITE_W5500 14 -#define ETH_PHY_RST_ELITE_W5500 -1 -#define ETH_PHY_CS_ELITE_W5500 45 -#define ETH_PHY_SPI_SCK_ELITE_W5500 48 -#define ETH_PHY_SPI_MISO_ELITE_W5500 47 -#define ETH_PHY_SPI_MOSI_ELITE_W5500 21 +#define ETH_PHY_IRQ_ELITE_W5500 14 +#define ETH_PHY_RST_ELITE_W5500 -1 +#define ETH_PHY_CS_ELITE_W5500 45 +#define ETH_PHY_SPI_SCK_ELITE_W5500 48 +#define ETH_PHY_SPI_MISO_ELITE_W5500 47 +#define ETH_PHY_SPI_MOSI_ELITE_W5500 21 -#define ETH_PHY_IRQ_GENERIC_W5500 3 -#define ETH_PHY_RST_GENERIC_W5500 4 -#define ETH_PHY_CS_GENERIC_W5500 5 -#define ETH_PHY_SPI_SCK_GENERIC_W5500 8 -#define ETH_PHY_SPI_MISO_GENERIC_W5500 9 -#define ETH_PHY_SPI_MOSI_GENERIC_W5500 10 +#define ETH_PHY_IRQ_GENERIC_W5500 3 +#define ETH_PHY_RST_GENERIC_W5500 4 +#define ETH_PHY_CS_GENERIC_W5500 5 +#define ETH_PHY_SPI_SCK_GENERIC_W5500 8 +#define ETH_PHY_SPI_MISO_GENERIC_W5500 9 +#define ETH_PHY_SPI_MOSI_GENERIC_W5500 10 -#define ETH_ADDR_WAVESHARE_ESP32_S3_ETH 1 -#define ETH_PHY_SPI_IRQ_WAVESHARE_ESP32_S3_ETH 10 -#define ETH_PHY_SPI_RST_WAVESHARE_ESP32_S3_ETH 9 -#define ETH_PHY_SPI_CS_WAVESHARE_ESP32_S3_ETH 14 -#define ETH_PHY_SPI_SCK_WAVESHARE_ESP32_S3_ETH 13 -#define ETH_PHY_SPI_MISO_WAVESHARE_ESP32_S3_ETH 12 -#define ETH_PHY_SPI_MOSI_WAVESHARE_ESP32_S3_ETH 11 +#define ETH_ADDR_WAVESHARE_ESP32_S3_ETH 1 +#define ETH_PHY_SPI_IRQ_WAVESHARE_ESP32_S3_ETH 10 +#define ETH_PHY_SPI_RST_WAVESHARE_ESP32_S3_ETH 9 +#define ETH_PHY_SPI_CS_WAVESHARE_ESP32_S3_ETH 14 +#define ETH_PHY_SPI_SCK_WAVESHARE_ESP32_S3_ETH 13 +#define ETH_PHY_SPI_MISO_WAVESHARE_ESP32_S3_ETH 12 +#define ETH_PHY_SPI_MOSI_WAVESHARE_ESP32_S3_ETH 11 + +#define ETH_PHY_CS_ETHLITES3_W5500 9 +#define ETH_PHY_IRQ_ETHLITES3_W5500 13 +#define ETH_PHY_RST_ETHLITES3_W5500 14 +#define ETH_PHY_SPI_SCK_ETHLITES3_W5500 10 +#define ETH_PHY_SPI_MISO_ETHLITES3_W5500 11 +#define ETH_PHY_SPI_MOSI_ETHLITES3_W5500 12 #define ETH_ADDR 1 \ No newline at end of file diff --git a/src/util/NetworkDeviceInstantiator.cpp b/src/util/NetworkDeviceInstantiator.cpp index 1bcd2d3..d57b6ec 100644 --- a/src/util/NetworkDeviceInstantiator.cpp +++ b/src/util/NetworkDeviceInstantiator.cpp @@ -80,6 +80,18 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDevice ETH_PHY_SPI_MOSI_ELITE_W5500, ETH_PHY_W5500); break; + case NetworkDeviceType::LilyGO_T_ETH_Lite_S3: + device = new EthernetDevice(hostname, preferences, ipConfiguration, "LilyGO T-ETH-Lite-ESP32S3", + ETH_PHY_ADDR_W5500, + ETH_PHY_CS_ETHLITES3_W5500, + ETH_PHY_IRQ_ETHLITES3_W5500, + ETH_PHY_RST_ETHLITES3_W5500, + ETH_PHY_SPI_SCK_ETHLITES3_W5500, + ETH_PHY_SPI_MISO_ETHLITES3_W5500, + ETH_PHY_SPI_MOSI_ETHLITES3_W5500, + ETH_PHY_W5500); + break; + case NetworkDeviceType::CUSTOM: { int custPHY = preferences->getInt(preference_network_custom_phy, 0); diff --git a/src/util/NetworkUtil.cpp b/src/util/NetworkUtil.cpp index e68325c..0d4633a 100644 --- a/src/util/NetworkUtil.cpp +++ b/src/util/NetworkUtil.cpp @@ -36,6 +36,8 @@ NetworkDeviceType NetworkUtil::GetDeviceTypeFromPreference(int hardwareDetect, i return NetworkDeviceType::LilyGO_T_ETH_ELite; case 13: return NetworkDeviceType::Waveshare_ESP32_S3_ETH; + case 14: + return NetworkDeviceType::LilyGO_T_ETH_Lite_S3; default: Log->println("Unknown hardware selected, falling back to Wi-Fi."); return NetworkDeviceType::WiFi; From 66bc83d628a033f33f95e718489851b22a75a31f Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 24 Mar 2025 22:43:10 +0100 Subject: [PATCH 07/15] Update WebCfgServer.cpp --- src/WebCfgServer.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 18765ce..5986ed4 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -1601,18 +1601,18 @@ esp_err_t WebCfgServer::buildOtaHtml(PsychicRequest *request, PsychicResponse* r #else String build_type = "debug"; #endif - response.print("

"); - response.print("

"); - response.print("

"); + response.print("

"); + response.print("

"); + response.print("

"); #if defined(CONFIG_IDF_TARGET_ESP32S3) if(esp_psram_get_size() <= 0) { - response.print("

"); + response.print("

"); } #elif defined(CONFIG_IDF_TARGET_ESP32) && !defined(NUKI_TARGET_GL_S10) if(_preferences->getInt(preference_network_hardware) == 8) { - response.print("

"); + response.print("

"); } #endif response.print("

"); @@ -6689,9 +6689,9 @@ esp_err_t WebCfgServer::processUpdate(PsychicRequest *request, PsychicResponse* { esp_err_t res; String value = ""; - if(request->hasParam("token")) + if(request->hasParam("CONFIRMTOKEN")) { - const PsychicWebParameter* p = request->getParam("token"); + const PsychicWebParameter* p = request->getParam("CONFIRMTOKEN"); if(p->value() != "") { value = p->value(); From 88e2b8724ba318de9b5d822cb35509e2f39d4775 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 24 Mar 2025 22:46:36 +0100 Subject: [PATCH 08/15] TOTP fix --- src/WebCfgServer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 5986ed4..127e4b1 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -4377,6 +4377,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S configChanged = true; clearSession = true; newMFA = true; + _importExport->_sessionsOpts[request->client()->localIP().toString() + "totp"] = true; } } } From 42a0aeeb3bae2ff8e63a952b60753755004f70b8 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 27 Mar 2025 23:17:17 +0100 Subject: [PATCH 09/15] Add Nuki Lock Go --- README.md | 20 +++++++++----------- src/WebCfgServer.cpp | 10 +++++----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 70a8b79..798322c 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,13 @@ Feel free to join us on Discord: https://discord.gg/9nPq85bP4p - Nuki Smart Lock 3.0 Pro - Nuki Smart Lock 4.0 - Nuki Smart Lock 4.0 Pro +- Nuki Smart Lock Go +- Nuki Smart Lock 5.0 Pro - Nuki Smart Lock Ultra - Nuki Opener - Nuki Keypad 1.0 - Nuki Keypad 2.0 -Probably supported Nuki devices (untested): -- Nuki Smart Lock 5.0 Pro (See https://github.com/technyon/nuki_hub/issues/642) -- Nuki Smart Lock Go (See https://github.com/technyon/nuki_hub/issues/643) - Supported Ethernet devices:
As an alternative to Wi-Fi (which is available on any supported ESP32), the following ESP32 modules with built-in wired ethernet are supported: - [Olimex ESP32-POE](https://www.olimex.com/Products/IoT/ESP32/ESP32-POE/open-source-hardware) @@ -165,15 +163,15 @@ MQTT nodes like lock state and battery level should now reflect the reported val This is not recommended (unless when using [hybrid mode](/HYBRID.md)) and will lead to excessive battery drain and can lead to either device missing updates. Enable "Register as app" before pairing to allow this. Otherwise the Bridge will be unregistered when pairing the Nuki Hub. -## Pairing with a Nuki Lock Ultra / 5th gen Pro +## Pairing with a Nuki Lock Ultra / Nuki Lock Go / Nuki Lock 5th gen Pro Make sure "Bluetooth pairing" is enabled for the Nuki device by enabling this setting in the official Nuki App in "Settings" > "Features & Configuration" > "Button and LED". -Before enabling pairing mode using the button on the Lock Ultra / 5th gen Pro first setup Nuki Hub as follows: -- Enable both "Nuki Smartlock enabled" and "Nuki Smartlock Ultra/5th gen enabled" settings on the "Basic Nuki Configuration" page and Save. Setting the "Nuki Smartlock Ultra/5th gen enabled" will change multiple other NukiHub settings. -- Input your 6-digit Nuki Lock Ultra/5th gen PIN on the "Credentials" page and Save +Before enabling pairing mode using the button on the Nuki Lock Ultra / Nuki Lock Go / Nuki Lock 5th gen Pro first setup Nuki Hub as follows: +- Enable both "Nuki Smartlock enabled" and "Nuki Smartlock Ultra/Go/5th gen enabled" settings on the "Basic Nuki Configuration" page and Save. Setting the "Nuki Smartlock Ultra/Go/5th gen enabled" will change multiple other NukiHub settings. +- Input your 6-digit Nuki Lock Ultra/Go/5th gen PIN on the "Credentials" page and Save - Press the button on the Nuki device for a few seconds until the LED ring lights up and remains lit. -- It is **strongly** recommended(/mandatory) to setup and enable Hybrid mode over Thread/WiFi + official MQTT as Nuki Hub works best in Hybrid or Bridge mode and the Ultra/5th gen Pro does not support Bridge mode +- It is **strongly** recommended(/mandatory) to setup and enable Hybrid mode over Thread/WiFi + official MQTT as Nuki Hub works best in Hybrid or Bridge mode and the Ultra/Go/5th gen Pro does not support Bridge mode When pairing is successful, the web interface should show "Paired: Yes".
@@ -274,7 +272,7 @@ In a browser navigate to the IP address assigned to the ESP32. #### Basic Nuki Configuration - Nuki Smartlock enabled: Enable if you want Nuki Hub to connect to a Nuki Lock (1.0-4.0 and Ultra) -- Nuki Smartlock Ultra/5th gen enabled: Enable if you want Nuki Hub to connect to a Nuki Lock Ultra/5th gen Pro +- Nuki Smartlock Ultra/Go/5th gen enabled: Enable if you want Nuki Hub to connect to a Nuki Lock Ultra/Go/5th gen Pro - Nuki Opener enabled: Enable if you want Nuki Hub to connect to a Nuki Opener - New Nuki Bluetooth connection mode (disable if there are connection issues): Enable to use the latest Nuki BLE connection mode (recommended). Disable if you have issues communicating with the lock/opener @@ -349,7 +347,7 @@ Note: All of the following requires the Nuki security code / PIN to be set, see #### Nuki Lock PIN / Nuki Opener PIN - PIN Code: Fill with the Nuki Security Code of the Nuki Lock and/or Nuki Opener. Required for functions that require the security code to be sent to the lock/opener such as setting lock permissions/adding keypad codes, viewing the activity log or changing the Nuki device configuration. Set to "#" to remove the security code from the Nuki Hub configuration. -- PIN Code Ultra/5th gen: Fill with the 6-digit Nuki Security Code of the Nuki Lock Ultra/5th gen Pro. Required for pairing (and many other functions) +- PIN Code Ultra/5th gen: Fill with the 6-digit Nuki Security Code of the Nuki Lock Ultra/Go/5th gen Pro. Required for pairing (and many other functions) #### Unpair Nuki Lock / Unpair Nuki Opener diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 127e4b1..6c9e8a6 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -4413,7 +4413,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S { if (_preferences->getBool(preference_lock_gemini_enabled, false)) { - message = "Nuki Lock Ultra/5th gen PIN cleared"; + message = "Nuki Lock Ultra/Go/5th gen PIN cleared"; _nuki->setUltraPin(0xffffffff); _preferences->putInt(preference_lock_gemini_pin, 0); } @@ -4432,7 +4432,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S { if(_nuki->getUltraPin() != value.toInt()) { - message = "Nuki Lock Ultra/5th gen PIN saved"; + message = "Nuki Lock Ultra/Go/5th gen PIN saved"; _nuki->setUltraPin(value.toInt()); _preferences->putInt(preference_lock_gemini_pin, value.toInt()); Log->print("Setting changed: "); @@ -5782,7 +5782,7 @@ esp_err_t WebCfgServer::buildNukiConfigHtml(PsychicRequest *request, PsychicResp response.print("

Basic Nuki Configuration

"); response.print(""); printCheckBox(&response, "LOCKENA", "Nuki Lock enabled", _preferences->getBool(preference_lock_enabled, true), ""); - printCheckBox(&response, "GEMINIENA", "Nuki Smartlock Ultra/5th gen enabled", _preferences->getBool(preference_lock_gemini_enabled, false), ""); + printCheckBox(&response, "GEMINIENA", "Nuki Smartlock Ultra/Go/5th gen enabled", _preferences->getBool(preference_lock_gemini_enabled, false), ""); printCheckBox(&response, "OPENA", "Nuki Opener enabled", _preferences->getBool(preference_opener_enabled, false), ""); printCheckBox(&response, "CONNMODE", "New Nuki Bluetooth connection mode (disable if there are connection issues)", _preferences->getBool(preference_connect_mode, true), ""); response.print("

"); @@ -6269,7 +6269,7 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse* else { response.print("\nLock enabled: Yes"); - response.print("\nLock Ultra/5th gen enabled: "); + response.print("\nLock Ultra/Go/5th gen enabled: "); response.print(_preferences->getBool(preference_lock_gemini_enabled, false) ? "Yes" : "No"); response.print("\nPaired: "); response.print(_nuki->isPaired() ? "Yes" : "No"); @@ -6467,7 +6467,7 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse* uint32_t authorizationIdInt = authorizationId[0] + 256U*authorizationId[1] + 65536U*authorizationId[2] + 16777216U*authorizationId[3]; response.print("\nAuthorizationId (UINT32_T): "); response.print(authorizationIdInt); - response.print("\nPaired to Nuki Lock Ultra/5th gen: "); + response.print("\nPaired to Nuki Lock Ultra/Go/5th gen: "); response.print(nukiBlePref.getBool("isUltra", false) ? "Yes" : "No"); } } From 1c546b5f8b68186c9a4524fd1d10f803e2d30d9d Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 21 Mar 2025 22:24:45 +0100 Subject: [PATCH 10/15] MQTT mempool --- platformio.ini | 7 +++++++ src/Config.h | 2 +- src/networkDevices/NetworkDevice.cpp | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 22a8574..73ddde7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -44,6 +44,13 @@ build_flags = -DNUKI_MUTEX_RECURSIVE -DNUKI_64BIT_TIME -DETH_SPI_SUPPORTS_NO_IRQ + -DEMC_RX_BUFFER_SIZE=1440 + -DEMC_TX_BUFFER_SIZE=1440 + -DEMC_MIN_FREE_MEMORY=8192 + -DEMC_TASK_STACK_SIZE=10240 + -DEMC_USE_MEMPOOL=1 + -DEMC_NUM_POOL_ELEMENTS=64 + -DEMC_SIZE_POOL_ELEMENTS=256 -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-type-limits diff --git a/src/Config.h b/src/Config.h index bdc85df..219041c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -5,7 +5,7 @@ #define NUKI_HUB_VERSION "9.10" #define NUKI_HUB_VERSION_INT (uint32_t)910 #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2025-03-03" +#define NUKI_HUB_DATE "2025-03-21" #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" diff --git a/src/networkDevices/NetworkDevice.cpp b/src/networkDevices/NetworkDevice.cpp index b921d71..7ce2c65 100644 --- a/src/networkDevices/NetworkDevice.cpp +++ b/src/networkDevices/NetworkDevice.cpp @@ -33,7 +33,7 @@ void NetworkDevice::init() { _useEncryption = true; Log->println("MQTT over TLS."); - _mqttClientSecure = new espMqttClientSecure(espMqttClientTypes::UseInternalTask::NO); + _mqttClientSecure = new espMqttClientSecure(espMqttClientTypes::UseInternalTask::YES); _mqttClientSecure->setCACert(caDest); File file2 = SPIFFS.open("/mqtt_ssl.crt"); @@ -70,7 +70,7 @@ void NetworkDevice::init() if (!_useEncryption) { Log->println("MQTT without TLS."); - _mqttClient = new espMqttClient(espMqttClientTypes::UseInternalTask::NO); + _mqttClient = new espMqttClient(espMqttClientTypes::UseInternalTask::YES); } if(_preferences->getBool(preference_mqtt_log_enabled, false) || _preferences->getBool(preference_webserial_enabled, false)) @@ -103,7 +103,7 @@ void NetworkDevice::update() { if (_mqttEnabled) { - getMqttClient()->loop(); + //getMqttClient()->loop(); } } From bae6e5df69c614461b4bde2980a985c1064ce984 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 25 Mar 2025 17:08:47 +0100 Subject: [PATCH 11/15] Switch Github root cert --- partitions.csv | 2 +- pio_package_post.py | 2 +- resources/how-to-flash.txt | 18 +++++++++--------- resources/root_ca.pem | 32 ++++++++++++++++++++++++++++++++ sdkconfig.defaults | 10 +++++++--- updater/partitions.csv | 2 +- updater/sdkconfig.defaults | 4 +++- 7 files changed, 54 insertions(+), 16 deletions(-) diff --git a/partitions.csv b/partitions.csv index 1b64460..2e3123f 100644 --- a/partitions.csv +++ b/partitions.csv @@ -1 +1 @@ -# Espressif ESP32 Partition Table # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, app0, app, ota_0, 0x10000, 0x270000, app1, app, ota_1, 0x280000, 0x130000, spiffs, data, spiffs, 0x3B0000, 0x40000, coredump, data, coredump,0x3F0000, 0x10000, \ No newline at end of file +# Espressif ESP32 Partition Table # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, app0, app, ota_0, 0x10000, 0x260000, app1, app, ota_1, 0x270000, 0x140000, spiffs, data, spiffs, 0x3B0000, 0x40000, coredump, data, coredump,0x3F0000, 0x10000, \ No newline at end of file diff --git a/pio_package_post.py b/pio_package_post.py index 60fc392..a4e333a 100644 --- a/pio_package_post.py +++ b/pio_package_post.py @@ -58,7 +58,7 @@ def merge_bin(source, target, env): flash_args.append(position) flash_args.append(bin_file) - flash_args.append("0x2B0000") + flash_args.append("0x270000") flash_args.append(f"{target_dir}/nuki_hub_updater_{board}.bin") cmd = f"esptool.py --chip {chip} merge_bin -o {target_file} --flash_mode dio --flash_freq keep --flash_size keep " + " ".join(flash_args) diff --git a/resources/how-to-flash.txt b/resources/how-to-flash.txt index b550583..1775b88 100644 --- a/resources/how-to-flash.txt +++ b/resources/how-to-flash.txt @@ -99,38 +99,38 @@ As an alternative to the Download Tools, you can also use the esptool from the E ## ESP32 -esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader.bin 0x10000 nuki_hub_esp32.bin 0x280000 nuki_hub_updater_esp32.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader.bin 0x10000 nuki_hub_esp32.bin 0x270000 nuki_hub_updater_esp32.bin 0x8000 nuki_hub.partitions.bin ## ESP32-GL-S10 -esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader.bin 0x10000 nuki_hub_esp32.bin 0x280000 nuki_hub_updater_esp32.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader.bin 0x10000 nuki_hub_esp32.bin 0x270000 nuki_hub_updater_esp32.bin 0x8000 nuki_hub.partitions.bin ## ESP32-S3 -esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3.bin 0x280000 nuki_hub_updater_esp32s3.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3.bin 0x270000 nuki_hub_updater_esp32s3.bin 0x8000 nuki_hub.partitions.bin ## ESP32-S3-OCT -esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3oct.bin 0x280000 nuki_hub_updater_esp32s3oct.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3oct.bin 0x270000 nuki_hub_updater_esp32s3oct.bin 0x8000 nuki_hub.partitions.bin ## ESP32-C3 -esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32c3.bin 0x280000 nuki_hub_updater_esp32c3.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32c3.bin 0x270000 nuki_hub_updater_esp32c3.bin 0x8000 nuki_hub.partitions.bin ## ESP32-C6 -esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32c6.bin 0x280000 nuki_hub_updater_esp32c6.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32c6.bin 0x270000 nuki_hub_updater_esp32c6.bin 0x8000 nuki_hub.partitions.bin ## ESP32-H2 -esptool.py --chip esp32h2 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32h2.bin 0x280000 nuki_hub_updater_esp32h2.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32h2 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32h2.bin 0x270000 nuki_hub_updater_esp32h2.bin 0x8000 nuki_hub.partitions.bin ## ESP32-P4 -esptool.py --chip esp32p4 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32p4.bin 0x280000 nuki_hub_updater_esp32p4.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32p4 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x0 bootloader.bin 0x10000 nuki_hub_esp32p4.bin 0x270000 nuki_hub_updater_esp32p4.bin 0x8000 nuki_hub.partitions.bin ## ESP32-SOLO1 -esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader.bin 0x10000 nuki_hub_esp32-solo1.bin 0x280000 nuki_hub_updater_esp32-solo1.bin 0x8000 nuki_hub.partitions.bin +esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader.bin 0x10000 nuki_hub_esp32-solo1.bin 0x270000 nuki_hub_updater_esp32-solo1.bin 0x8000 nuki_hub.partitions.bin Adjust the serial device and path to the binaries if necessary. \ No newline at end of file diff --git a/resources/root_ca.pem b/resources/root_ca.pem index 95629e4..52b3cd7 100644 --- a/resources/root_ca.pem +++ b/resources/root_ca.pem @@ -40,6 +40,38 @@ pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl MrY= -----END CERTIFICATE----- +USERTrust RSA Certification Authority +===================================== +-----BEGIN CERTIFICATE----- +MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE +BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK +ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE +BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK +ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz +0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j +Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn +RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O ++T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq +/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE +Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM +lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8 +yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+ +eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd +BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF +MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW +FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ +7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ +Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM +8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi +FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi +yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c +J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw +sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx +Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9 +-----END CERTIFICATE----- + DigiCert High Assurance EV Root CA ================================== -----BEGIN CERTIFICATE----- diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 752e1e1..2cb66bd 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -40,10 +40,14 @@ CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y CONFIG_MBEDTLS_PSK_MODES=y CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y -CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="resources/root_ca.pem" +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y +#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y +#CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y +#CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="resources/root_ca.pem" CONFIG_MBEDTLS_DYNAMIC_BUFFER=y +CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y +CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y # RTC WDT CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE=y diff --git a/updater/partitions.csv b/updater/partitions.csv index b024b85..62f1c28 100644 --- a/updater/partitions.csv +++ b/updater/partitions.csv @@ -1 +1 @@ -# Espressif ESP32 Partition Table # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, app0, app, ota_0, 0x10000, 0x130000, \ No newline at end of file +# Espressif ESP32 Partition Table # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, app0, app, ota_0, 0x10000, 0x140000, \ No newline at end of file diff --git a/updater/sdkconfig.defaults b/updater/sdkconfig.defaults index 274c771..c9a90e4 100644 --- a/updater/sdkconfig.defaults +++ b/updater/sdkconfig.defaults @@ -26,7 +26,9 @@ CONFIG_ARDUINO_SELECTIVE_RainMaker=n CONFIG_ARDUINO_SELECTIVE_OpenThread=n CONFIG_ARDUINO_SELECTIVE_Insights=n CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y +CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y CONFIG_LOG_COLORS=n CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=n CONFIG_LOG_MAXIMUM_LEVEL=4 From 45211ea352355bf53bceb4ff29e428d48dbc5587 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 28 Mar 2025 15:54:13 +0100 Subject: [PATCH 12/15] Pioarduino 3.2.0 final --- platformio.ini | 2 +- updater/platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 73ddde7..6ea5182 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,7 +13,7 @@ default_envs = esp32 boards_dir = boards [env] -platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc2/platform-espressif32.zip +platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip platform_packages = framework = arduino, espidf board_build.embed_txtfiles = diff --git a/updater/platformio.ini b/updater/platformio.ini index 3c49ee6..38ff5a5 100644 --- a/updater/platformio.ini +++ b/updater/platformio.ini @@ -13,7 +13,7 @@ default_envs = updater_esp32 boards_dir = ../boards [env] -platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc2/platform-espressif32.zip +platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip platform_packages = framework = arduino, espidf board_build.embed_txtfiles = From 0592c277ea098b9812970e08dc2e6a5163341fa9 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 31 Mar 2025 20:12:47 +0200 Subject: [PATCH 13/15] Unique hostname and disable MDNS --- README.md | 2 +- src/Config.h | 2 +- src/NukiNetwork.cpp | 25 +++++++++++++++----- src/WebCfgServer.cpp | 4 ++-- src/main.cpp | 39 +++++++++++++++++++------------ src/networkDevices/WifiDevice.cpp | 4 ---- 6 files changed, 47 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 798322c..d3bc13a 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ In a browser navigate to the IP address assigned to the ESP32. #### Network Configuration -- Host name: Set the hostname for the Nuki Hub ESP +- Hostname (needs to be unique, "nukihub" is not allowed): Set the hostname for the Nuki Hub ESP, will also be used as the MQTT client ID. Needs to be unique. - Network hardware: "Wi-Fi only" by default, set to one of the specified ethernet modules if available, see the "Supported Ethernet devices" and "[Connecting via Ethernet](#connecting-via-ethernet-optional)" section of this README. - Home Assistant device configuration URL: When using Home Assistant discovery the link to the Nuki Hub Web Configuration will be published to Home Assistant. By default when this setting is left empty this will link to the current IP of the Nuki Hub. When using a reverse proxy to access the Web Configuration you can set a custom URL here. - RSSI Publish interval: Set to a positive integer to set the amount of seconds between updates to the maintenance/wifiRssi MQTT topic with the current Wi-Fi RSSI, set to -1 to disable, default 60. diff --git a/src/Config.h b/src/Config.h index 219041c..e8c976a 100644 --- a/src/Config.h +++ b/src/Config.h @@ -5,7 +5,7 @@ #define NUKI_HUB_VERSION "9.10" #define NUKI_HUB_VERSION_INT (uint32_t)910 #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2025-03-21" +#define NUKI_HUB_DATE "2025-04-01" #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" diff --git a/src/NukiNetwork.cpp b/src/NukiNetwork.cpp index 8684d4a..acb5aa4 100644 --- a/src/NukiNetwork.cpp +++ b/src/NukiNetwork.cpp @@ -11,6 +11,7 @@ #endif #include "networkDevices/EthernetDevice.h" #include "hal/wdt_hal.h" +#include "esp_mac.h" NukiNetwork* NukiNetwork::_inst = nullptr; @@ -216,9 +217,15 @@ void NukiNetwork::initialize() { _hostname = _preferences->getString(preference_hostname, ""); - if(_hostname == "") + if(_hostname == "" || _hostname == "nukihub") { - _hostname = "nukihub"; + char _nukiHubUidString[20]; + uint8_t mac[8]; + esp_efuse_mac_get_default(mac); + uint64_t curDevId; + memcpy(&curDevId, &mac, 8); + sprintf(_nukiHubUidString, "%" PRIu64, curDevId); + _hostname = (String)"NH" + _nukiHubUidString; _preferences->putString(preference_hostname, _hostname); } @@ -258,9 +265,15 @@ void NukiNetwork::initialize() _hostname = _preferences->getString(preference_hostname, ""); - if(_hostname == "") + if(_hostname == "" || _hostname == "nukihub") { - _hostname = "nukihub"; + char _nukiHubUidString[20]; + uint8_t mac[8]; + esp_efuse_mac_get_default(mac); + uint64_t curDevId; + memcpy(&curDevId, &mac, 8); + sprintf(_nukiHubUidString, "%" PRIu64, curDevId); + _hostname = (String)"NH" + _nukiHubUidString; _preferences->putString(preference_hostname, _hostname); } @@ -429,7 +442,7 @@ bool NukiNetwork::update() _firstDisconnected = true; } - if(!_device->mqttConnected() && _device->isConnected()) + if(!_logIp && _device->isConnected() && !_device->mqttConnected() ) { bool success = reconnect(); if(!success) @@ -453,7 +466,7 @@ bool NukiNetwork::update() delay(2000); } - if(!_device->mqttConnected() || !_device->isConnected()) + if(!_device->isConnected() || !_device->mqttConnected() ) { if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000) && ts > 60000) { diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 6c9e8a6..576f032 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -3174,7 +3174,7 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S } else if(key == "HOSTNAME") { - if(_preferences->getString(preference_hostname, "") != value) + if(_preferences->getString(preference_hostname, "") != value && value != "nukihub") { _preferences->putString(preference_hostname, value); Log->print("Setting changed: "); @@ -5104,7 +5104,7 @@ esp_err_t WebCfgServer::buildNetworkConfigHtml(PsychicRequest *request, PsychicR response.print(""); response.print("

Network Configuration

"); response.print(""); - printInputField(&response, "HOSTNAME", "Host name", _preferences->getString(preference_hostname).c_str(), 100, ""); + printInputField(&response, "HOSTNAME", "Hostname (needs to be unique, \"nukihub\" is not allowed)", _preferences->getString(preference_hostname).c_str(), 100, ""); printDropDown(&response, "NWHW", "Network hardware", String(_preferences->getInt(preference_network_hardware)), getNetworkDetectionOptions(), ""); printInputField(&response, "HASSCUURL", "Home Assistant device configuration URL (empty to use http://LOCALIP; fill when using a reverse proxy for example)", _preferences->getString(preference_mqtt_hass_cu_url).c_str(), 261, ""); #ifndef CONFIG_IDF_TARGET_ESP32H2 diff --git a/src/main.cpp b/src/main.cpp index c1d50b1..dd18e90 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -95,6 +95,8 @@ RTC_NOINIT_ATTR bool wifiFallback; RTC_NOINIT_ATTR bool ethCriticalFailure; bool coredumpPrinted = true; bool timeSynced = false; +bool webStarted = false; +bool webSSLStarted = false; int lastHTTPeventId = -1; bool doOta = false; @@ -218,7 +220,7 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels) { { SPIFFS.remove((String)"/" + file.name()); } - + file = root.openNextFile(); } } @@ -257,6 +259,20 @@ void networkTask(void *pvParameters) { esp_netif_sntp_start(); } + + /* MDNS currently disabled for causing issues (9.10 / 2025-04-01) + if(webSSLStarted) { + if (MDNS.begin(preferences->getString(preference_hostname, "nukihub").c_str())) { + MDNS.addService("http", "tcp", 443); + } + } + else if(webStarted) { + if (MDNS.begin(preferences->getString(preference_hostname, "nukihub").c_str())) { + MDNS.addService("http", "tcp", 80); + } + } + */ + reroute = false; setReroute(); } @@ -529,6 +545,8 @@ void setupTasks(bool ota) esp_chip_info_t info; esp_chip_info(&info); uint8_t espCores = info.cores; + Log->print("Cores: "); + Log->println(espCores); if(ota) { @@ -673,7 +691,7 @@ void setup() { logCoreDump(); } - + if (SPIFFS.begin(true)) { listDir(SPIFFS, "/", 1); @@ -792,10 +810,7 @@ void setup() return response->redirect("/"); }); psychicSSLServer->begin(); - if (MDNS.begin(preferences->getString(preference_hostname, "nukihub").c_str())) { - MDNS.addService("http", "tcp", 443); - } - + webSSLStarted = true; } } } @@ -812,9 +827,7 @@ void setup() return response->redirect("/"); }); psychicServer->begin(); - if (MDNS.begin(preferences->getString(preference_hostname, "nukihub").c_str())) { - MDNS.addService("http", "tcp", 80); - } + webStarted = true; #ifdef CONFIG_SOC_SPIRAM_SUPPORTED } #endif @@ -977,9 +990,7 @@ void setup() return response->redirect("/"); }); psychicSSLServer->begin(); - if (MDNS.begin(preferences->getString(preference_hostname, "nukihub").c_str())) { - MDNS.addService("http", "tcp", 443); - } + webSSLStarted = true; } } } @@ -996,9 +1007,7 @@ void setup() return response->redirect("/"); }); psychicServer->begin(); - if (MDNS.begin(preferences->getString(preference_hostname, "nukihub").c_str())) { - MDNS.addService("http", "tcp", 80); - } + webStarted = true; #ifdef CONFIG_SOC_SPIRAM_SUPPORTED } #endif diff --git a/src/networkDevices/WifiDevice.cpp b/src/networkDevices/WifiDevice.cpp index 5b1c68e..21da624 100644 --- a/src/networkDevices/WifiDevice.cpp +++ b/src/networkDevices/WifiDevice.cpp @@ -286,10 +286,6 @@ void WifiDevice::onWifiEvent(const WiFiEvent_t &event, const WiFiEventInfo_t &in break; case ARDUINO_EVENT_WIFI_STA_CONNECTED: Log->println("Connected to access point"); - if(!_openAP) - { - onConnected(); - } break; case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: Log->println("Disconnected from WiFi access point"); From bf1b27a7925d051a3612a6612510cc991c5eb3b5 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 1 Apr 2025 22:27:50 +0200 Subject: [PATCH 14/15] MQTT internal task --- src/networkDevices/NetworkDevice.cpp | 36 +++++++++++++++++++++++----- src/networkDevices/NetworkDevice.h | 1 + 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/networkDevices/NetworkDevice.cpp b/src/networkDevices/NetworkDevice.cpp index 7ce2c65..d4eedae 100644 --- a/src/networkDevices/NetworkDevice.cpp +++ b/src/networkDevices/NetworkDevice.cpp @@ -7,9 +7,19 @@ #include "SPIFFS.h" #include "../MqttTopics.h" #include "PreferencesKeys.h" +#ifdef CONFIG_SOC_SPIRAM_SUPPORTED +#include "esp_psram.h" +#endif void NetworkDevice::init() { + #ifdef CONFIG_SOC_SPIRAM_SUPPORTED + if(esp_psram_get_size() > 0) + { + _mqttInternal = true; + } + #endif + if(_preferences->getBool(preference_mqtt_ssl_enabled, false)) { if (!SPIFFS.begin(true)) { Log->println("SPIFFS Mount Failed"); @@ -28,12 +38,19 @@ void NetworkDevice::init() char* caDest; caDest = (char *)malloc(sizeof(char) * (ca_cert.length()+1)); strcpy(caDest, ca_cert.c_str()); - + if(ca_cert.length() > 1) { _useEncryption = true; Log->println("MQTT over TLS."); - _mqttClientSecure = new espMqttClientSecure(espMqttClientTypes::UseInternalTask::YES); + if(_mqttInternal) + { + _mqttClientSecure = new espMqttClientSecure(espMqttClientTypes::UseInternalTask::YES); + } + else + { + _mqttClientSecure = new espMqttClientSecure(espMqttClientTypes::UseInternalTask::NO); + } _mqttClientSecure->setCACert(caDest); File file2 = SPIFFS.open("/mqtt_ssl.crt"); @@ -48,7 +65,7 @@ void NetworkDevice::init() char* certDest; certDest = (char *)malloc(sizeof(char) * (cert.length()+1)); strcpy(certDest, cert.c_str()); - + String key = file3.readString(); file3.close(); char* keyDest; @@ -70,7 +87,14 @@ void NetworkDevice::init() if (!_useEncryption) { Log->println("MQTT without TLS."); - _mqttClient = new espMqttClient(espMqttClientTypes::UseInternalTask::YES); + if(_mqttInternal) + { + _mqttClient = new espMqttClient(espMqttClientTypes::UseInternalTask::YES); + } + else + { + _mqttClient = new espMqttClient(espMqttClientTypes::UseInternalTask::NO); + } } if(_preferences->getBool(preference_mqtt_log_enabled, false) || _preferences->getBool(preference_webserial_enabled, false)) @@ -101,9 +125,9 @@ void NetworkDevice::init() } void NetworkDevice::update() { - if (_mqttEnabled) + if (_mqttEnabled && !_mqttInternal) { - //getMqttClient()->loop(); + getMqttClient()->loop(); } } diff --git a/src/networkDevices/NetworkDevice.h b/src/networkDevices/NetworkDevice.h index 667bf64..4bf949e 100644 --- a/src/networkDevices/NetworkDevice.h +++ b/src/networkDevices/NetworkDevice.h @@ -64,6 +64,7 @@ protected: bool _useEncryption = false; bool _mqttEnabled = true; + bool _mqttInternal = false; char* _path; #endif From 586af011991d624cdd75b5db4d2a7d419db9271d Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 1 Apr 2025 23:10:01 +0200 Subject: [PATCH 15/15] 9.10 --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d3bc13a..50dd063 100644 --- a/README.md +++ b/README.md @@ -184,9 +184,14 @@ See [hybrid mode](/HYBRID.md) for more information. ESP32 devices have a limited amount of free RAM available.

-On version >=9.00 of Nuki Hub with only a Nuki Lock connected the expected free amount of RAM/Heap available is around: -- ESP32: 60 kilobytes / 60.000 bytes -- Other variants (C3/S3/C6/H2): 90-120 kilobytes / 90.000-120.000 bytes +On version >=9.10 of Nuki Hub with only a Nuki Lock connected the expected free amount of RAM/Heap available is around: + +- ESP32: 40.000 bytes +- ESP32 with PSRAM: 90.000 bytes + PSRAM +- ESP32-C3: 45.000 bytes +- ESP32-C6: 170.000 bytes +- ESP32-S3 90.000 bytes +- ESP32-S3 with PSRAM: 130.000 bytes + PSRAM This free amount of RAM can be reduced (temporarily) by certain actions (such as changing Nuki device config) or continuously when enabling the following: - Connecting both a Nuki opener and a Nuki lock to Nuki Hub @@ -697,13 +702,15 @@ When you are on the right application you can upload the new binary by clicking After about a minute the new firmware should be installed afterwhich the ESP will reboot automatically to the updated binary.
Selecting the wrong binary will lead to an unsuccessfull update

- Note for users upgrading from Nuki Hub 8.35 or lower:
-Updating to version 9.00 requires a change to the partition table of the ESP32.
-Please follow the instructions for the [First time installation](#first-time-installation) one time when updating to Nuki Hub 9.00 from an earlier version.
+ Note for users upgrading from Nuki Hub 9.09 or lower:
+Updating to version 9.10 requires a change to the partition table of the ESP32.
+Please follow the instructions for the [First time installation](#first-time-installation) one time when updating to Nuki Hub 9.10 from an earlier version.
## MQTT Encryption (optional) The communication via MQTT can be SSL encrypted.
+Note: MQTT SSL requires a significant amount of RAM and will not work in most cases on low RAM devices (ESP32 without PSRAM or ESP32-C3) + To enable SSL encryption, supply the necessary information in the MQTT Configuration page.

The following configurations are supported: