Skip to content

Commit

Permalink
[nrfconnect] Fixed handling lock/unlock door lock commands (#22359)
Browse files Browse the repository at this point in the history
Some time ago setting lock state attribute was removed from the
door lock cluster code, so basically now it doesn't work in
nrfconnect example, as application was relying on the cluster
code.

Added handling attribute state in the application.
  • Loading branch information
kkasperczyk-no authored and pull[bot] committed Oct 26, 2023
1 parent f863ea6 commit 1986068
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
5 changes: 1 addition & 4 deletions examples/lock-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,7 @@ void AppTask::LockStateChanged(BoltLockManager::State state, BoltLockManager::Op
break;
}

if (source != BoltLockManager::OperationSource::kRemote)
{
sAppTask.UpdateClusterState(state, source);
}
sAppTask.UpdateClusterState(state, source);
}

void AppTask::PostEvent(AppEvent * aEvent)
Expand Down
20 changes: 18 additions & 2 deletions examples/lock-app/nrfconnect/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,28 @@ bool emberAfPluginDoorLockSetCredential(EndpointId endpointId, uint16_t credenti

bool emberAfPluginDoorLockOnDoorLockCommand(EndpointId endpointId, const Optional<ByteSpan> & pinCode, DlOperationError & err)
{
return BoltLockMgr().ValidatePIN(pinCode, err);
bool result = BoltLockMgr().ValidatePIN(pinCode, err);

/* Handle changing attribute state on command reception */
if (result)
{
BoltLockMgr().Lock(BoltLockManager::OperationSource::kRemote);
}

return result;
}

bool emberAfPluginDoorLockOnDoorUnlockCommand(EndpointId endpointId, const Optional<ByteSpan> & pinCode, DlOperationError & err)
{
return BoltLockMgr().ValidatePIN(pinCode, err);
bool result = BoltLockMgr().ValidatePIN(pinCode, err);

/* Handle changing attribute state on command reception */
if (result)
{
BoltLockMgr().Unlock(BoltLockManager::OperationSource::kRemote);
}

return result;
}

void emberAfDoorLockClusterInitCallback(EndpointId endpoint)
Expand Down

0 comments on commit 1986068

Please sign in to comment.