Skip to content

Commit

Permalink
Thermostat Cluster Init Function Enabled (#12863)
Browse files Browse the repository at this point in the history
* Enable thermostat 

emberAfThermostatClusterServerInitCallback via helper.js

Eliminated #ifdefs
FeatureMap new accessors

Feature map in functions to allow for more than one thermostat endpoint within a device.

* REGEN
  • Loading branch information
chrisbeach59 authored and pull[bot] committed Aug 3, 2023
1 parent 8d9e8a2 commit 1539944
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 61 deletions.
88 changes: 41 additions & 47 deletions src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ constexpr int8_t kDefaultDeadBand = 25; // 2.5C is the defaul
#define FEATURE_MAP_SB 0x10
#define FEATURE_MAP_AUTO 0x20

// Uncomment out FEATURE_MAP_OVERIDE and set appropriately for testing to overide ZAP
//#define FEATURE_MAP_OVERIDE FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO
#define FEATURE_MAP_DEFAULT FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO

void emberAfThermostatClusterServerInitCallback()
void emberAfThermostatClusterServerInitCallback(chip::EndpointId endpoint)
{
// TODO
// Get from the "real thermostat"
Expand Down Expand Up @@ -105,43 +104,40 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
int16_t AbsMaxCoolSetpointLimit;
int16_t MinCoolSetpointLimit;
int16_t MaxCoolSetpointLimit;
int8_t DeadBand = 0;
int16_t DeadBandTemp = 0;
uint32_t FeatureMap = 0;
bool AutoSupported = false;
bool HeatSupported = false;
bool CoolSupported = false;
bool OccupancySupported = false;
int8_t DeadBand = 0;
int16_t DeadBandTemp = 0;
int16_t OccupiedCoolingSetpoint;
int16_t OccupiedHeatingSetpoint;
int16_t UnoccupiedCoolingSetpoint;
int16_t UnoccupiedHeatingSetpoint;
uint32_t OurFeatureMap;
bool AutoSupported = false;
bool HeatSupported = false;
bool CoolSupported = false;
bool OccupancySupported = false;

#ifndef FEATURE_MAP_OVERIDE
emberAfReadServerAttribute(endpoint, chip::app::Clusters::Thermostat::Id,
chip::app::Clusters::Thermostat::Attributes::FeatureMap::Id,
reinterpret_cast<uint8_t *>(&FeatureMap), sizeof(FeatureMap));
#else
FeatureMap = FEATURE_MAP_OVERIDE;
#endif
if (FeatureMap::Get(endpoint, &OurFeatureMap) != EMBER_ZCL_STATUS_SUCCESS)
OurFeatureMap = FEATURE_MAP_DEFAULT;

if (FeatureMap & 1 << 5) // Bit 5 is Auto Mode supported
{
if (OurFeatureMap & 1 << 5) // Bit 5 is Auto Mode supported
AutoSupported = true;
if (MinSetpointDeadBand::Get(endpoint, &DeadBand) != EMBER_ZCL_STATUS_SUCCESS)
{
DeadBand = kDefaultDeadBand;
}
DeadBandTemp = static_cast<int16_t>(DeadBand * 10);
}
if (FeatureMap & 1 << 0)

if (OurFeatureMap & 1 << 0)
HeatSupported = true;

if (FeatureMap & 1 << 1)
if (OurFeatureMap & 1 << 1)
CoolSupported = true;

if (FeatureMap & 1 << 2)
OccupancySupported = true;
if (OurFeatureMap & 1 << 2)

if (AutoSupported)
{
if (MinSetpointDeadBand::Get(endpoint, &DeadBand) != EMBER_ZCL_STATUS_SUCCESS)
{
DeadBand = kDefaultDeadBand;
}
DeadBandTemp = static_cast<int16_t>(DeadBand * 10);
}

if (AbsMinCoolSetpointLimit::Get(endpoint, &AbsMinCoolSetpointLimit) != EMBER_ZCL_STATUS_SUCCESS)
AbsMinCoolSetpointLimit = kDefaultAbsMinCoolSetpointLimit;
Expand Down Expand Up @@ -551,33 +547,31 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co
EmberAfStatus status = EMBER_ZCL_STATUS_FAILURE;
EmberAfStatus WriteCoolingSetpointStatus = EMBER_ZCL_STATUS_FAILURE;
EmberAfStatus WriteHeatingSetpointStatus = EMBER_ZCL_STATUS_FAILURE;
bool AutoSupported = false;
bool HeatSupported = false;
bool CoolSupported = false;
int16_t DeadBandTemp = 0;
int8_t DeadBand = 0;
uint32_t FeatureMap = 0;
uint32_t OurFeatureMap;
bool AutoSupported = false;
bool HeatSupported = false;
bool CoolSupported = false;

#ifndef FEATURE_MAP_OVERIDE
emberAfReadServerAttribute(aEndpointId, chip::app::Clusters::Thermostat::Id,
chip::app::Clusters::Thermostat::Attributes::FeatureMap::Id,
reinterpret_cast<uint8_t *>(&FeatureMap), sizeof(FeatureMap));
#else
FeatureMap = FEATURE_MAP_OVERIDE;
#endif
if (FeatureMap::Get(aEndpointId, &OurFeatureMap) != EMBER_ZCL_STATUS_SUCCESS)
OurFeatureMap = FEATURE_MAP_DEFAULT;

if (FeatureMap & 1 << 5) // Bit 5 is Auto Mode supported
{
if (OurFeatureMap & 1 << 5) // Bit 5 is Auto Mode supported
AutoSupported = true;

if (OurFeatureMap & 1 << 0)
HeatSupported = true;

if (OurFeatureMap & 1 << 1)
CoolSupported = true;

if (AutoSupported)
{
if (MinSetpointDeadBand::Get(aEndpointId, &DeadBand) != EMBER_ZCL_STATUS_SUCCESS)
DeadBand = kDefaultDeadBand;
DeadBandTemp = static_cast<int16_t>(DeadBand * 10);
}
if (FeatureMap & 1 << 0)
HeatSupported = true;

if (FeatureMap & 1 << 1)
CoolSupported = true;

switch (mode)
{
Expand Down
11 changes: 6 additions & 5 deletions src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ function asReadType(type)
// List of all cluster with generated functions
var endpointClusterWithInit = [
'Basic',
'Identify',
'Color Control',
'Groups',
'Scenes',
'IAS Zone',
'Identify',
'Level Control',
'Occupancy Sensing',
'On/Off',
'Level Control',
'Color Control',
'IAS Zone',
'Pump Configuration and Control',
'Scenes',
'Thermostat',
];
var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock', 'Pump Configuration and Control' ];
var endpointClusterWithPreAttribute = [ 'IAS Zone', 'Thermostat User Interface Configuration' ];
Expand Down
12 changes: 9 additions & 3 deletions zzz_generated/all-clusters-app/zap-generated/endpoint_config.h

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

12 changes: 9 additions & 3 deletions zzz_generated/thermostat/zap-generated/endpoint_config.h

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

12 changes: 9 additions & 3 deletions zzz_generated/tv-casting-app/zap-generated/endpoint_config.h

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

0 comments on commit 1539944

Please sign in to comment.