Skip to content

Commit

Permalink
Make esp32 temperature measurement app commissionable
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Feb 8, 2022
1 parent 8d0fd6b commit e9815f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 16 additions & 1 deletion examples/temperature-measurement-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
#include <string>
#include <vector>

#include <app/clusters/network-commissioning/network-commissioning.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <platform/ESP32/NetworkCommissioningDriver.h>

#include <lib/support/ErrorStr.h>

Expand All @@ -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!");
Expand Down Expand Up @@ -80,7 +95,7 @@ extern "C" void app_main()
return;
}

chip::Server::GetInstance().Init();
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down

0 comments on commit e9815f8

Please sign in to comment.