From 11413997cd678e7500136b661d930cdaff3f4650 Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Mon, 12 Dec 2022 20:29:29 +0100 Subject: [PATCH] [SED] Fix Commissioning with Long Idle time (#23936) * Update Active Mode during commissioning * Apply comments --- src/app/server/CommissioningWindowManager.cpp | 18 ++++++++++-------- src/app/server/CommissioningWindowManager.h | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 949b46020373b2..6ce32d01bbbfa2 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -98,6 +98,14 @@ void CommissioningWindowManager::ResetState() mECMIterations = 0; mECMSaltLength = 0; +#if CHIP_DEVICE_CONFIG_ENABLE_SED + if (mSEDActiveModeEnabled) + { + DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(false); + mSEDActiveModeEnabled = false; + } +#endif + UpdateWindowStatus(CommissioningWindowStatus::kWindowNotOpen); UpdateOpenerFabricIndex(NullNullable); @@ -223,8 +231,9 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE() mPairingSession.Clear(); #if CHIP_DEVICE_CONFIG_ENABLE_SED - if (!mIsBLE && !mListeningForPASE) + if (!mSEDActiveModeEnabled) { + mSEDActiveModeEnabled = true; DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(true); } #endif @@ -455,13 +464,6 @@ CHIP_ERROR CommissioningWindowManager::StopAdvertisement(bool aShuttingDown) { RestoreDiscriminator(); -#if CHIP_DEVICE_CONFIG_ENABLE_SED - if (!mIsBLE && mListeningForPASE) - { - DeviceLayer::ConnectivityMgr().RequestSEDActiveMode(false); - } -#endif - mServer->GetExchangeManager().UnregisterUnsolicitedMessageHandlerForType(Protocols::SecureChannel::MsgType::PBKDFParamRequest); mListeningForPASE = false; mPairingSession.Clear(); diff --git a/src/app/server/CommissioningWindowManager.h b/src/app/server/CommissioningWindowManager.h index bb2cf00c8d8c3c..4222830ad5def1 100644 --- a/src/app/server/CommissioningWindowManager.h +++ b/src/app/server/CommissioningWindowManager.h @@ -203,6 +203,10 @@ class CommissioningWindowManager : public SessionEstablishmentDelegate, uint32_t mECMSaltLength = 0; uint8_t mECMSalt[kSpake2p_Max_PBKDF_Salt_Length]; +#if CHIP_DEVICE_CONFIG_ENABLE_SED + bool mSEDActiveModeEnabled = false; +#endif + // For tests only, so that we can test the commissioning window timeout // without having to wait 3 minutes. Optional mMinCommissioningTimeoutOverride;