From ce017eea545627fe43334b5b868f2b6399e38569 Mon Sep 17 00:00:00 2001 From: Adrian Gielniewski Date: Fri, 21 Mar 2025 16:46:34 +0100 Subject: [PATCH] [nrf toup] Don't advertise when waiting for last fabric removed action * Close commissioning window on last fabric removal. It will be reopened depending on `CHIP_LAST_FABRIC_REMOVED_ACTION`. * Update handler to match implementation in NCS. Signed-off-by: Adrian Gielniewski --- .../util/include/FabricTableDelegate.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/platform/nrfconnect/util/include/FabricTableDelegate.h b/examples/platform/nrfconnect/util/include/FabricTableDelegate.h index fa9e6f0c82..fa9cf509ad 100644 --- a/examples/platform/nrfconnect/util/include/FabricTableDelegate.h +++ b/examples/platform/nrfconnect/util/include/FabricTableDelegate.h @@ -47,7 +47,19 @@ class AppFabricTableDelegate : public chip::FabricTable::Delegate private: void OnFabricRemoved(const chip::FabricTable & fabricTable, chip::FabricIndex fabricIndex) { - k_timer_start(&sFabricRemovedTimer, K_MSEC(CONFIG_CHIP_LAST_FABRIC_REMOVED_ACTION_DELAY), K_NO_WAIT); +#ifndef CONFIG_CHIP_LAST_FABRIC_REMOVED_NONE + auto & server = chip::Server::GetInstance(); + + if (server.GetFabricTable().FabricCount() == 0) + { + if (chip::DeviceLayer::ConnectivityMgr().IsBLEAdvertisingEnabled()) + { + server.GetCommissioningWindowManager().CloseCommissioningWindow(); + } + + k_timer_start(&sFabricRemovedTimer, K_MSEC(CONFIG_CHIP_LAST_FABRIC_REMOVED_ACTION_DELAY), K_NO_WAIT); + } +#endif // CONFIG_CHIP_LAST_FABRIC_REMOVED_NONE } static void OnFabricRemovedTimerCallback(k_timer * timer) @@ -59,6 +71,9 @@ class AppFabricTableDelegate : public chip::FabricTable::Delegate #ifdef CONFIG_CHIP_LAST_FABRIC_REMOVED_ERASE_AND_REBOOT chip::Server::GetInstance().ScheduleFactoryReset(); #elif defined(CONFIG_CHIP_LAST_FABRIC_REMOVED_ERASE_ONLY) || defined(CONFIG_CHIP_LAST_FABRIC_REMOVED_ERASE_AND_PAIRING_START) +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + chip::DeviceLayer::ThreadStackMgr().ClearAllSrpHostAndServices(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT // Erase Matter data chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().DoFactoryReset(); // Erase Network credentials and disconnect