Skip to content

Commit

Permalink
Fix active mode (fast-poll) management in CommissioningWindowManager. (
Browse files Browse the repository at this point in the history
…#23298)

Without this fix we could end up in the following situation:

1. Open a commissioning window when operational.  Enter active mode in
   StartAdvertisement.
2. Establish a PASE session.  Leave active mode in StopAdvertisement.
3. Commissioning fails, fail-safe triggers.
4. We call StartAdvertisement, but do not enter active mode, because
   IsCommissioningWindowOpen() is true at this point.

The fix is to ensure that our RequestSEDActiveMode() calls happen
exacty when mListeningForPASE chages value, since that's the reason we
want to be messing with active mode to start with.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Oct 12, 2023
1 parent 7df0c25 commit fbe1b3a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE()

mPairingSession.Clear();

#if CHIP_DEVICE_CONFIG_ENABLE_SED
if (!mIsBLE && !mListeningForPASE)
{
DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(true);
}
#endif

ReturnErrorOnFailure(mServer->GetExchangeManager().RegisterUnsolicitedMessageHandlerForType(
Protocols::SecureChannel::MsgType::PBKDFParamRequest, &mPairingSession));
mListeningForPASE = true;
Expand Down Expand Up @@ -400,13 +407,6 @@ CHIP_ERROR CommissioningWindowManager::StartAdvertisement()
DeviceLayer::ConfigurationMgr().NotifyOfAdvertisementStart();
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_SED
if (!mIsBLE && !IsCommissioningWindowOpen())
{
DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(true);
}
#endif

#if CONFIG_NETWORK_LAYER_BLE
if (mIsBLE)
{
Expand Down Expand Up @@ -446,17 +446,17 @@ CHIP_ERROR CommissioningWindowManager::StopAdvertisement(bool aShuttingDown)
{
RestoreDiscriminator();

mServer->GetExchangeManager().UnregisterUnsolicitedMessageHandlerForType(Protocols::SecureChannel::MsgType::PBKDFParamRequest);
mListeningForPASE = false;
mPairingSession.Clear();

#if CHIP_DEVICE_CONFIG_ENABLE_SED
if (!mIsBLE && IsCommissioningWindowOpen())
if (!mIsBLE && mListeningForPASE)
{
DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(false);
}
#endif

mServer->GetExchangeManager().UnregisterUnsolicitedMessageHandlerForType(Protocols::SecureChannel::MsgType::PBKDFParamRequest);
mListeningForPASE = false;
mPairingSession.Clear();

// If aShuttingDown, don't try to change our DNS-SD advertisements.
if (!aShuttingDown)
{
Expand Down

0 comments on commit fbe1b3a

Please sign in to comment.