Skip to content

Commit 1226472

Browse files
ArekBalysNordicpull[bot]
authored andcommitted
Add handling a local lock operation error to door-lock-server (#29857)
The current implementation of the door-lock server supports emitting the LockOperationEvent only if the credential has been provided remotely. In case we use a custom handling lock credential in the application code the event is emitted only on the correct credential, but we also need a mechanism that allows the door lock server to handle a lock operation error when the wrong credential has been provided. Added handling local lock operation error to emit LockOperationEvent and call HandleWrongCodeEntry.
1 parent 77afdc8 commit 1226472

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/app/clusters/door-lock-server/door-lock-server.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ bool DoorLockServer::SetPrivacyModeButton(chip::EndpointId endpointId, bool isEn
202202
return SetAttribute(endpointId, Attributes::EnablePrivacyModeButton::Id, Attributes::EnablePrivacyModeButton::Set, isEnabled);
203203
}
204204

205+
void DoorLockServer::HandleLocalLockOperationError(chip::EndpointId endpointId, LockOperationTypeEnum opType,
206+
OperationSourceEnum opSource, Nullable<uint16_t> userId)
207+
{
208+
SendLockOperationEvent(endpointId, opType, opSource, OperationErrorEnum::kInvalidCredential, userId,
209+
Nullable<chip::FabricIndex>(), Nullable<chip::NodeId>(), Nullable<List<const LockOpCredentials>>(),
210+
false);
211+
212+
HandleWrongCodeEntry(endpointId);
213+
214+
ChipLogProgress(Zcl, "Handling a local Lock Operation Error: [endpoint=%d, user=%d]", endpointId, userId.Value());
215+
}
216+
205217
bool DoorLockServer::HandleWrongCodeEntry(chip::EndpointId endpointId)
206218
{
207219
auto endpointContext = getContext(endpointId);

src/app/clusters/door-lock-server/door-lock-server.h

+14
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,20 @@ class DoorLockServer
228228
*/
229229
void ResetWrongCodeEntryAttempts(chip::EndpointId endpointId);
230230

231+
/**
232+
* @brief Handles a local lock operation error. This method allows handling a wrong attempt of providing
233+
* user credential entry that has been provided locally by the user. The method will emit the LockOperationEvent
234+
* to inform the controller that a local wrong attempt occurred, and also call HandleWrongEntry method to
235+
* increment wrong entry counter.
236+
*
237+
* @param endpointId
238+
* @param opType Operation source to be registered in the LockOperationEvent.
239+
* @param opSource source of the operation to be registered in the LockOperationEvent.
240+
* @param userId Optional user id to be registered in the LockOperationEvent
241+
*/
242+
void HandleLocalLockOperationError(chip::EndpointId endpointId, LockOperationTypeEnum opType, OperationSourceEnum opSource,
243+
Nullable<uint16_t> userId);
244+
231245
private:
232246
chip::FabricIndex getFabricIndex(const chip::app::CommandHandler * commandObj);
233247
chip::NodeId getNodeId(const chip::app::CommandHandler * commandObj);

0 commit comments

Comments
 (0)