Skip to content

Commit 2c05b3b

Browse files
committed
[nrf toup] Add factory reset event
Add `kFactoryReset` event and post it at the beginning of `ScheduleFactoryReset`. Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
1 parent 4c46941 commit 2c05b3b

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/app/server/Server.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,22 @@ void Server::GenerateShutDownEvent()
586586
PlatformMgr().ScheduleWork([](intptr_t) { PlatformMgr().HandleServerShuttingDown(); });
587587
}
588588

589+
void Server::PostFactoryResetEvent()
590+
{
591+
DeviceLayer::ChipDeviceEvent event;
592+
event.Type = DeviceLayer::DeviceEventType::kFactoryReset;
593+
594+
CHIP_ERROR error = DeviceLayer::PlatformMgr().PostEvent(&event);
595+
if (error != CHIP_NO_ERROR)
596+
{
597+
ChipLogError(Discovery, "Posting kFactoryReset event failed with %" CHIP_ERROR_FORMAT, error.Format());
598+
}
599+
}
600+
589601
void Server::ScheduleFactoryReset()
590602
{
603+
PostFactoryResetEvent();
604+
591605
PlatformMgr().ScheduleWork([](intptr_t) {
592606
// Delete all fabrics and emit Leave event.
593607
GetInstance().GetFabricTable().DeleteAllFabrics();

src/app/server/Server.h

+2
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ class Server
456456
void OnPlatformEvent(const DeviceLayer::ChipDeviceEvent & event);
457457
void CheckServerReadyEvent();
458458

459+
void PostFactoryResetEvent();
460+
459461
static void OnPlatformEventWrapper(const DeviceLayer::ChipDeviceEvent * event, intptr_t);
460462

461463
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS

src/include/platform/CHIPDeviceEvent.h

+5
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ enum PublicEventTypes
255255
* Signals that secure session is established.
256256
*/
257257
kSecureSessionEstablished,
258+
259+
/**
260+
* Signals that factory reset has started.
261+
*/
262+
kFactoryReset,
258263
};
259264

260265
/**

0 commit comments

Comments
 (0)