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