From 1988866e29ea9cf943033bee91d212ebd0c4e57b Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Thu, 29 Sep 2022 10:04:06 -0400 Subject: [PATCH] Open basic commissioning window on pb0 press and release (#22940) --- examples/platform/efr32/BaseApplication.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/platform/efr32/BaseApplication.cpp b/examples/platform/efr32/BaseApplication.cpp index 3f8f584d87fe77..517f53de08a04d 100644 --- a/examples/platform/efr32/BaseApplication.cpp +++ b/examples/platform/efr32/BaseApplication.cpp @@ -414,7 +414,8 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) } else { - // If the button was released before factory reset got initiated, start BLE advertissement in fast mode + // If the button was released before factory reset got initiated, open the commissioning window and start BLE advertissement + // in fast mode if (mFunctionTimerActive && mFunction == kFunction_StartBleAdv) { CancelFunctionTimer(); @@ -431,9 +432,14 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) if (!ConnectivityMgr().IsThreadProvisioned()) #endif /* !SL_WIFI */ { - // Enable BLE advertisements - ConnectivityMgr().SetBLEAdvertisingEnabled(true); - ConnectivityMgr().SetBLEAdvertisingMode(ConnectivityMgr().kFastAdvertising); + // Open Basic CommissioningWindow. Will start BLE advertisements + chip::DeviceLayer::PlatformMgr().LockChipStack(); + CHIP_ERROR err = chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow(); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + if (err != CHIP_NO_ERROR) + { + EFR32_LOG("Failed to open the Basic Commissioning Window"); + } } else { EFR32_LOG("Network is already provisioned, Ble advertissement not enabled"); } }