Skip to content

Commit

Permalink
move handling of latch pulling to door lock example
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarc committed May 25, 2023
1 parent 8ec73af commit b27dd44
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 38 deletions.
4 changes: 2 additions & 2 deletions examples/lock-app/lock-common/src/LockEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool LockEndpoint::Unlock(const Optional<chip::ByteSpan> & pin, OperationErrorEn
if (DoorLockServer::Instance().SupportsUnbolt(mEndpointId))
{
// If Unbolt is supported Unlock is supposed to pull the latch
return setLockState(DlLockState::kUnlatched, pin, err, opSource);
setLockState(DlLockState::kUnlatched, pin, err, opSource);
}

return setLockState(DlLockState::kUnlocked, pin, err, opSource);
Expand Down Expand Up @@ -406,7 +406,7 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional<chip::Byte
ChipLogProgress(Zcl, "Door Lock App: setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState),
mEndpointId);

DoorLockServer::Instance().SetLockState(mEndpointId, lockState, opSource, Nullable<uint16_t>(), Nullable<List<const LockOpCredentials>>());
DoorLockServer::Instance().SetLockState(mEndpointId, lockState);

return true;
}
Expand Down
11 changes: 0 additions & 11 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,6 @@ bool DoorLockServer::SetLockState(chip::EndpointId endpointId, DlLockState newLo
{
bool success = SetLockState(endpointId, newLockState);

if (success && DlLockState::kUnlatched == newLockState)
{
if (OperationSourceEnum::kRemote != opSource)
{
SendLockOperationEvent(endpointId, LockOperationTypeEnum::kUnlatch, opSource, OperationErrorEnum::kUnspecified, userIndex,
Nullable<chip::FabricIndex>(), Nullable<chip::NodeId>(), credentials, success);
}

success = SetLockState(endpointId, DlLockState::kUnlocked);
}

// Remote operations are handled separately as they use more data unavailable here
VerifyOrReturnError(OperationSourceEnum::kRemote != opSource, success);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,36 +174,12 @@ def test_lock_ctrl(device, controller):
assert err == 0
assert res.value == DoorLock.Enums.DlLockState.kLocked

err, res = send_zcl_command(devCtrl, "DoorLock", "UnboltDoor", nodeId, LOCK_CTRL_TEST_ENDPOINT_ID,
dict(PINCode=LOCK_CTRL_TEST_PIN_CODE),
requestTimeoutMs=1000)
assert err == 0

ret = device.wait_for_output("setting door lock state to \"Unlocked\"")
assert ret is not None and len(ret) > 0

err, res = read_zcl_attribute(devCtrl, "DoorLock", "LockState", nodeId, LOCK_CTRL_TEST_ENDPOINT_ID)
assert err == 0
assert res.value == DoorLock.Enums.DlLockState.kUnlocked

err, res = send_zcl_command(devCtrl, "DoorLock", "LockDoor", nodeId, LOCK_CTRL_TEST_ENDPOINT_ID,
dict(PINCode=LOCK_CTRL_TEST_PIN_CODE),
requestTimeoutMs=1000)
assert err == 0

ret = device.wait_for_output("setting door lock state to \"Locked\"")
assert ret is not None and len(ret) > 0

err, res = read_zcl_attribute(devCtrl, "DoorLock", "LockState", nodeId, LOCK_CTRL_TEST_ENDPOINT_ID)
assert err == 0
assert res.value == DoorLock.Enums.DlLockState.kLocked

err, res = send_zcl_command(devCtrl, "DoorLock", "UnlockDoor", nodeId, LOCK_CTRL_TEST_ENDPOINT_ID,
dict(PINCode=LOCK_CTRL_TEST_PIN_CODE),
requestTimeoutMs=1000)
assert err == 0

ret = device.wait_for_output("setting door lock state to \"Unlatched\"")
ret = device.wait_for_output("setting door lock state to \"Unlocked\"")
assert ret is not None and len(ret) > 0

err, res = read_zcl_attribute(devCtrl, "DoorLock", "LockState", nodeId, LOCK_CTRL_TEST_ENDPOINT_ID)
Expand Down

0 comments on commit b27dd44

Please sign in to comment.