Skip to content

Commit

Permalink
Remove MatterPostAttributeChangeCallback from thermostat-manager, as …
Browse files Browse the repository at this point in the history
…it conflicts with other implementations
  • Loading branch information
hasty committed Jul 30, 2024
1 parent 5abc22d commit 637db40
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class ThermostatDelegate : public Delegate

void ClearPendingPresetList() override;

void AttributeChanged(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t * value,
uint16_t size) override;

private:
static ThermostatDelegate sInstance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include <thermostat-delegate-impl.h>
#include <thermostat-manager.h>

#include <app-common/zap-generated/attributes/Accessors.h>
#include <lib/support/Span.h>
Expand Down Expand Up @@ -252,3 +253,15 @@ void ThermostatDelegate::ClearPendingPresetList()
{
mNextFreeIndexInPendingPresetsList = 0;
}

void ThermostatDelegate::AttributeChanged(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t * value,
uint16_t size)
{
ChipLogProgress(AppServer, "ThermostatDelegate AttributeChanged callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));

ChipLogProgress(AppServer,
"Attribute ID changed: " ChipLogFormatMEI " Endpoint: %d ClusterId: " ChipLogFormatMEI " Value: %u, length %u",
ChipLogValueMEI(attributeId), endpointId, ChipLogValueMEI(clusterId), *value, size);

ThermostatManager().AttributeChangeHandler(endpointId, clusterId, attributeId, value, size);
}
Original file line number Diff line number Diff line change
Expand Up @@ -490,20 +490,6 @@ static const char * RunningModeString(ThermostatRunningModeEnum runningMode)
}
}

void MatterPostAttributeChangeCallback(const ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value)
{
ClusterId clusterId = attributePath.mClusterId;
AttributeId attributeId = attributePath.mAttributeId;
ChipLogProgress(AppServer, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));

ChipLogProgress(AppServer,
"Attribute ID changed: " ChipLogFormatMEI " Endpoint: %d ClusterId: " ChipLogFormatMEI
" Type: %u Value: %u, length %u",
ChipLogValueMEI(attributeId), attributePath.mEndpointId, ChipLogValueMEI(clusterId), type, *value, size);

ThermostatMgr().AttributeChangeHandler(attributePath.mEndpointId, clusterId, attributeId, value, size);
}

void emberAfThermostatClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "Starting Thermostat Manager");
Expand Down
13 changes: 13 additions & 0 deletions src/app/clusters/thermostat-server/thermostat-delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ class Delegate
*
*/
virtual void ClearPendingPresetList() = 0;

/**
* @brief Informs of a change in a non-atomic thermostat attribute
*
* @param[in] endpointId The endpoint for the thermostat cluster.
* @param[in] clusterId The ID of the cluster.
* @param[in] attributeId The ID of the attribute being updated.
* @param[in] value The new value of the attribute.
* @param[in] size The size of the new value of the attribute.
*
*/
virtual void AttributeChanged(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t * value,
uint16_t size) = 0;
};

} // namespace Thermostat
Expand Down
37 changes: 21 additions & 16 deletions src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested > OccupiedCoolingSetpoint - DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}

case OccupiedCoolingSetpoint::Id: {
Expand All @@ -1094,7 +1094,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested < OccupiedHeatingSetpoint + DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}

case UnoccupiedHeatingSetpoint::Id: {
Expand All @@ -1109,7 +1109,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested > UnoccupiedCoolingSetpoint - DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}
case UnoccupiedCoolingSetpoint::Id: {
requested = static_cast<int16_t>(chip::Encoding::LittleEndian::Get16(value));
Expand All @@ -1123,7 +1123,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested < UnoccupiedHeatingSetpoint + DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}

case MinHeatSetpointLimit::Id: {
Expand All @@ -1137,7 +1137,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested > MinCoolSetpointLimit - DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}
case MaxHeatSetpointLimit::Id: {
requested = static_cast<int16_t>(chip::Encoding::LittleEndian::Get16(value));
Expand All @@ -1150,7 +1150,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested > MaxCoolSetpointLimit - DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}
case MinCoolSetpointLimit::Id: {
requested = static_cast<int16_t>(chip::Encoding::LittleEndian::Get16(value));
Expand All @@ -1163,7 +1163,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested < MinHeatSetpointLimit + DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}
case MaxCoolSetpointLimit::Id: {
requested = static_cast<int16_t>(chip::Encoding::LittleEndian::Get16(value));
Expand All @@ -1176,23 +1176,23 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
if (requested < MaxHeatSetpointLimit + DeadBandTemp)
return imcode::InvalidValue;
}
return imcode::Success;
break;
}
case MinSetpointDeadBand::Id: {
requested = *value;
if (!AutoSupported)
return imcode::UnsupportedAttribute;
if (requested < 0 || requested > 25)
return imcode::InvalidValue;
return imcode::Success;
break;
}

case ControlSequenceOfOperation::Id: {
uint8_t requestedCSO;
requestedCSO = *value;
if (requestedCSO > to_underlying(ControlSequenceOfOperationEnum::kCoolingAndHeatingWithReheat))
return imcode::InvalidValue;
return imcode::Success;
break;
}

case SystemMode::Id: {
Expand All @@ -1215,22 +1215,27 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
case ControlSequenceOfOperationEnum::kCoolingWithReheat:
if (RequestedSystemMode == SystemModeEnum::kHeat || RequestedSystemMode == SystemModeEnum::kEmergencyHeat)
return imcode::InvalidValue;
else
return imcode::Success;
break;

case ControlSequenceOfOperationEnum::kHeatingOnly:
case ControlSequenceOfOperationEnum::kHeatingWithReheat:
if (RequestedSystemMode == SystemModeEnum::kCool || RequestedSystemMode == SystemModeEnum::kPrecooling)
return imcode::InvalidValue;
else
return imcode::Success;
break;
default:
return imcode::Success;
break;
}
break;
}
default:
return imcode::Success;
break;
}
Delegate * delegate = GetDelegate(endpoint);
if (delegate != nullptr)
{
delegate->AttributeChanged(attributePath.mEndpointId, attributePath.mClusterId, attributePath.mAttributeId, value, size);
}
return imcode::Success;
}

bool emberAfThermostatClusterClearWeeklyScheduleCallback(app::CommandHandler * commandObj,
Expand Down

0 comments on commit 637db40

Please sign in to comment.