From 3ef9ec3ebf4602d5af8432311d07b2e93f585c28 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 8 Feb 2022 19:41:33 -0500 Subject: [PATCH] Make esp32 temperature measurement app commissionable (#14913) --- .../esp32/main/CMakeLists.txt | 1 + .../esp32/main/main.cpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index e1affc2fa6e11b..ba5b2c41c3c89e 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -47,6 +47,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook" PRIV_REQUIRES chip QRCode bt) diff --git a/examples/temperature-measurement-app/esp32/main/main.cpp b/examples/temperature-measurement-app/esp32/main/main.cpp index 146dcab7e527bd..c35d4f13b2941d 100644 --- a/examples/temperature-measurement-app/esp32/main/main.cpp +++ b/examples/temperature-measurement-app/esp32/main/main.cpp @@ -33,8 +33,10 @@ #include #include +#include #include #include +#include #include @@ -47,6 +49,19 @@ const char * TAG = "temperature-measurement-app"; static DeviceCallbacks EchoCallbacks; +namespace { + +app::Clusters::NetworkCommissioning::Instance + sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::ESPWiFiDriver::GetInstance())); + +static void InitServer(intptr_t context) +{ + chip::Server::GetInstance().Init(); + sWiFiNetworkCommissioningInstance.Init(); +} + +} // namespace + extern "C" void app_main() { ESP_LOGI(TAG, "Temperature sensor!"); @@ -80,7 +95,7 @@ extern "C" void app_main() return; } - chip::Server::GetInstance().Init(); + chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());