From 11203da6326ed9a8c89af1139b28a6861a9e3763 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 4 Apr 2025 15:47:46 +0200 Subject: [PATCH 1/3] New commands --- lib/nuki_ble | 2 +- src/Config.h | 2 +- src/NukiWrapper.cpp | 37 ++++++++++++++++++++++++++++++++++++- src/NukiWrapper.h | 1 + 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/nuki_ble b/lib/nuki_ble index cf762e7..bd91181 160000 --- a/lib/nuki_ble +++ b/lib/nuki_ble @@ -1 +1 @@ -Subproject commit cf762e7dbd6ed501e9b719a7a4b9590ec85c7f99 +Subproject commit bd91181b3e3a182fb6e822077b6f0f3f711934cc diff --git a/src/Config.h b/src/Config.h index 5649086..1c669b2 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-04-02" +#define NUKI_HUB_DATE "2025-04-04" #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/NukiWrapper.cpp b/src/NukiWrapper.cpp index 3be7a82..48fc976 100644 --- a/src/NukiWrapper.cpp +++ b/src/NukiWrapper.cpp @@ -359,7 +359,8 @@ void NukiWrapper::update(bool reboot) { Log->println("Updating Lock config based on timer or query"); _nextConfigUpdateTs = ts + _intervalConfig * 1000; - updateConfig(); + updateConfig(); + updateDebug(); } if(_waitAuthLogUpdateTs != 0 && ts > _waitAuthLogUpdateTs) { @@ -728,6 +729,40 @@ void NukiWrapper::updateConfig() } } +void NukiWrapper::updateDebug() +{ + Nuki::CmdResult result = (Nuki::CmdResult)-1; + Log->println("Running debug command - RequestGeneralStatistics"); + result = _nukiLock.genericCommand(Nuki::Command::RequestGeneralStatistics); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + Log->println("Running debug command - RequestMqttConfig"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.genericCommand(Nuki::Command::RequestMqttConfig); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + + /* + RequestGeneralStatistics = 0x0063, + RequestMqttConfig = 0x008B, + + RequestInternalLogEntries = 0x0065, + RequestAccessoryInfo = 0x0091, + RequestMatterPairings = 0x0112 + CheckKeypadCode = 0x006E, + + SmartLockScanWifi = 0x0080, + SmartLockConnectWifi = 0x0082, + SmartLockSetWifiConfig = 0x0087, + SetMqttConfig = 0x008D, + SetKeypad2Config = 0x009C, + EnableMatterCommissioning = 0x0110, + SetMatterState = 0x0111, + */ +} + void NukiWrapper::updateAuthData(bool retrieved) { if(!isPinValid()) diff --git a/src/NukiWrapper.h b/src/NukiWrapper.h index 1fe4d1f..db1cc49 100644 --- a/src/NukiWrapper.h +++ b/src/NukiWrapper.h @@ -69,6 +69,7 @@ private: bool updateKeyTurnerState(); void updateBatteryState(); void updateConfig(); + void updateDebug(); void updateAuthData(bool retrieved); void updateKeypad(bool retrieved); void updateTimeControl(bool retrieved); From c42bd657cbb79f2426f87076eb36c3c70f4a7966 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 14 Apr 2025 21:10:55 +0200 Subject: [PATCH 2/3] New commands --- lib/nuki_ble | 2 +- sdkconfig.defaults | 2 +- src/Config.h | 2 +- src/NukiWrapper.cpp | 139 ++++++++++++++++++++++++++++++++++++++----- src/WebCfgServer.cpp | 2 +- 5 files changed, 128 insertions(+), 19 deletions(-) diff --git a/lib/nuki_ble b/lib/nuki_ble index bd91181..51eb268 160000 --- a/lib/nuki_ble +++ b/lib/nuki_ble @@ -1 +1 @@ -Subproject commit bd91181b3e3a182fb6e822077b6f0f3f711934cc +Subproject commit 51eb268f53efdf216ce32bba5d214c770dffff45 diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 0d140b4..765cffb 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -82,7 +82,7 @@ CONFIG_BT_NIMBLE_NVS_PERSIST=y CONFIG_BT_NIMBLE_GATT_MAX_PROCS=8 CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=y CONFIG_BT_NIMBLE_PINNED_TO_CORE=0 -CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=8192 +CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=12288 CONFIG_BT_NIMBLE_ROLE_CENTRAL=y CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=n CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y diff --git a/src/Config.h b/src/Config.h index 95d5acd..a2d5810 100644 --- a/src/Config.h +++ b/src/Config.h @@ -5,7 +5,7 @@ #define NUKI_HUB_VERSION "9.11" #define NUKI_HUB_VERSION_INT (uint32_t)911 #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2025-04-06" +#define NUKI_HUB_DATE "2025-05-05" #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/NukiWrapper.cpp b/src/NukiWrapper.cpp index 48fc976..e8e363b 100644 --- a/src/NukiWrapper.cpp +++ b/src/NukiWrapper.cpp @@ -359,7 +359,7 @@ void NukiWrapper::update(bool reboot) { Log->println("Updating Lock config based on timer or query"); _nextConfigUpdateTs = ts + _intervalConfig * 1000; - updateConfig(); + updateConfig(); updateDebug(); } if(_waitAuthLogUpdateTs != 0 && ts > _waitAuthLogUpdateTs) @@ -732,34 +732,143 @@ void NukiWrapper::updateConfig() void NukiWrapper::updateDebug() { Nuki::CmdResult result = (Nuki::CmdResult)-1; + int count = 0; + Log->println("Running debug command - RequestGeneralStatistics"); + result = (Nuki::CmdResult)-1; result = _nukiLock.genericCommand(Nuki::Command::RequestGeneralStatistics); Log->print("Result: "); Log->println(result); Log->println("Debug command complete"); + Log->println("Running debug command - RequestDailyStatistics"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.requestDailyStatistics(); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); Log->println("Running debug command - RequestMqttConfig"); result = (Nuki::CmdResult)-1; result = _nukiLock.genericCommand(Nuki::Command::RequestMqttConfig); Log->print("Result: "); Log->println(result); Log->println("Debug command complete"); + Log->println("Running debug command - RequestMqttConfigForMigration"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.genericCommand(Nuki::Command::RequestMqttConfigForMigration); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + Log->println("Running debug command - ReadWifiConfig"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.genericCommand(Nuki::Command::ReadWifiConfig); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + Log->println("Running debug command - ReadWifiConfigForMigration"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.genericCommand(Nuki::Command::ReadWifiConfigForMigration); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + Log->println("Running debug command - GetKeypad2Config"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.genericCommand(Nuki::Command::GetKeypad2Config, false); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + Log->println("Running debug command - RequestFingerprintEntries"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.retrieveFingerprintEntries(); + Log->print("Result: "); + Log->println(result); + count = 0; + while (count < 5) { + delay(1000); + esp_task_wdt_reset(); + count++; + } + + std::list fingerprintEntries; + _nukiLock.getFingerprintEntries(&fingerprintEntries); + + Log->print("Fingerprint entries: "); + Log->println(fingerprintEntries.size()); + Log->println("Debug command complete"); + + Log->println("Running debug command - RequestInternalLogEntries"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.retrieveInternalLogEntries(0, 10, 1, false); + Log->print("Result: "); + Log->println(result); + + count = 0; + while (count < 15) { + delay(1000); + esp_task_wdt_reset(); + count++; + } + + std::list internalLogEntries; + _nukiLock.getInternalLogEntries(&internalLogEntries); + + Log->print("InternalLog entries: "); + Log->println(internalLogEntries.size()); + Log->println("Debug command complete"); + + Log->println("Running debug command - scanWifi"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.scanWifi(15); + Log->print("Result: "); + Log->println(result); + + count = 0; + while (count < 20) { + delay(1000); + esp_task_wdt_reset(); + count++; + } + + std::list wifiScanEntries; + _nukiLock.getWifiScanEntries(&wifiScanEntries); + + Log->print("WifiScan entries: "); + Log->println(wifiScanEntries.size()); + Log->println("Debug command complete"); + + Log->println("Running debug command - getAccessoryInfo, type = 4"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.getAccessoryInfo(4); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + + Log->println("Running debug command - getAccessoryInfo, type = 5"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.getAccessoryInfo(5); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); + + Log->println("Running debug command - RequestDoorSensorConfig"); + result = (Nuki::CmdResult)-1; + result = _nukiLock.genericCommand(Nuki::Command::RequestDoorSensorConfig, false); + Log->print("Result: "); + Log->println(result); + Log->println("Debug command complete"); /* - RequestGeneralStatistics = 0x0063, - RequestMqttConfig = 0x008B, - - RequestInternalLogEntries = 0x0065, - RequestAccessoryInfo = 0x0091, - RequestMatterPairings = 0x0112 - CheckKeypadCode = 0x006E, + CheckKeypadCode = 0x006E keypadCode (int), (nonce, PIN) - SmartLockScanWifi = 0x0080, - SmartLockConnectWifi = 0x0082, - SmartLockSetWifiConfig = 0x0087, - SetMqttConfig = 0x008D, - SetKeypad2Config = 0x009C, - EnableMatterCommissioning = 0x0110, - SetMatterState = 0x0111, + RequestMatterPairings = 0x0112 requestTotalCount (bool), (nonce, PIN) + MatterPairing = 0x0113 + MatterPairingCount = 0x0114 + + ConnectWifi = 0x0082 + SetWifiConfig = 0x0087 + SetMqttConfig = 0x008D + SetKeypad2Config = 0x009C + EnableMatterCommissioning = 0x0110 + SetMatterState = 0x0111 */ } diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index e08b052..53614d2 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -6642,7 +6642,7 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request, PsychicResponse* response.print("\n\n------------ GPIO ------------\n"); response.print("\nRetain Input GPIO MQTT state: "); - response.print(_preferences->getBool(preference_retain_gpio, false) ? "Yes" : "No"); + response.print(_preferences->getBool(preference_retain_gpio, false) ? "Yes\n" : "No\n"); String gpioStr = ""; _gpio->getConfigurationText(gpioStr, _gpio->pinConfiguration()); response.print(gpioStr); From fc1ee70a2c51226b12b0d7544d443e3198bcbe1d Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 9 Jun 2025 21:58:55 +0200 Subject: [PATCH 3/3] P4 Fixes --- README.md | 25 +++++++----- platformio.ini | 8 ++-- resources/how-to-flash.txt | 4 +- sdkconfig.defaults.esp32-p4 | 1 - src/Config.h | 19 ++++++++- src/NukiWrapper.cpp | 6 ++- src/NukiWrapper.h | 1 + src/WebCfgServer.cpp | 3 ++ src/enums/NetworkDeviceType.h | 3 ++ src/networkDevices/WifiDevice.cpp | 46 +++++++++++++--------- src/util/NetworkDeviceInstantiator.cpp | 53 +++++++++++++++++++++++++- src/util/NetworkUtil.cpp | 8 +++- updater/platformio.ini | 4 +- updater/sdkconfig.defaults.esp32-p4 | 30 ++++++++++----- 14 files changed, 162 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 2b0547a..558da8e 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Feel free to join us on Discord: https://discord.gg/9nPq85bP4p Supported ESP32 devices: - Nuki Hub is compiled against all ESP32 models with Wi-Fi and Bluetooh Low Energy (BLE) which are supported by ESP-IDF 5.4.1 and Arduino Core 3.2.0. -- Tested stable builds are provided for the ESP32, ESP32-S3, ESP32-C3, ESP32-C6 and ESP32-H2. -- Untested builds are provided for the ESP32-P4 (with the ESP32-C6-MINI-1 module for BLE and WiFi) and ESP32-Solo1 (as the developers don't own one). +- Tested stable builds are provided for the ESP32, ESP32-S3, ESP32-C3, ESP32-C6, ESP32-P4 (with the ESP32-C6-MINI-1 module for BLE and WiFi) and ESP32-H2. +- Untested builds are provided for the ESP32-Solo1 (as the developers don't own one). Not supported ESP32 devices: - The ESP32-S2 has no built-in BLE and as such can't run Nuki Hub. @@ -49,6 +49,9 @@ As an alternative to Wi-Fi (which is available on any supported ESP32), the foll - [LilyGO-T-ETH ELite](https://github.com/Xinyuan-LilyGO/LilyGO-T-ETH-Series) - [GL-S10 (Revisions 2.1, 2.3 / 1.0 might not be supported)](https://www.gl-inet.com/products/gl-s10/) - [Waveshare ESP32-S3-ETH / ESP32-S3-POE-ETH](https://www.waveshare.com/esp32-s3-eth.htm?sku=28771) +- [Waveshare ESP32-P4-NANO](https://www.waveshare.com/esp32-p4-nano.htm) +- [Waveshare ESP32-P4-Module-DEV-KIT](https://www.waveshare.com/esp32-p4-module-dev-kit.htm) +- [Espressif ESP32-P4-Function-EV-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html) In principle all ESP32 (and variants) devices with built-in ethernet port are supported, but might require additional setup using the "Custom LAN setup" option. See the "[Connecting via Ethernet](#connecting-via-ethernet-optional)" section for more information. @@ -59,20 +62,24 @@ We don't recommend using single-core ESP32 devices (ESP32-C3, ESP32-C6, ESP32-H2 Although Nuki Hub supports single-core devices, Nuki Hub uses both CPU cores (if available) to process tasks (e.g. HTTP server/MQTT client/BLE scanner/BLE client) and thus runs much better on dual-core devices.
We also don't recommend using the original ESP32 or ESP32-Solo1 devices because these devices experience unexpected crashes related to the (closed-source) BLE controller.
-In all newer models (e.g. ESP32-S3, ESP32-P4, ESP32-C3, ESP32-C6, ESP32-H2) these unexpected crashed haven't been seen. +In newer models (e.g. ESP32-S3, ESP32-P4, ESP32-C3, ESP32-C6, ESP32-H2) these unexpected crashes are seen less. + +When buying a new device in 2025 we can only recommend the ESP32-P4 or ESP32-S3 with PSRAM (look for an ESP32-S3 with the designation N>=4 and R>=2 such as an ESP32-S3 N16R8).
+ +The ESP32-P4 with ESP32-C6-MINI-1 module for BLE/WiFi is the most powerfull ESP32 in 2025. +It supports (with the C6 co-processor) anything the ESP32 range has to offer with the highest CPU clocks, largest flash and PSRAM, Ethernet, PoE and WiFi6. +The only function missing (when not using a C5 as co-processor) is 5Ghz WiFi support. -When buying a new device in 2025 we can only recommend the ESP32-S3 with PSRAM (look for an ESP32-S3 with the designation N>=4 and R>=2 such as an ESP32-S3 N16R8).
The ESP32-S3 is a dual-core CPU with many GPIO's, ability to enlarge RAM using PSRAM, ability to connect Ethernet modules over SPI and optionally power the device with a PoE splitter.
The only functions missing from the ESP32-S3 as compared to other ESP devices is the ability to use some Ethernet modules only supported by the original ESP32 (and ESP32-P4) and the ability to connect over WIFI6 (C6 or ESP32-P4 with C6 module) -We provide a build for the ESP32-P4 with ESP32-C6-MINI-1 module for BLE/WiFi but this device is untested as of now. - Other considerations: -- If Ethernet/PoE is required: An ESP32-S3 with PSRAM in combination with a SPI Ethernet module ([W5500](https://www.aliexpress.com/w/wholesale-w5500.html)) and [PoE to Ethernet and USB type B/C splitter](https://aliexpress.com/w/wholesale-poe-splitter-usb-c.html) or the LilyGO-T-ETH ELite, LilyGO-T-ETH-Lite-ESP32S3 or M5stack Atom S3R with the M5stack AtomPoe W5500 module -- If WIFI6 is absolutely required (it probably isn't): ESP32-C6 or ESP32-P4 with ESP32-C6-MINI-1 module (UNTESTED) +- If Ethernet/PoE is required: ESP32-P4 with ESP32-C6-MINI-1 module or ESP32-S3 with PSRAM in combination with a SPI Ethernet module ([W5500](https://www.aliexpress.com/w/wholesale-w5500.html)) and [PoE to Ethernet and USB type B/C splitter](https://aliexpress.com/w/wholesale-poe-splitter-usb-c.html) or the LilyGO-T-ETH ELite, LilyGO-T-ETH-Lite-ESP32S3 or M5stack Atom S3R with the M5stack AtomPoe W5500 module +- If WIFI6 is absolutely required: ESP32-P4 with ESP32-C6-MINI-1 module or ESP32-C6 Devices ranked best-to-worst: -- ESP32-P4 with ESP32-C6-MINI-1 module (UNTESTED) +- ESP32-P4 with ESP32-C6-MINI-1 module +- ......
- ESP32-S3 with PSRAM - ......
(Devices below will not support some Nuki Hub functions, be slower and/or are more likely to experience unexpected crashes) diff --git a/platformio.ini b/platformio.ini index bb62438..3292efe 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/platform-espressif32.zip +platform = https://github.com/iranl/nuki_hub/raw/refs/heads/binary/platform-espressif32.zip platform_packages = framework = arduino, espidf board_build.embed_txtfiles = @@ -43,7 +43,7 @@ build_flags = -DNUKI_NO_WDT_RESET -DNUKI_MUTEX_RECURSIVE -DNUKI_64BIT_TIME - -DETH_SPI_SUPPORTS_NO_IRQ + -DETH_SPI_SUPPORTS_NO_IRQ -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-type-limits @@ -137,6 +137,8 @@ board_build.cmake_extra_args = extends = env:esp32 board_build.embed_txtfiles = board = esp32-p4 +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.release.defaults;sdkconfig.defaults.esp32-p4" build_flags = ${env.build_flags} -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE @@ -166,7 +168,7 @@ build_flags = extends = env:esp32-gl-s10 custom_build = debug board_build.cmake_extra_args = - -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32;sdkconfig.gls10.defaults" + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.debug.defaults;sdkconfig.defaults.esp32;sdkconfig.gls10.defaults" build_flags = ${env:esp32_dbg.build_flags} -DNUKI_TARGET_GL_S10=y diff --git a/resources/how-to-flash.txt b/resources/how-to-flash.txt index d39ab21..a874353 100644 --- a/resources/how-to-flash.txt +++ b/resources/how-to-flash.txt @@ -73,7 +73,7 @@ e000 boot_app0.bin ESP32-P4 e000 boot_app0.bin -0 nuki_hub_bootloader_esp32p4.bin +2000 nuki_hub_bootloader_esp32p4.bin 8000 nuki_hub_partitions_esp32p4.bin 10000 nuki_hub_esp32p4.bin 270000 nuki_hub_updater_esp32p4.bin @@ -127,7 +127,7 @@ esptool.py --chip esp32h2 --port /dev/ttyUSB0 --baud 921600 --before default_res ## 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 nuki_hub_bootloader_esp32p4.bin 0x10000 nuki_hub_esp32p4.bin 0x270000 nuki_hub_updater_esp32p4.bin 0x8000 nuki_hub_partitions_esp32p4.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 0x2000 nuki_hub_bootloader_esp32p4.bin 0x10000 nuki_hub_esp32p4.bin 0x270000 nuki_hub_updater_esp32p4.bin 0x8000 nuki_hub_partitions_esp32p4.bin ## ESP32-SOLO1 diff --git a/sdkconfig.defaults.esp32-p4 b/sdkconfig.defaults.esp32-p4 index affa10c..c6dcc6b 100644 --- a/sdkconfig.defaults.esp32-p4 +++ b/sdkconfig.defaults.esp32-p4 @@ -32,7 +32,6 @@ CONFIG_BT_CONTROLLER_DISABLED=y CONFIG_BT_BLUEDROID_ENABLED=n CONFIG_BT_NIMBLE_TRANSPORT_UART=n CONFIG_ESP_ENABLE_BT=y -CONFIG_ESP32_P4_EV_BOARD=y CONFIG_BT_NIMBLE_ENABLED=y CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE=y CONFIG_SLAVE_IDF_TARGET_ESP32C6=y \ No newline at end of file diff --git a/src/Config.h b/src/Config.h index a2d5810..1666f70 100644 --- a/src/Config.h +++ b/src/Config.h @@ -5,12 +5,27 @@ #define NUKI_HUB_VERSION "9.11" #define NUKI_HUB_VERSION_INT (uint32_t)911 #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2025-05-05" +#define NUKI_HUB_DATE "2025-06-09" #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" -#if defined(CONFIG_IDF_TARGET_ESP32C3) +#if defined(CONFIG_IDF_TARGET_ESP32P4) +#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32p4.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32p4.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32p4.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_updater_esp32p4.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_esp32p4.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_updater_esp32p4.bin" +#define GITHUB_LATEST_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/nuki_hub_esp32p4.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/nuki_hub_updater_esp32p4.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/beta/nuki_hub_esp32p4.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/beta/nuki_hub_updater_esp32p4.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_esp32p4.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL_DBG (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/debug/master/nuki_hub_updater_esp32p4.bin" +#define NUKI_HUB_HW (char*)"ESP32-P4" +#define BOOT_BUTTON_GPIO (gpio_num_t)35 +#elif defined(CONFIG_IDF_TARGET_ESP32C3) #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32c3.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32c3.bin" #define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32c3.bin" diff --git a/src/NukiWrapper.cpp b/src/NukiWrapper.cpp index e8e363b..9dc8c2e 100644 --- a/src/NukiWrapper.cpp +++ b/src/NukiWrapper.cpp @@ -162,6 +162,7 @@ void NukiWrapper::readSettings() _forceKeypad = _preferences->getBool(preference_lock_force_keypad, false); _forceId = _preferences->getBool(preference_lock_force_id, false); _isUltra = _preferences->getBool(preference_lock_gemini_enabled, false); + _isDebugging = _preferences->getBool(preference_debug_hex_data, false); _preferences->getBytes(preference_conf_lock_basic_acl, &_basicLockConfigaclPrefs, sizeof(_basicLockConfigaclPrefs)); _preferences->getBytes(preference_conf_lock_advanced_acl, &_advancedLockConfigaclPrefs, sizeof(_advancedLockConfigaclPrefs)); @@ -360,7 +361,10 @@ void NukiWrapper::update(bool reboot) Log->println("Updating Lock config based on timer or query"); _nextConfigUpdateTs = ts + _intervalConfig * 1000; updateConfig(); - updateDebug(); + if(_isDebugging) + { + updateDebug(); + } } if(_waitAuthLogUpdateTs != 0 && ts > _waitAuthLogUpdateTs) { diff --git a/src/NukiWrapper.h b/src/NukiWrapper.h index db1cc49..1f132f9 100644 --- a/src/NukiWrapper.h +++ b/src/NukiWrapper.h @@ -141,6 +141,7 @@ private: bool _keypadEnabled = false; bool _forceId = false; bool _isUltra = false; + bool _isDebugging = false; uint _maxKeypadCodeCount = 0; uint _maxTimeControlEntryCount = 0; uint _maxAuthEntryCount = 0; diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 2522f5e..1f98a11 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -6977,6 +6977,9 @@ const std::vector> WebCfgServer::getNetworkDetectionOp 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("15", "Waveshare ESP32-P4-NANO")); + options.push_back(std::make_pair("16", "Waveshare ESP32-P4-Module-DEV-KIT")); + options.push_back(std::make_pair("17", "ESP32-P4-Function-EV-Board")); 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 68e2f69..a283c63 100644 --- a/src/enums/NetworkDeviceType.h +++ b/src/enums/NetworkDeviceType.h @@ -15,5 +15,8 @@ enum class NetworkDeviceType ETH01_Evo, Waveshare_ESP32_S3_ETH, LilyGO_T_ETH_Lite_S3, + Waveshare_ESP32_P4_NANO, + Waveshare_ESP32_P4_Module_DEV_KIT, + ESP32_P4_Function_EV_Board, CUSTOM }; \ No newline at end of file diff --git a/src/networkDevices/WifiDevice.cpp b/src/networkDevices/WifiDevice.cpp index 21da624..f518b46 100644 --- a/src/networkDevices/WifiDevice.cpp +++ b/src/networkDevices/WifiDevice.cpp @@ -20,29 +20,39 @@ const String WifiDevice::deviceName() const void WifiDevice::initialize() { - ssid = _preferences->getString(preference_wifi_ssid, ""); - ssid.trim(); - pass = _preferences->getString(preference_wifi_pass, ""); - pass.trim(); - WiFi.setHostname(_hostname.c_str()); + if (_hostname != "fakep4forhosted") { + ssid = _preferences->getString(preference_wifi_ssid, ""); + ssid.trim(); + pass = _preferences->getString(preference_wifi_pass, ""); + pass.trim(); + WiFi.setHostname(_hostname.c_str()); - WiFi.onEvent([&](WiFiEvent_t event, WiFiEventInfo_t info) - { - onWifiEvent(event, info); - }); + WiFi.onEvent([&](WiFiEvent_t event, WiFiEventInfo_t info) + { + onWifiEvent(event, info); + }); - if(isWifiConfigured()) - { - Log->println(String("Attempting to connect to saved SSID ") + String(ssid)); - _openAP = false; + if(isWifiConfigured()) + { + Log->println(String("Attempting to connect to saved SSID ") + String(ssid)); + _openAP = false; + } + else + { + Log->println("No SSID or Wifi password saved, opening AP"); + _openAP = true; + } + + scan(false, true); } else { - Log->println("No SSID or Wifi password saved, opening AP"); - _openAP = true; + WiFi.disconnect(true); + WiFi.mode(WIFI_STA); + WiFi.disconnect(); + delay(5000); + Log->println("Dummy WiFi device for Hosted on P4 done"); } - - scan(false, true); return; } @@ -177,7 +187,7 @@ bool WifiDevice::connect() } return false; - } + } return true; } diff --git a/src/util/NetworkDeviceInstantiator.cpp b/src/util/NetworkDeviceInstantiator.cpp index 05ef8c0..48fcf38 100644 --- a/src/util/NetworkDeviceInstantiator.cpp +++ b/src/util/NetworkDeviceInstantiator.cpp @@ -11,6 +11,9 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDeviceType, String hostname, Preferences *preferences, IPConfiguration *ipConfiguration) { NetworkDevice* device = nullptr; + #if defined(CONFIG_IDF_TARGET_ESP32P4) + bool fakedevice = true; + #endif switch (networkDeviceType) { @@ -91,7 +94,35 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDevice ETH_PHY_SPI_MOSI_ETHLITES3_W5500, ETH_PHY_W5500); break; - + #if defined(CONFIG_IDF_TARGET_ESP32P4) + case NetworkDeviceType::Waveshare_ESP32_P4_NANO: + device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-P4-NANO", + 1, + 51, + 31, + 52, + ETH_PHY_IP101, + ETH_CLOCK_GPIO0_IN); + break; + case NetworkDeviceType::Waveshare_ESP32_P4_Module_DEV_KIT: + device = new EthernetDevice(hostname, preferences, ipConfiguration, "Waveshare ESP32-P4-Module-DEV-KIT", + 1, + 51, + 31, + 52, + ETH_PHY_IP101, + ETH_CLOCK_GPIO0_IN); + break; + case NetworkDeviceType::ESP32_P4_Function_EV_Board: + device = new EthernetDevice(hostname, preferences, ipConfiguration, "ESP32-P4-Function-EV-Board", + 1, + 51, + 31, + 52, + ETH_PHY_IP101, + ETH_CLOCK_GPIO0_IN); + break; + #endif case NetworkDeviceType::CUSTOM: { int custPHY = preferences->getInt(preference_network_custom_phy, 0); @@ -153,6 +184,9 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDevice else { device = new WifiDevice(hostname, preferences, ipConfiguration); + #if defined(CONFIG_IDF_TARGET_ESP32P4) + fakedevice = false; + #endif } #endif } @@ -183,9 +217,15 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDevice #ifndef CONFIG_IDF_TARGET_ESP32H2 case NetworkDeviceType::WiFi: device = new WifiDevice(hostname, preferences, ipConfiguration); + #if defined(CONFIG_IDF_TARGET_ESP32P4) + fakedevice = false; + #endif break; default: device = new WifiDevice(hostname, preferences, ipConfiguration); + #if defined(CONFIG_IDF_TARGET_ESP32P4) + fakedevice = false; + #endif break; #else default: @@ -202,5 +242,16 @@ NetworkDevice *NetworkDeviceInstantiator::Create(NetworkDeviceType networkDevice #endif } + #if defined(CONFIG_IDF_TARGET_ESP32P4) + if (fakedevice) { + Log->println("Create dummy WiFi device for Hosted on P4"); + NetworkDevice* device2 = nullptr; + device2 = new WifiDevice("fakep4forhosted", preferences, ipConfiguration); + device2->initialize(); + delete device2; + device2 = NULL; + } + #endif + return device; } diff --git a/src/util/NetworkUtil.cpp b/src/util/NetworkUtil.cpp index 0d4633a..dbaf092 100644 --- a/src/util/NetworkUtil.cpp +++ b/src/util/NetworkUtil.cpp @@ -38,6 +38,12 @@ NetworkDeviceType NetworkUtil::GetDeviceTypeFromPreference(int hardwareDetect, i return NetworkDeviceType::Waveshare_ESP32_S3_ETH; case 14: return NetworkDeviceType::LilyGO_T_ETH_Lite_S3; + case 15: + return NetworkDeviceType::Waveshare_ESP32_P4_NANO; + case 16: + return NetworkDeviceType::Waveshare_ESP32_P4_Module_DEV_KIT; + case 17: + return NetworkDeviceType::ESP32_P4_Function_EV_Board; default: Log->println("Unknown hardware selected, falling back to Wi-Fi."); return NetworkDeviceType::WiFi; @@ -101,7 +107,7 @@ eth_clock_mode_t NetworkUtil::GetCustomClock(int custCLKpref) case 0: return ETH_CLOCK_GPIO0_IN; break; - case 1: + case 1: return ETH_CLOCK_GPIO0_OUT; break; case 2: diff --git a/updater/platformio.ini b/updater/platformio.ini index 477b11a..8ac988b 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/platform-espressif32.zip +platform = https://github.com/iranl/nuki_hub/raw/refs/heads/binary/platform-espressif32.zip platform_packages = framework = arduino, espidf board_build.embed_txtfiles = @@ -100,6 +100,8 @@ board = esp32-c6-devkitm-1 extends = env:updater_esp32 board_build.embed_txtfiles = board = esp32-p4 +board_build.cmake_extra_args = + -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.esp32-p4" build_flags = ${env.build_flags} -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE diff --git a/updater/sdkconfig.defaults.esp32-p4 b/updater/sdkconfig.defaults.esp32-p4 index b8c91d6..958ef78 100644 --- a/updater/sdkconfig.defaults.esp32-p4 +++ b/updater/sdkconfig.defaults.esp32-p4 @@ -2,8 +2,16 @@ CONFIG_SPIRAM=y CONFIG_SPIRAM_IGNORE_NOTFOUND=y CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y -CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 + CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 + +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534 +CONFIG_LWIP_TCP_WND_DEFAULT=65534 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=64 +CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64 +CONFIG_LWIP_TCP_SACK_OUT=y + CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16 CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64 CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64 @@ -11,14 +19,7 @@ CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y CONFIG_ESP_WIFI_TX_BA_WIN=32 CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y CONFIG_ESP_WIFI_RX_BA_WIN=32 -CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534 -CONFIG_LWIP_TCP_WND_DEFAULT=65534 -CONFIG_LWIP_TCP_RECVMBOX_SIZE=64 -CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 -CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64 -CONFIG_LWIP_TCP_SACK_OUT=y -CONFIG_BT_NIMBLE_TRANSPORT_UART=n -CONFIG_ESP_HCI_VHCI=y + CONFIG_ESP_WIFI_REMOTE_ENABLED=y CONFIG_ESP_WIFI_REMOTE_LIBRARY_HOSTED=y CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=7 @@ -26,4 +27,13 @@ CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=32 CONFIG_ESP_WIFI_TX_BUFFER_TYPE=0 CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16 CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 -CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 \ No newline at end of file +CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 + +CONFIG_ESP_HCI_VHCI=y +CONFIG_BT_CONTROLLER_DISABLED=y +CONFIG_BT_BLUEDROID_ENABLED=n +CONFIG_BT_NIMBLE_TRANSPORT_UART=n +CONFIG_ESP_ENABLE_BT=y +CONFIG_BT_NIMBLE_ENABLED=y +CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE=y +CONFIG_SLAVE_IDF_TARGET_ESP32C6=y \ No newline at end of file