Skip to content

Commit 64c1029

Browse files
huangzh142restyled-commits
authored andcommitted
Add support for LTNE (Local Temperature Not Exposed) feature in Therm… (#26686)
* Add support for LTNE (Local Temperature Not Exposed) feature in Thermostat Cluster * Restyled by clang-format * Tidy up code and use error-mapping function * Restyled by clang-format * Tidy up code and add some comments * Restyled by clang-format --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 508726a commit 64c1029

File tree

13 files changed

+110
-9
lines changed

13 files changed

+110
-9
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,7 @@ server cluster Thermostat = 513 {
32033203
kScheduleConfiguration = 0x8;
32043204
kSetback = 0x10;
32053205
kAutoMode = 0x20;
3206+
kLocalTemperatureNotExposed = 0x40;
32063207
}
32073208

32083209
bitmap ModeForSequence : BITMAP8 {

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,7 @@ server cluster Thermostat = 513 {
27252725
kScheduleConfiguration = 0x8;
27262726
kSetback = 0x10;
27272727
kAutoMode = 0x20;
2728+
kLocalTemperatureNotExposed = 0x40;
27282729
}
27292730

27302731
bitmap ModeForSequence : BITMAP8 {

examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter

+1
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ client cluster Thermostat = 513 {
13891389
kScheduleConfiguration = 0x8;
13901390
kSetback = 0x10;
13911391
kAutoMode = 0x20;
1392+
kLocalTemperatureNotExposed = 0x40;
13921393
}
13931394

13941395
bitmap ModeForSequence : BITMAP8 {

examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter

+1
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ server cluster Thermostat = 513 {
12461246
kScheduleConfiguration = 0x8;
12471247
kSetback = 0x10;
12481248
kAutoMode = 0x20;
1249+
kLocalTemperatureNotExposed = 0x40;
12491250
}
12501251

12511252
bitmap ModeForSequence : BITMAP8 {

examples/placeholder/linux/apps/app1/config.matter

+1
Original file line numberDiff line numberDiff line change
@@ -2476,6 +2476,7 @@ server cluster Thermostat = 513 {
24762476
kScheduleConfiguration = 0x8;
24772477
kSetback = 0x10;
24782478
kAutoMode = 0x20;
2479+
kLocalTemperatureNotExposed = 0x40;
24792480
}
24802481

24812482
bitmap ModeForSequence : BITMAP8 {

examples/placeholder/linux/apps/app2/config.matter

+1
Original file line numberDiff line numberDiff line change
@@ -2437,6 +2437,7 @@ server cluster Thermostat = 513 {
24372437
kScheduleConfiguration = 0x8;
24382438
kSetback = 0x10;
24392439
kAutoMode = 0x20;
2440+
kLocalTemperatureNotExposed = 0x40;
24402441
}
24412442

24422443
bitmap ModeForSequence : BITMAP8 {

examples/thermostat/thermostat-common/thermostat.matter

+1
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,7 @@ server cluster Thermostat = 513 {
16761676
kScheduleConfiguration = 0x8;
16771677
kSetback = 0x10;
16781678
kAutoMode = 0x20;
1679+
kLocalTemperatureNotExposed = 0x40;
16791680
}
16801681

16811682
bitmap ModeForSequence : BITMAP8 {

src/app/clusters/thermostat-server/thermostat-server.cpp

+92-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
#include <lib/core/CHIPEncoding.h>
3232

3333
using namespace chip;
34+
using namespace chip::app;
35+
using namespace chip::app::Clusters;
3436
using namespace chip::app::Clusters::Thermostat;
3537
using namespace chip::app::Clusters::Thermostat::Attributes;
3638

39+
using imcode = Protocols::InteractionModel::Status;
40+
3741
constexpr int16_t kDefaultAbsMinHeatSetpointLimit = 700; // 7C (44.5 F) is the default
3842
constexpr int16_t kDefaultAbsMaxHeatSetpointLimit = 3000; // 30C (86 F) is the default
3943
constexpr int16_t kDefaultMinHeatSetpointLimit = 700; // 7C (44.5 F) is the default
@@ -62,6 +66,90 @@ constexpr int8_t kDefaultDeadBand = 25; // 2.5C is the default
6266

6367
#define FEATURE_MAP_DEFAULT FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO
6468

69+
namespace {
70+
71+
class ThermostatAttrAccess : public AttributeAccessInterface
72+
{
73+
public:
74+
ThermostatAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), Thermostat::Id) {}
75+
76+
CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
77+
CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override;
78+
};
79+
80+
ThermostatAttrAccess gThermostatAttrAccess;
81+
82+
CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
83+
{
84+
VerifyOrDie(aPath.mClusterId == Thermostat::Id);
85+
86+
uint32_t ourFeatureMap;
87+
bool localTemperatureNotExposedSupported = (FeatureMap::Get(aPath.mEndpointId, &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS) &&
88+
((ourFeatureMap & to_underlying(Feature::kLocalTemperatureNotExposed)) != 0);
89+
90+
switch (aPath.mAttributeId)
91+
{
92+
case LocalTemperature::Id:
93+
if (localTemperatureNotExposedSupported)
94+
{
95+
return aEncoder.EncodeNull();
96+
}
97+
break;
98+
case RemoteSensing::Id:
99+
if (localTemperatureNotExposedSupported)
100+
{
101+
uint8_t valueRemoteSensing;
102+
EmberAfStatus status = RemoteSensing::Get(aPath.mEndpointId, &valueRemoteSensing);
103+
if (status != EMBER_ZCL_STATUS_SUCCESS)
104+
{
105+
StatusIB statusIB(ToInteractionModelStatus(status));
106+
return statusIB.ToChipError();
107+
}
108+
valueRemoteSensing &= 0xFE; // clear bit 1 (LocalTemperature RemoteSensing bit)
109+
return aEncoder.Encode(valueRemoteSensing);
110+
}
111+
break;
112+
default: // return CHIP_NO_ERROR and just read from the attribute store in default
113+
break;
114+
}
115+
116+
return CHIP_NO_ERROR;
117+
}
118+
119+
CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
120+
{
121+
VerifyOrDie(aPath.mClusterId == Thermostat::Id);
122+
123+
uint32_t ourFeatureMap;
124+
bool localTemperatureNotExposedSupported = (FeatureMap::Get(aPath.mEndpointId, &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS) &&
125+
((ourFeatureMap & to_underlying(Feature::kLocalTemperatureNotExposed)) != 0);
126+
127+
switch (aPath.mAttributeId)
128+
{
129+
case RemoteSensing::Id:
130+
if (localTemperatureNotExposedSupported)
131+
{
132+
uint8_t valueRemoteSensing;
133+
ReturnErrorOnFailure(aDecoder.Decode(valueRemoteSensing));
134+
if (valueRemoteSensing & 0x01) // If setting bit 1 (LocalTemperature RemoteSensing bit)
135+
{
136+
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
137+
}
138+
139+
EmberAfStatus status = RemoteSensing::Set(aPath.mEndpointId, valueRemoteSensing);
140+
StatusIB statusIB(ToInteractionModelStatus(status));
141+
return statusIB.ToChipError();
142+
}
143+
break;
144+
default: // return CHIP_NO_ERROR and just write to the attribute store in default
145+
break;
146+
}
147+
148+
return CHIP_NO_ERROR;
149+
}
150+
151+
} // anonymous namespace
152+
65153
void emberAfThermostatClusterServerInitCallback(chip::EndpointId endpoint)
66154
{
67155
// TODO
@@ -78,8 +166,6 @@ void emberAfThermostatClusterServerInitCallback(chip::EndpointId endpoint)
78166
// or should this just be the responsibility of the thermostat application?
79167
}
80168

81-
using imcode = Protocols::InteractionModel::Status;
82-
83169
Protocols::InteractionModel::Status
84170
MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttributePath & attributePath,
85171
EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
@@ -754,4 +840,7 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co
754840
return true;
755841
}
756842

757-
void MatterThermostatPluginServerInitCallback() {}
843+
void MatterThermostatPluginServerInitCallback()
844+
{
845+
registerAttributeAccessOverride(&gThermostatAttrAccess);
846+
}

src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ limitations under the License.
2525
<field name="ScheduleConfiguration" mask="0x8"/>
2626
<field name="Setback" mask="0x10"/>
2727
<field name="AutoMode" mask="0x20"/>
28+
<field name="LocalTemperatureNotExposed" mask="0x40"/>
2829
</bitmap>
2930

3031
<bitmap name="DayOfWeek" type="BITMAP8">

src/controller/data_model/controller-clusters.matter

+1
Original file line numberDiff line numberDiff line change
@@ -4341,6 +4341,7 @@ client cluster Thermostat = 513 {
43414341
kScheduleConfiguration = 0x8;
43424342
kSetback = 0x10;
43434343
kAutoMode = 0x20;
4344+
kLocalTemperatureNotExposed = 0x40;
43444345
}
43454346

43464347
bitmap ModeForSequence : BITMAP8 {

src/controller/python/chip/clusters/Objects.py

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/app-common/app-common/zap-generated/cluster-enums.h

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)