Skip to content

Commit

Permalink
Open basic commissioning window on pb0 press and release (#22940)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinez-silabs authored Sep 29, 2022
1 parent 57c7321 commit 6d48f4b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/platform/efr32/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"); }
}
Expand Down

0 comments on commit 6d48f4b

Please sign in to comment.