@@ -92,13 +92,13 @@ Delegate * GetDelegate(EndpointId endpoint)
92
92
*/
93
93
bool IsValidPresetEntry (const PresetStruct::Type & preset)
94
94
{
95
- // If the presetHandle is not null, the size of the handle does not exceed 16 bytes, return true .
95
+ // Check that the preset handle is not too long .
96
96
if (!preset.presetHandle .IsNull () && preset.presetHandle .Value ().size () > kPresetHandleSize )
97
97
{
98
98
return false ;
99
99
}
100
100
101
- // Return true if the preset scenario is valid, false otherwise .
101
+ // Ensure we have a valid PresetScenario .
102
102
return (preset.presetScenario != PresetScenarioEnum::kUnknownEnumValue );
103
103
}
104
104
@@ -419,7 +419,7 @@ uint8_t CountUpdatedPresetsAfterApplyingPendingPresets(Delegate * delegate)
419
419
*
420
420
* @return true if the presetScenario is found, false otherwise.
421
421
*/
422
- bool FindPresetScenarioInPresetTypes (Delegate * delegate, PresetScenarioEnum presetScenario)
422
+ bool PresetScenarioExistsInPresetTypes (Delegate * delegate, PresetScenarioEnum presetScenario)
423
423
{
424
424
VerifyOrReturnValue (delegate != nullptr , false );
425
425
@@ -786,7 +786,7 @@ CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
786
786
Delegate * delegate = GetDelegate (aPath.mEndpointId );
787
787
VerifyOrReturnError (delegate != nullptr , CHIP_ERROR_INCORRECT_STATE, ChipLogError (Zcl, " Delegate is null" ));
788
788
789
- ReturnErrorOnFailure (aEncoder.Encode (gThermostatAttrAccess . GetPresetsEditable (aPath.mEndpointId )));
789
+ ReturnErrorOnFailure (aEncoder.Encode (GetPresetsEditable (aPath.mEndpointId )));
790
790
}
791
791
break ;
792
792
case ActivePresetHandle::Id: {
@@ -855,15 +855,15 @@ CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath,
855
855
VerifyOrReturnError (delegate != nullptr , CHIP_ERROR_INCORRECT_STATE, ChipLogError (Zcl, " Delegate is null" ));
856
856
857
857
// Presets are not editable, return INVALID_IN_STATE.
858
- VerifyOrReturnError (gThermostatAttrAccess . GetPresetsEditable (endpoint), CHIP_IM_GLOBAL_STATUS (InvalidInState),
858
+ VerifyOrReturnError (GetPresetsEditable (endpoint), CHIP_IM_GLOBAL_STATUS (InvalidInState),
859
859
ChipLogError (Zcl, " Presets are not editable" ));
860
860
861
861
// Check if the OriginatorScopedNodeId at the endpoint is the same as the node editing the presets,
862
862
// otherwise return BUSY.
863
863
const Access::SubjectDescriptor subjectDescriptor = aDecoder.GetSubjectDescriptor ();
864
864
ScopedNodeId scopedNodeId = ScopedNodeId (subjectDescriptor.subject , subjectDescriptor.fabricIndex );
865
865
866
- if (gThermostatAttrAccess . GetOriginatorScopedNodeId (endpoint) != scopedNodeId)
866
+ if (GetOriginatorScopedNodeId (endpoint) != scopedNodeId)
867
867
{
868
868
ChipLogError (Zcl, " Another node is editing presets. Server is busy. Try again later" );
869
869
return CHIP_IM_GLOBAL_STATUS (Busy);
@@ -1273,7 +1273,7 @@ bool emberAfThermostatClusterSetActivePresetRequestCallback(
1273
1273
if (err != CHIP_NO_ERROR)
1274
1274
{
1275
1275
ChipLogError (Zcl, " Failed to set ActivePresetHandle with error %" CHIP_ERROR_FORMAT, err.Format ());
1276
- commandObj->AddStatus (commandPath, imcode::Failure );
1276
+ commandObj->AddStatus (commandPath, StatusIB (err). mStatus );
1277
1277
return true ;
1278
1278
}
1279
1279
@@ -1509,7 +1509,7 @@ bool emberAfThermostatClusterCommitPresetsSchedulesRequestCallback(
1509
1509
return SendResponseAndCleanUp (delegate, endpoint, commandObj, commandPath, imcode::ConstraintError);
1510
1510
}
1511
1511
1512
- // If the preset type for the preset scenario does not supports names and a name is specified, return CONSTRAINT_ERROR.
1512
+ // If the preset type for the preset scenario does not supports name and a name is specified, return CONSTRAINT_ERROR.
1513
1513
if (!PresetTypeSupportsNames (delegate, presetScenario) && pendingPreset.GetName ().HasValue ())
1514
1514
{
1515
1515
return SendResponseAndCleanUp (delegate, endpoint, commandObj, commandPath, imcode::ConstraintError);
@@ -1522,7 +1522,7 @@ bool emberAfThermostatClusterCommitPresetsSchedulesRequestCallback(
1522
1522
pendingPreset.SetCoolingSetpoint (MakeOptional (EnforceCoolingSetpointLimits (coolingSetpointValue.Value (), endpoint)));
1523
1523
}
1524
1524
1525
- Optional<int16_t > heatingSetpointValue = preset .GetHeatingSetpoint ();
1525
+ Optional<int16_t > heatingSetpointValue = pendingPreset .GetHeatingSetpoint ();
1526
1526
if (heatingSetpointValue.HasValue ())
1527
1527
{
1528
1528
pendingPreset.SetHeatingSetpoint (MakeOptional (EnforceHeatingSetpointLimits (heatingSetpointValue.Value (), endpoint)));
0 commit comments