Skip to content

Commit

Permalink
Merge branch 'master' into feature/appliance-device-type-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mideayanghui authored Jul 24, 2023
2 parents bc4715b + a5e396a commit 4631882
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,12 +1353,13 @@ bool DoorLockServer::OnFabricRemoved(chip::EndpointId endpointId, chip::FabricIn
ChipLogProgress(Zcl, "[OnFabricRemoved] Handling a fabric removal from the door lock server [endpointId=%d,fabricIndex=%d]",
endpointId, fabricIndex);

bool status{ true };
// Iterate over all the users and clean up the deleted fabric
if (!clearFabricFromUsers(endpointId, fabricIndex))
{
ChipLogError(Zcl, "[OnFabricRemoved] Unable to cleanup fabric from users - internal error [endpointId=%d,fabricIndex=%d]",
endpointId, fabricIndex);
return false;
status = false;
}

// Iterate over all the credentials and clean up the fabrics
Expand All @@ -1367,10 +1368,15 @@ bool DoorLockServer::OnFabricRemoved(chip::EndpointId endpointId, chip::FabricIn
ChipLogError(Zcl,
"[OnFabricRemoved] Unable to cleanup fabric from credentials - internal error [endpointId=%d,fabricIndex=%d]",
endpointId, fabricIndex);
return false;
status = false;
}

return true;
if (mOnFabricRemovedCustomCallback)
{
mOnFabricRemovedCustomCallback(endpointId, fabricIndex);
}

return status;
}

/**********************************************************
Expand Down
17 changes: 16 additions & 1 deletion src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class DoorLockServer
public:
static DoorLockServer & Instance();

using Feature = chip::app::Clusters::DoorLock::Feature;
using Feature = chip::app::Clusters::DoorLock::Feature;
using OnFabricRemovedCustomCallback = void (*)(chip::EndpointId endpointId, chip::FabricIndex fabricIndex);

void InitServer(chip::EndpointId endpointId);

Expand Down Expand Up @@ -202,6 +203,18 @@ class DoorLockServer

inline bool SupportsUnbolt(chip::EndpointId endpointId) { return GetFeatures(endpointId).Has(Feature::kUnbolt); }

/**
* @brief Allows the application to register a custom callback which will be called after the default DoorLock
* OnFabricRemoved implementation. At that point the door lock cluster has done any
* spec-required clearing of state for fabric removal.
*
* @param callback callback to be registered
*/
inline void SetOnFabricRemovedCustomCallback(OnFabricRemovedCustomCallback callback)
{
mOnFabricRemovedCustomCallback = callback;
}

bool OnFabricRemoved(chip::EndpointId endpointId, chip::FabricIndex fabricIndex);

static void DoorLockOnAutoRelockCallback(chip::System::Layer *, void * callbackContext);
Expand Down Expand Up @@ -580,6 +593,8 @@ class DoorLockServer

std::array<EmberAfDoorLockEndpointContext, kDoorLockClusterServerMaxEndpointCount> mEndpointCtx;

OnFabricRemovedCustomCallback mOnFabricRemovedCustomCallback{ nullptr };

static DoorLockServer instance;
};

Expand Down

0 comments on commit 4631882

Please sign in to comment.