Skip to content
Snippets Groups Projects
Unverified Commit 0584ebb1 authored by Timothy Maes's avatar Timothy Maes Committed by GitHub
Browse files

[QPG] Use Doorlock cluster attribute API and fix door lock application behavior (#22720) (#22818)


* Fix lock state transitions

* Restyled by clang-format

Co-authored-by: default avatarRestyled.io <commits@restyled.io>

Co-authored-by: default avatarDieter Van der Meulen <87530904+dvdm-qorvo@users.noreply.github.com>
Co-authored-by: default avatarRestyled.io <commits@restyled.io>
parent 9c0c1d42
No related branches found
No related tags found
No related merge requests found
......@@ -542,12 +542,14 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
*/
void AppTask::UpdateClusterState(void)
{
using namespace chip::app::Clusters;
auto newValue = BoltLockMgr().IsUnlocked() ? DoorLock::DlLockState::kUnlocked : DoorLock::DlLockState::kLocked;
ChipLogProgress(NotSpecified, "UpdateClusterState");
// write the new on/off value
EmberAfStatus status = Clusters::OnOff::Attributes::OnOff::Set(QPG_LOCK_ENDPOINT_ID, !BoltLockMgr().IsUnlocked());
EmberAfStatus status = DoorLock::Attributes::LockState::Set(DOOR_LOCK_SERVER_ENDPOINT, newValue);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
ChipLogError(NotSpecified, "ERR: updating on/off %x", status);
ChipLogError(NotSpecified, "ERR: updating DoorLock %x", status);
}
}
......@@ -45,14 +45,6 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
default:
break;
}
if (path.mAttributeId != OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(path.mAttributeId));
return;
}
BoltLockMgr().InitiateAction(0, *value ? BoltLockManager::LOCK_ACTION : BoltLockManager::UNLOCK_ACTION);
}
bool emberAfPluginDoorLockGetUser(EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user)
......@@ -83,13 +75,27 @@ bool emberAfPluginDoorLockSetCredential(EndpointId endpointId, uint16_t credenti
bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional<ByteSpan> & pinCode, DlOperationError & err)
{
return BoltLockMgr().ValidatePIN(pinCode, err);
bool returnValue = false;
if (BoltLockMgr().ValidatePIN(pinCode, err))
{
returnValue = BoltLockMgr().InitiateAction(0, BoltLockManager::LOCK_ACTION);
}
return returnValue;
}
bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional<ByteSpan> & pinCode,
DlOperationError & err)
{
return BoltLockMgr().ValidatePIN(pinCode, err);
bool returnValue = false;
if (BoltLockMgr().ValidatePIN(pinCode, err))
{
returnValue = BoltLockMgr().InitiateAction(0, BoltLockManager::UNLOCK_ACTION);
}
return returnValue;
}
void emberAfDoorLockClusterInitCallback(EndpointId endpoint)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment