Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LTNE (Local Temperature Not Exposed) feature in Therm… #26686

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,7 @@ server cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2725,6 +2725,7 @@ server cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ client cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ server cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
1 change: 1 addition & 0 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2476,6 +2476,7 @@ server cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
1 change: 1 addition & 0 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,7 @@ server cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
1 change: 1 addition & 0 deletions examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@ server cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
95 changes: 92 additions & 3 deletions src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
#include <lib/core/CHIPEncoding.h>

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::Thermostat;
using namespace chip::app::Clusters::Thermostat::Attributes;

using imcode = Protocols::InteractionModel::Status;

constexpr int16_t kDefaultAbsMinHeatSetpointLimit = 700; // 7C (44.5 F) is the default
constexpr int16_t kDefaultAbsMaxHeatSetpointLimit = 3000; // 30C (86 F) is the default
constexpr int16_t kDefaultMinHeatSetpointLimit = 700; // 7C (44.5 F) is the default
Expand Down Expand Up @@ -62,6 +66,90 @@ constexpr int8_t kDefaultDeadBand = 25; // 2.5C is the default

#define FEATURE_MAP_DEFAULT FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO

namespace {

class ThermostatAttrAccess : public AttributeAccessInterface
{
public:
ThermostatAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), Thermostat::Id) {}

CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override;
};

ThermostatAttrAccess gThermostatAttrAccess;
huangzh142 marked this conversation as resolved.
Show resolved Hide resolved

CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
{
VerifyOrDie(aPath.mClusterId == Thermostat::Id);

uint32_t ourFeatureMap;
bool localTemperatureNotExposedSupported = (FeatureMap::Get(aPath.mEndpointId, &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS) &&
((ourFeatureMap & to_underlying(Feature::kLocalTemperatureNotExposed)) != 0);

switch (aPath.mAttributeId)
{
case LocalTemperature::Id:
if (localTemperatureNotExposedSupported)
{
return aEncoder.EncodeNull();
}
break;
case RemoteSensing::Id:
if (localTemperatureNotExposedSupported)
{
uint8_t valueRemoteSensing;
EmberAfStatus status = RemoteSensing::Get(aPath.mEndpointId, &valueRemoteSensing);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
StatusIB statusIB(ToInteractionModelStatus(status));
return statusIB.ToChipError();
}
valueRemoteSensing &= 0xFE; // clear bit 1 (LocalTemperature RemoteSensing bit)
return aEncoder.Encode(valueRemoteSensing);
}
break;
huangzh142 marked this conversation as resolved.
Show resolved Hide resolved
default: // return CHIP_NO_ERROR and just read from the attribute store in default
break;
huangzh142 marked this conversation as resolved.
Show resolved Hide resolved
}

return CHIP_NO_ERROR;
}

CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
{
VerifyOrDie(aPath.mClusterId == Thermostat::Id);

uint32_t ourFeatureMap;
bool localTemperatureNotExposedSupported = (FeatureMap::Get(aPath.mEndpointId, &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS) &&
((ourFeatureMap & to_underlying(Feature::kLocalTemperatureNotExposed)) != 0);

switch (aPath.mAttributeId)
{
case RemoteSensing::Id:
if (localTemperatureNotExposedSupported)
{
uint8_t valueRemoteSensing;
ReturnErrorOnFailure(aDecoder.Decode(valueRemoteSensing));
if (valueRemoteSensing & 0x01) // If setting bit 1 (LocalTemperature RemoteSensing bit)
huangzh142 marked this conversation as resolved.
Show resolved Hide resolved
{
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
}

EmberAfStatus status = RemoteSensing::Set(aPath.mEndpointId, valueRemoteSensing);
StatusIB statusIB(ToInteractionModelStatus(status));
return statusIB.ToChipError();
}
break;
huangzh142 marked this conversation as resolved.
Show resolved Hide resolved
default: // return CHIP_NO_ERROR and just write to the attribute store in default
break;
}

return CHIP_NO_ERROR;
}

} // anonymous namespace

void emberAfThermostatClusterServerInitCallback(chip::EndpointId endpoint)
{
// TODO
Expand All @@ -78,8 +166,6 @@ void emberAfThermostatClusterServerInitCallback(chip::EndpointId endpoint)
// or should this just be the responsibility of the thermostat application?
}

using imcode = Protocols::InteractionModel::Status;

Protocols::InteractionModel::Status
MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttributePath & attributePath,
EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
Expand Down Expand Up @@ -754,4 +840,7 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co
return true;
}

void MatterThermostatPluginServerInitCallback() {}
void MatterThermostatPluginServerInitCallback()
{
registerAttributeAccessOverride(&gThermostatAttrAccess);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ limitations under the License.
<field name="ScheduleConfiguration" mask="0x8"/>
<field name="Setback" mask="0x10"/>
<field name="AutoMode" mask="0x20"/>
<field name="LocalTemperatureNotExposed" mask="0x40"/>
</bitmap>

<bitmap name="DayOfWeek" type="BITMAP8">
Expand Down
1 change: 1 addition & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4345,6 +4345,7 @@ client cluster Thermostat = 513 {
kScheduleConfiguration = 0x8;
kSetback = 0x10;
kAutoMode = 0x20;
kLocalTemperatureNotExposed = 0x40;
}

bitmap ModeForSequence : BITMAP8 {
Expand Down
1 change: 1 addition & 0 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.