From 10cf28bb35a3f6c3aa900cc87ac5b0f1675ad6e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Mar 2026 10:53:30 +0000 Subject: [PATCH 1/2] app_main: enable SRP auto-host-address to fix Thread commissioning The SRP client gets stuck in "Updated" state and never sends its SRP Update to the OTBR. Without an SRP Update, the OTBR never proxies the _matter._tcp record to mDNS, HA's matter-server cannot locate the device for CASE, and the FailSafe timer expires (t=200.6s), rolling back the entire commissioning (Thread dataset + NOC). Root cause: on ESP32 with WiFi present in the build (even when disabled via CONFIG_ENABLE_WIFI_STATION=n), the CHIP SDK does not reliably call otSrpClientSetHostAddresses() after Thread attaches. The SRP client has the _matter._tcp service queued but its host object has zero addresses, so OpenThread never transmits the SRP Update. Fix: call otSrpClientEnableAutoHostAddress() once on the CHIP/OpenThread task immediately after esp_matter::start(). This puts the SRP client into auto-host-address mode: OpenThread itself watches the Thread netif for address changes and keeps the SRP host addresses current, removing the dependency on the CHIP SDK calling otSrpClientSetHostAddresses() at the right moment. https://claude.ai/code/session_01SxqAiQApiRTwXefk9aQ6bR --- main/app_main.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main/app_main.cpp b/main/app_main.cpp index ebc701d..16592f4 100644 --- a/main/app_main.cpp +++ b/main/app_main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -246,6 +247,28 @@ extern "C" void app_main() ESP_LOGI(kTag, "Starting Matter stack (BLE commissioning + Thread FTD)"); ESP_ERROR_CHECK(start(app_event_cb)); + // Work-around: enable OpenThread's SRP auto-host-address mode so the SRP + // client always tracks the Thread interface's addresses (ML-EID + on-mesh + // global addresses) as the SRP host address. + // + // Without this the SRP client can be stuck in "Updated" state forever: + // it has the Matter operational service queued but otSrpClientSetHostAddresses() + // was never called by the CHIP SDK (a gap in its Thread-on-ESP32 integration + // when WiFi is also present in the build). No host address → no SRP Update + // sent → OTBR never proxies the _matter._tcp record to mDNS → HA's + // matter-server cannot reach the device for CASE → FailSafe expires → + // commissioning rolled back. + // + // ScheduleWork() runs on the CHIP/OpenThread shared task, so it is safe to + // call OpenThread APIs directly here without an explicit OpenThread lock. + chip::DeviceLayer::PlatformMgr().ScheduleWork([](intptr_t) { + otInstance *instance = esp_openthread_get_instance(); + if (instance != nullptr) { + otSrpClientEnableAutoHostAddress(instance); + ESP_LOGI(kTag, "SRP auto-host-address enabled"); + } + }, 0); + // app_main's task is no longer needed — the Matter stack owns its own tasks. // Deleting here reclaims the ~8 KB default stack and TCB immediately. vTaskDelete(nullptr); From bfc59cbef77bd2e5ddb238d07f57e69054c9a0a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Mar 2026 11:21:00 +0000 Subject: [PATCH 2/2] app_main: add missing for esp_openthread_get_instance() esp_openthread_get_instance() is declared in the ESP-IDF OpenThread component header , not in the CHIP SDK's OpenthreadLauncher.h. Fixes the build error introduced in the previous SRP workaround commit. https://claude.ai/code/session_01SxqAiQApiRTwXefk9aQ6bR --- main/app_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/main/app_main.cpp b/main/app_main.cpp index 16592f4..d954196 100644 --- a/main/app_main.cpp +++ b/main/app_main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include