Skip to content

Commit 1051812

Browse files
eve-cxrppull[bot]
eve-cxrp
authored andcommitted
Bugfix termostat user interface value validation (#11058)
* add support for boundry checks for thermostat-user-interface-configuration * add impl for boundry checks for thermostat-user-interface-configuration in all-clsuter-app * add check for size and remove static cast to unit8 * add support for ProAttribute hook for thermostat user interface configuration * remove preattribute hooks in all-cluster-app/linux * regen all * fix esp32 and mbed builds
1 parent 0d0552f commit 1051812

File tree

7 files changed

+79
-4
lines changed

7 files changed

+79
-4
lines changed

examples/all-clusters-app/esp32/main/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ set(SRC_DIRS_LIST
5555
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/media-playback-server"
5656
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-provider"
5757
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/target-navigator-server"
58-
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-server"
58+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-server"
59+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-user-interface-configuration-server"
5960
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread_network_diagnostics_server"
6061
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/tv-channel-server"
6162
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes"

examples/all-clusters-app/linux/main.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616
* limitations under the License.
1717
*/
1818

19+
#include <app-common/zap-generated/callback.h>
20+
#include <app-common/zap-generated/ids/Clusters.h>
1921
#include <app/Command.h>
22+
#include <app/ConcreteAttributePath.h>
2023
#include <app/clusters/identify-server/identify-server.h>
2124
#include <app/util/af.h>
2225

2326
#include "AppMain.h"
2427

28+
using namespace chip;
29+
2530
bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj)
2631
{
2732
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);

examples/all-clusters-app/mbed/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ target_sources(${APP_TARGET} PRIVATE
120120
${APP_CLUSTERS}/scenes/scenes.cpp
121121
${APP_CLUSTERS}/target-navigator-server/target-navigator-server.cpp
122122
${APP_CLUSTERS}/thermostat-server/thermostat-server.cpp
123+
${APP_CLUSTERS}/thermostat-user-interface-configuration-server/thermostat-user-interface-configuration-server.cpp
123124
${APP_CLUSTERS}/tv-channel-server/tv-channel-server.cpp
124125
${APP_CLUSTERS}/operational-credentials-server/operational-credentials-server.cpp
125126
${APP_CLUSTERS}/test-cluster-server/test-cluster-server.cpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <app/util/af.h>
2+
3+
#include <app/util/af-event.h>
4+
#include <app/util/attribute-storage.h>
5+
6+
#include <app-common/zap-generated/attribute-id.h>
7+
#include <app-common/zap-generated/attribute-type.h>
8+
#include <app-common/zap-generated/attributes/Accessors.h>
9+
#include <app-common/zap-generated/callback.h>
10+
#include <app-common/zap-generated/cluster-id.h>
11+
#include <app-common/zap-generated/cluster-objects.h>
12+
#include <app-common/zap-generated/command-id.h>
13+
#include <app-common/zap-generated/enums.h>
14+
#include <app-common/zap-generated/ids/Attributes.h>
15+
#include <app/CommandHandler.h>
16+
#include <app/ConcreteAttributePath.h>
17+
#include <app/ConcreteCommandPath.h>
18+
#include <app/util/error-mapping.h>
19+
#include <lib/core/CHIPEncoding.h>
20+
21+
using namespace chip;
22+
using namespace chip::app;
23+
using namespace chip::app::Clusters;
24+
25+
Protocols::InteractionModel::Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback(
26+
const app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
27+
{
28+
if (size != 0)
29+
{
30+
if (ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId)
31+
{
32+
EmberAfTemperatureDisplayMode mode = static_cast<EmberAfTemperatureDisplayMode>(chip::Encoding::Get8(value));
33+
if ((EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_CELSIUS != mode) && (EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_FAHRENHEIT != mode))
34+
{
35+
return Protocols::InteractionModel::Status::Failure;
36+
}
37+
}
38+
else if (ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::Id == attributePath.mAttributeId)
39+
{
40+
EmberAfKeypadLockout lockout = static_cast<EmberAfKeypadLockout>(chip::Encoding::Get8(value));
41+
if ((EMBER_ZCL_KEYPAD_LOCKOUT_NO_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_ONE_LOCKOUT != lockout) &&
42+
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_TWO_LOCKOUT != lockout) &&
43+
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_THREE_LOCKOUT != lockout) &&
44+
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_FOUR_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVELFIVE_LOCKOUT != lockout))
45+
{
46+
return Protocols::InteractionModel::Status::Failure;
47+
}
48+
}
49+
else if (ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId)
50+
{
51+
uint8_t prog = chip::Encoding::Get8(value);
52+
if (prog > 1)
53+
{
54+
return Protocols::InteractionModel::Status::Failure;
55+
}
56+
}
57+
}
58+
59+
return Protocols::InteractionModel::Status::Success;
60+
}

src/app/zap-templates/templates/app/helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ var endpointClusterWithInit = [
106106
'Pump Configuration and Control',
107107
];
108108
var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock', 'Pump Configuration and Control' ];
109-
var endpointClusterWithPreAttribute = [ 'IAS Zone' ];
109+
var endpointClusterWithPreAttribute = [ 'IAS Zone', 'Thermostat User Interface Configuration' ];
110110
var endpointClusterWithMessageSent = [ 'IAS Zone' ];
111111

112112
/**

src/app/zap_cluster_list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
'THERMOSTAT_CLUSTER': ['thermostat-server'],
7070
'THREAD_NETWORK_DIAGNOSTICS_CLUSTER': ['thread_network_diagnostics_server'],
7171
'WINDOW_COVERING_CLUSTER': ['window-covering-server'],
72-
'THERMOSTAT_UI_CONFIG_CLUSTER': [],
72+
'THERMOSTAT_UI_CONFIG_CLUSTER': ['thermostat-user-interface-configuration-server'],
7373
'WIFI_NETWORK_DIAGNOSTICS_CLUSTER': ['wifi_network_diagnostics_server'],
7474
'WAKE_ON_LAN_CLUSTER': [],
7575
'ZLL_COMMISSIONING_CLUSTER': []

zzz_generated/all-clusters-app/zap-generated/endpoint_config.h

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

0 commit comments

Comments
 (0)