From 39fe8948f851bf6192f888b18c057799d7977daf Mon Sep 17 00:00:00 2001 From: Clifton Rawlings Date: Wed, 27 Jul 2022 09:21:13 -0700 Subject: [PATCH] Move UseECM check for StartAdvertisement (#21249) * Move UseECM check for StartAdvertisement Moved UseECM check above AppDelegate to ensure status is set before Commissioning Window is activated. * Fix restyle issue Co-authored-by: Boris Zbarsky --- src/app/server/AppDelegate.h | 7 +++++++ src/app/server/CommissioningWindowManager.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/server/AppDelegate.h b/src/app/server/AppDelegate.h index e722e1b41b8f00..49937c62d7168e 100644 --- a/src/app/server/AppDelegate.h +++ b/src/app/server/AppDelegate.h @@ -28,6 +28,13 @@ class AppDelegate virtual ~AppDelegate() {} virtual void OnCommissioningSessionStarted() {} virtual void OnCommissioningSessionStopped() {} + + /* + * This is called anytime a basic or enhanced commissioning window is opened. + * + * The type of the window can be retrieved by calling + * CommissioningWindowManager::CommissioningWindowStatus() + */ virtual void OnCommissioningWindowOpened() {} virtual void OnCommissioningWindowClosed() {} }; diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 5d1e574fe97c34..eaea53d90ec00d 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -374,11 +374,6 @@ CHIP_ERROR CommissioningWindowManager::StartAdvertisement() } #endif // CONFIG_NETWORK_LAYER_BLE - if (mAppDelegate != nullptr) - { - mAppDelegate->OnCommissioningWindowOpened(); - } - if (mUseECM) { mWindowStatus = AdministratorCommissioning::CommissioningWindowStatus::kEnhancedWindowOpen; @@ -388,6 +383,11 @@ CHIP_ERROR CommissioningWindowManager::StartAdvertisement() mWindowStatus = AdministratorCommissioning::CommissioningWindowStatus::kBasicWindowOpen; } + if (mAppDelegate != nullptr) + { + mAppDelegate->OnCommissioningWindowOpened(); + } + // reset all advertising, switching to our new commissioning mode. app::DnssdServer::Instance().StartServer();