Skip to content

Commit

Permalink
Added Fabric Removal callback to scenes-server
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs authored and woody-apple committed Nov 15, 2023
1 parent 512fa70 commit 19d18a8
Show file tree
Hide file tree
Showing 4 changed files with 1,394 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/clusters/scenes-server/scenes-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ ScenesServer & ScenesServer::Instance()
}
void ReportAttributeOnAllEndpoints(AttributeId attribute) {}

class ScenesClusterFabricDelegate : public chip::FabricTable::Delegate
{
void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) override
{
SceneTable * sceneTable = scenes::GetSceneTableImpl();
VerifyOrReturn(nullptr != sceneTable);
sceneTable->RemoveFabric(fabricIndex);
}
};

static ScenesClusterFabricDelegate gFabricDelegate;

CHIP_ERROR ScenesServer::Init()
{
// Prevents re-initializing
Expand All @@ -115,6 +127,7 @@ CHIP_ERROR ScenesServer::Init()

SceneTable * sceneTable = scenes::GetSceneTableImpl();
ReturnErrorOnFailure(sceneTable->Init(&chip::Server::GetInstance().GetPersistentStorage()));
ReturnErrorOnFailure(chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(&gFabricDelegate));

mIsInitialized = true;
return CHIP_NO_ERROR;
Expand Down
Loading

0 comments on commit 19d18a8

Please sign in to comment.