Skip to content

Commit ce017ee

Browse files
committed
[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 <adrian.gielniewski@nordicsemi.no>
1 parent 96191c5 commit ce017ee

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

examples/platform/nrfconnect/util/include/FabricTableDelegate.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,19 @@ class AppFabricTableDelegate : public chip::FabricTable::Delegate
4747
private:
4848
void OnFabricRemoved(const chip::FabricTable & fabricTable, chip::FabricIndex fabricIndex)
4949
{
50-
k_timer_start(&sFabricRemovedTimer, K_MSEC(CONFIG_CHIP_LAST_FABRIC_REMOVED_ACTION_DELAY), K_NO_WAIT);
50+
#ifndef CONFIG_CHIP_LAST_FABRIC_REMOVED_NONE
51+
auto & server = chip::Server::GetInstance();
52+
53+
if (server.GetFabricTable().FabricCount() == 0)
54+
{
55+
if (chip::DeviceLayer::ConnectivityMgr().IsBLEAdvertisingEnabled())
56+
{
57+
server.GetCommissioningWindowManager().CloseCommissioningWindow();
58+
}
59+
60+
k_timer_start(&sFabricRemovedTimer, K_MSEC(CONFIG_CHIP_LAST_FABRIC_REMOVED_ACTION_DELAY), K_NO_WAIT);
61+
}
62+
#endif // CONFIG_CHIP_LAST_FABRIC_REMOVED_NONE
5163
}
5264

5365
static void OnFabricRemovedTimerCallback(k_timer * timer)
@@ -59,6 +71,9 @@ class AppFabricTableDelegate : public chip::FabricTable::Delegate
5971
#ifdef CONFIG_CHIP_LAST_FABRIC_REMOVED_ERASE_AND_REBOOT
6072
chip::Server::GetInstance().ScheduleFactoryReset();
6173
#elif defined(CONFIG_CHIP_LAST_FABRIC_REMOVED_ERASE_ONLY) || defined(CONFIG_CHIP_LAST_FABRIC_REMOVED_ERASE_AND_PAIRING_START)
74+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
75+
chip::DeviceLayer::ThreadStackMgr().ClearAllSrpHostAndServices();
76+
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
6277
// Erase Matter data
6378
chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().DoFactoryReset();
6479
// Erase Network credentials and disconnect

0 commit comments

Comments
 (0)