@@ -90,7 +90,7 @@ class DoorLockClusterFabricDelegate : public chip::FabricTable::Delegate
90
90
{
91
91
void OnFabricRemoved (const FabricTable & fabricTable, FabricIndex fabricIndex) override
92
92
{
93
- for (auto endpointId : EnabledEndpointsWithServerCluster (chip::app:: Clusters::DoorLock::Id))
93
+ for (auto endpointId : EnabledEndpointsWithServerCluster (Clusters::DoorLock::Id))
94
94
{
95
95
if (!DoorLockServer::Instance ().OnFabricRemoved (endpointId, fabricIndex))
96
96
{
@@ -3641,7 +3641,7 @@ void DoorLockServer::SendEvent(chip::EndpointId endpointId, T & event)
3641
3641
3642
3642
template <typename T>
3643
3643
bool DoorLockServer::GetAttribute (chip::EndpointId endpointId, chip::AttributeId attributeId,
3644
- Status (*getFn)(chip::EndpointId endpointId, T * value), T & value) const
3644
+ Status (*getFn)(chip::EndpointId endpointId, T * value), T & value)
3645
3645
{
3646
3646
Status status = getFn (endpointId, &value);
3647
3647
bool success = (Status::Success == status);
@@ -3927,12 +3927,26 @@ void DoorLockServer::setAliroReaderConfigCommandHandler(CommandHandler * command
3927
3927
}
3928
3928
3929
3929
Delegate * delegate = GetDelegate (endpointID);
3930
- VerifyOrReturn (delegate != nullptr , ChipLogError (Zcl, " Delegate is null" ));
3930
+ if (!delegate)
3931
+ {
3932
+ ChipLogError (Zcl, " Door Lock delegate is null" );
3933
+ commandObj->AddStatus (commandPath, Status::Failure);
3934
+ return ;
3935
+ }
3931
3936
3932
- // If Aliro BLE UWB feature is supported and groupResolvingKey is not provided in the command, return INVALID_COMMAND.
3933
- if (SupportsAliroBLEUWB (endpointID) && !groupResolvingKey.HasValue ())
3937
+ // The GroupResolvingKey must be provided if and only if the Aliro BLE UWB
3938
+ // feature is supported. Otherwise, return INVALID_COMMAND
3939
+ const bool supportsAliroBLEUWB = SupportsAliroBLEUWB (endpointID);
3940
+ if (supportsAliroBLEUWB != groupResolvingKey.HasValue ())
3934
3941
{
3935
- ChipLogProgress (Zcl, " [SetAliroReaderConfig] Aliro BLE UWB supported but Group Resolving Key is not provided" );
3942
+ if (supportsAliroBLEUWB)
3943
+ {
3944
+ ChipLogError (Zcl, " [SetAliroReaderConfig] Aliro BLE UWB supported but Group Resolving Key is not provided" );
3945
+ }
3946
+ else
3947
+ {
3948
+ ChipLogError (Zcl, " [SetAliroReaderConfig] Aliro BLE UWB not supported but Group Resolving Key is provided" );
3949
+ }
3936
3950
commandObj->AddStatus (commandPath, Status::InvalidCommand);
3937
3951
return ;
3938
3952
}
@@ -3959,19 +3973,27 @@ void DoorLockServer::setAliroReaderConfigCommandHandler(CommandHandler * command
3959
3973
// INVALID_IN_STATE.
3960
3974
if (err != CHIP_NO_ERROR || !readerVerificationKey.empty ())
3961
3975
{
3962
- ChipLogProgress (
3963
- Zcl, " [SetAliroReaderConfig] Aliro reader verification key was not read or is not null. Return INVALID_IN_STATE" );
3976
+ ChipLogError (Zcl, " [SetAliroReaderConfig] Aliro reader verification key was not read or is not null." );
3964
3977
commandObj->AddStatus (commandPath, Status::InvalidInState);
3965
3978
return ;
3966
3979
}
3967
3980
3968
- Status status = Status::Success ;
3969
- if (! emberAfPluginDoorLockSetAliroReaderConfig (endpointID, signingKey, verificationKey, groupIdentifier, groupResolvingKey) )
3981
+ err = delegate-> SetAliroReaderConfig (signingKey, verificationKey, groupIdentifier, groupResolvingKey) ;
3982
+ if (err != CHIP_NO_ERROR )
3970
3983
{
3971
3984
ChipLogProgress (Zcl, " [SetAliroReaderConfig] Unable to set aliro reader config [endpointId=%d]" , endpointID);
3972
- status = Status::Failure;
3973
3985
}
3974
- sendClusterResponse (commandObj, commandPath, ClusterStatusCode (status));
3986
+ else
3987
+ {
3988
+ // Various attributes changed; mark them dirty.
3989
+ MatterReportingAttributeChangeCallback (endpointID, Clusters::DoorLock::Id, AliroReaderVerificationKey::Id);
3990
+ MatterReportingAttributeChangeCallback (endpointID, Clusters::DoorLock::Id, AliroReaderGroupIdentifier::Id);
3991
+ if (supportsAliroBLEUWB)
3992
+ {
3993
+ MatterReportingAttributeChangeCallback (endpointID, Clusters::DoorLock::Id, AliroGroupResolvingKey::Id);
3994
+ }
3995
+ }
3996
+ sendClusterResponse (commandObj, commandPath, ClusterStatusCode (StatusIB (err).mStatus ));
3975
3997
}
3976
3998
3977
3999
void DoorLockServer::clearAliroReaderConfigCommandHandler (CommandHandler * commandObj, const ConcreteCommandPath & commandPath)
@@ -3987,13 +4009,41 @@ void DoorLockServer::clearAliroReaderConfigCommandHandler(CommandHandler * comma
3987
4009
return ;
3988
4010
}
3989
4011
3990
- Status status = Status::Success ;
3991
- if (!emberAfPluginDoorLockClearAliroReaderConfig (endpointID) )
4012
+ Delegate * delegate = GetDelegate (endpointID) ;
4013
+ if (!delegate )
3992
4014
{
3993
- ChipLogProgress (Zcl, " [SetAliroReaderConfig] Unable to set aliro reader config [endpointId=%d]" , endpointID);
3994
- status = Status::Failure;
4015
+ ChipLogError (Zcl, " Door Lock delegate is null" );
4016
+ commandObj->AddStatus (commandPath, Status::Failure);
4017
+ return ;
4018
+ }
4019
+
4020
+ uint8_t buffer[kAliroReaderVerificationKeySize ];
4021
+ MutableByteSpan readerVerificationKey (buffer);
4022
+ CHIP_ERROR err = delegate->GetAliroReaderVerificationKey (readerVerificationKey);
4023
+ if (err != CHIP_NO_ERROR && readerVerificationKey.empty ())
4024
+ {
4025
+ // No reader config to start with. Just return without marking any
4026
+ // attributes as dirty.
4027
+ commandObj->AddStatus (commandPath, Status::Success);
4028
+ return ;
4029
+ }
4030
+
4031
+ err = delegate->ClearAliroReaderConfig ();
4032
+ if (err != CHIP_NO_ERROR)
4033
+ {
4034
+ ChipLogError (Zcl, " [SetAliroReaderConfig] Unable to set aliro reader config [endpointId=%d]" , endpointID);
4035
+ }
4036
+ else
4037
+ {
4038
+ // Various attributes changed; mark them dirty.
4039
+ MatterReportingAttributeChangeCallback (endpointID, Clusters::DoorLock::Id, AliroReaderVerificationKey::Id);
4040
+ MatterReportingAttributeChangeCallback (endpointID, Clusters::DoorLock::Id, AliroReaderGroupIdentifier::Id);
4041
+ if (SupportsAliroBLEUWB (endpointID))
4042
+ {
4043
+ MatterReportingAttributeChangeCallback (endpointID, Clusters::DoorLock::Id, AliroGroupResolvingKey::Id);
4044
+ }
3995
4045
}
3996
- sendClusterResponse (commandObj, commandPath, ClusterStatusCode (status ));
4046
+ sendClusterResponse (commandObj, commandPath, ClusterStatusCode (StatusIB (err). mStatus ));
3997
4047
}
3998
4048
3999
4049
// =============================================================================
0 commit comments