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 committed Nov 10, 2023
1 parent 491354a commit 44dead0
Show file tree
Hide file tree
Showing 3 changed files with 408 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));

for (auto endpoint : EnabledEndpointsWithServerCluster(Id))
{
Expand Down
Loading

0 comments on commit 44dead0

Please sign in to comment.