From 67e6e83148102a69629a6e5bb0fbb78cbed64bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:25:54 +0100 Subject: [PATCH] [admin] Do not enable BLE advertising in response to admin commands (#12287) AdministratorCommissioning commands for opening the commissioning window on a peer device, enable BLE advertising while only the operational network shall be used for subsequent commissionings. --- .../administrator-commissioning-server.cpp | 4 ++-- src/app/server/CommissioningWindowManager.cpp | 7 ++----- src/app/tests/TestCommissionManager.cpp | 6 +++++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp index d7e260005ed39b..568f6ee4015c45 100644 --- a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp +++ b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp @@ -96,8 +96,8 @@ bool emberAfAdministratorCommissioningClusterOpenBasicCommissioningWindowCallbac status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); VerifyOrExit(commissioningTimeout <= kMaxCommissionioningTimeoutSeconds, status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow(commissioningTimeout) == - CHIP_NO_ERROR, + VerifyOrExit(Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow( + commissioningTimeout, CommissioningWindowAdvertisement::kDnssdOnly) == CHIP_NO_ERROR, status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); ChipLogProgress(Zcl, "Commissioning window is now open"); diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index e19cfcd7cfd4b1..adf501554c8cd2 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -229,12 +229,9 @@ CHIP_ERROR CommissioningWindowManager::OpenEnhancedCommissioningWindow(uint16_t PASEVerifier & verifier, uint32_t iterations, ByteSpan salt, uint16_t passcodeID) { -#if CONFIG_NETWORK_LAYER_BLE - // TODO: Don't use BLE for commissioning additional fabrics on a device - SetBLE(true); -#else + // Once a device is operational, it shall be commissioned into subsequent fabrics using + // the operational network only. SetBLE(false); -#endif VerifyOrReturnError(salt.size() <= sizeof(mECMSalt), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/src/app/tests/TestCommissionManager.cpp b/src/app/tests/TestCommissionManager.cpp index 32fa2774b5b0bc..8ab70f6f72469c 100644 --- a/src/app/tests/TestCommissionManager.cpp +++ b/src/app/tests/TestCommissionManager.cpp @@ -47,8 +47,9 @@ void InitializeChip(nlTestSuite * suite) err = chip::DeviceLayer::PlatformMgr().InitChipStack(); NL_TEST_ASSERT(suite, err == CHIP_NO_ERROR); err = Server::GetInstance().Init(); - chip::DeviceLayer::PlatformMgr().StartEventLoopTask(); NL_TEST_ASSERT(suite, err == CHIP_NO_ERROR); + Server::GetInstance().GetCommissioningWindowManager().CloseCommissioningWindow(); + chip::DeviceLayer::PlatformMgr().StartEventLoopTask(); } void CheckCommissioningWindowManagerBasicWindowOpenCloseTask(intptr_t context) @@ -59,6 +60,7 @@ void CheckCommissioningWindowManagerBasicWindowOpenCloseTask(intptr_t context) commissionMgr.OpenBasicCommissioningWindow(kNoCommissioningTimeout, CommissioningWindowAdvertisement::kDnssdOnly); NL_TEST_ASSERT(suite, err == CHIP_NO_ERROR); NL_TEST_ASSERT(suite, commissionMgr.IsCommissioningWindowOpen()); + NL_TEST_ASSERT(suite, !chip::DeviceLayer::ConnectivityMgr().IsBLEAdvertisingEnabled()); commissionMgr.CloseCommissioningWindow(); NL_TEST_ASSERT(suite, !commissionMgr.IsCommissioningWindowOpen()); } @@ -87,6 +89,7 @@ void CheckCommissioningWindowManagerWindowTimeoutTask(intptr_t context) CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds, CommissioningWindowAdvertisement::kDnssdOnly); NL_TEST_ASSERT(suite, err == CHIP_NO_ERROR); NL_TEST_ASSERT(suite, commissionMgr.IsCommissioningWindowOpen()); + NL_TEST_ASSERT(suite, !chip::DeviceLayer::ConnectivityMgr().IsBLEAdvertisingEnabled()); chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(kTimeoutMs + kSleepPadding), CheckCommissioningWindowManagerWindowClosedTask, suite); } @@ -117,6 +120,7 @@ void CheckCommissioningWindowManagerEnhancedWindowTask(intptr_t context) kPasscodeID); NL_TEST_ASSERT(suite, err == CHIP_NO_ERROR); NL_TEST_ASSERT(suite, commissionMgr.IsCommissioningWindowOpen()); + NL_TEST_ASSERT(suite, !chip::DeviceLayer::ConnectivityMgr().IsBLEAdvertisingEnabled()); err = chip::DeviceLayer::ConfigurationMgr().GetSetupDiscriminator(currentDiscriminator); NL_TEST_ASSERT(suite, err == CHIP_NO_ERROR); NL_TEST_ASSERT(suite, currentDiscriminator == newDiscriminator);