Skip to content

Commit 504476a

Browse files
committed
SiliconLabsGH-46: Humidity Control Operating State CC
ZPC implementation only Forwarded: SiliconLabs#46 Bug-SiliconLabs: UIC-3068 Bug-Github: SiliconLabs#46
1 parent 3ee31ac commit 504476a

8 files changed

+425
-0
lines changed

applications/zpc/components/zpc_attribute_store/include/attribute_store_defined_attribute_types.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,17 @@ DEFINE_ATTRIBUTE(ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_MODE_SUPPORTED_MODES,
544544
DEFINE_ATTRIBUTE(ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_MODE_CURRENT_MODE,
545545
((COMMAND_CLASS_HUMIDITY_CONTROL_MODE << 8) | 0x03))
546546

547+
/////////////////////////////////////////////////
548+
// Humidity Control Operating State Command Class
549+
///< This represents the version of the Humidity Control Mode Command class.
550+
/// zwave_cc_version_t
551+
DEFINE_ATTRIBUTE(ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_VERSION,
552+
ZWAVE_CC_VERSION_ATTRIBUTE(COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE))
553+
554+
// Current state
555+
DEFINE_ATTRIBUTE(ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_CURRENT_STATE,
556+
((COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE << 8) | 0x02))
557+
547558
/////////////////////////////////////////////////
548559
// Inclusion Controller Command Class
549560
///< This represents the version of the Inclusion Controller Command class.

applications/zpc/components/zpc_attribute_store/include/command_class_types/zwave_command_class_humidity_control_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ typedef uint8_t humidity_control_mode_t;
3737
///> Humidity Control Suppoted Mode Bitmask. uint8_t
3838
typedef uint8_t humidity_control_supported_modes_t;
3939

40+
//>> Humidity Control Operating State CC
41+
///> Humidity Control Operating State. uint8_t
42+
typedef uint8_t humidity_control_operating_state_t;
43+
4044
#ifdef __cplusplus
4145
extern "C" {
4246
#endif

applications/zpc/components/zpc_attribute_store/src/zpc_attribute_store_type_registration.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ static const std::vector<attribute_schema_t> attribute_schema = {
201201
{ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_MODE_SUPPORTED_MODES, "Humidity Control Mode Supported Modes", ATTRIBUTE_ENDPOINT_ID, U8_STORAGE_TYPE},
202202
{ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_MODE_CURRENT_MODE, "Humidity Control Mode Current Mode", ATTRIBUTE_INDICATOR_INDICATOR_ID, U8_STORAGE_TYPE},
203203

204+
/////////////////////////////////////////////////////////////////////
205+
// Humidity Control Operating State Command Class attributes
206+
/////////////////////////////////////////////////////////////////////
207+
{ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_VERSION, "Humidity Control Operating State Version", ATTRIBUTE_ENDPOINT_ID, U8_STORAGE_TYPE},
208+
{ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_CURRENT_STATE, "Humidity Control Operating State Current State", ATTRIBUTE_INDICATOR_INDICATOR_ID, U8_STORAGE_TYPE},
209+
204210
/////////////////////////////////////////////////////////////////////
205211
// Meter Command Class attributes
206212
/////////////////////////////////////////////////////////////////////

applications/zpc/components/zwave_command_classes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ add_library(
2222
src/zwave_command_class_door_lock_control.cpp
2323
src/zwave_command_class_firmware_update.c
2424
src/zwave_command_class_humidity_control_mode.c
25+
src/zwave_command_class_humidity_control_operating_state.c
2526
src/zwave_command_class_indicator.c
2627
src/zwave_command_class_indicator_control.cpp
2728
src/zwave_command_class_manufacturer_specific.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
2+
/******************************************************************************
3+
* # License
4+
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
5+
******************************************************************************
6+
* The licensor of this software is Silicon Laboratories Inc. Your use of this
7+
* software is governed by the terms of Silicon Labs Master Software License
8+
* Agreement (MSLA) available at
9+
* www.silabs.com/about-us/legal/master-software-license-agreement. This
10+
* software is distributed to you in Source Code format and is governed by the
11+
* sections of the MSLA applicable to Source Code.
12+
*
13+
*****************************************************************************/
14+
15+
// System
16+
#include <stdlib.h>
17+
18+
#include "zwave_command_class_humidity_control_operating_state.h"
19+
#include "zwave_command_class_humidity_control_types.h"
20+
#include "zwave_command_classes_utils.h"
21+
#include "ZW_classcmd.h"
22+
23+
// Includes from other ZPC Components
24+
#include "zwave_command_class_indices.h"
25+
#include "zwave_command_handler.h"
26+
#include "zwave_command_class_version_types.h"
27+
#include "zpc_attribute_store_network_helper.h"
28+
#include "attribute_store_defined_attribute_types.h"
29+
30+
// Unify
31+
#include "attribute_resolver.h"
32+
#include "attribute_store.h"
33+
#include "attribute_store_helper.h"
34+
#include "sl_log.h"
35+
36+
#define LOG_TAG "zwave_command_class_humidity_control_operating_state"
37+
38+
/////////////////////////////////////////////////////////////////////////////
39+
// Version & Attribute Creation
40+
/////////////////////////////////////////////////////////////////////////////
41+
static void
42+
zwave_command_class_humidity_control_operating_state_on_version_attribute_update(
43+
attribute_store_node_t updated_node, attribute_store_change_t change)
44+
{
45+
if (change == ATTRIBUTE_DELETED) {
46+
return;
47+
}
48+
49+
zwave_cc_version_t version = 0;
50+
attribute_store_get_reported(updated_node, &version, sizeof(version));
51+
52+
if (version == 0) {
53+
return;
54+
}
55+
56+
attribute_store_node_t endpoint_node
57+
= attribute_store_get_first_parent_with_type(updated_node,
58+
ATTRIBUTE_ENDPOINT_ID);
59+
60+
// The order of the attribute matter since it defines the order of the
61+
// Z-Wave get command order.
62+
const attribute_store_type_t attributes[]
63+
= {ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_CURRENT_STATE};
64+
65+
attribute_store_add_if_missing(endpoint_node,
66+
attributes,
67+
COUNT_OF(attributes));
68+
}
69+
70+
/////////////////////////////////////////////////////////////////////////////
71+
// Humidity Control Operating State State Get/Report
72+
/////////////////////////////////////////////////////////////////////////////
73+
74+
static sl_status_t zwave_command_class_humidity_control_operating_state_get(
75+
attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
76+
{
77+
(void)node; // unused.
78+
ZW_HUMIDITY_CONTROL_OPERATING_STATE_GET_FRAME *get_frame
79+
= (ZW_HUMIDITY_CONTROL_OPERATING_STATE_GET_FRAME *)frame;
80+
get_frame->cmdClass = COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE;
81+
get_frame->cmd = HUMIDITY_CONTROL_OPERATING_STATE_GET;
82+
*frame_length = sizeof(ZW_HUMIDITY_CONTROL_OPERATING_STATE_GET_FRAME);
83+
return SL_STATUS_OK;
84+
}
85+
86+
sl_status_t zwave_command_class_humidity_control_operating_state_handle_report(
87+
const zwave_controller_connection_info_t *connection_info,
88+
const uint8_t *frame_data,
89+
uint16_t frame_length)
90+
{
91+
if (frame_length < 3) {
92+
return SL_STATUS_FAIL;
93+
}
94+
95+
humidity_control_operating_state_t fan_state
96+
= frame_data[2]
97+
& HUMIDITY_CONTROL_OPERATING_STATE_REPORT_PROPERTIES1_OPERATING_STATE_MASK;
98+
99+
attribute_store_node_t endpoint_node
100+
= zwave_command_class_get_endpoint_node(connection_info);
101+
102+
attribute_store_set_child_reported(
103+
endpoint_node,
104+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_CURRENT_STATE,
105+
&fan_state,
106+
sizeof(fan_state));
107+
108+
return SL_STATUS_OK;
109+
}
110+
111+
sl_status_t
112+
zwave_command_class_humidity_control_operating_state_control_handler(
113+
const zwave_controller_connection_info_t *connection_info,
114+
const uint8_t *frame_data,
115+
uint16_t frame_length)
116+
{
117+
if (frame_length <= COMMAND_INDEX) {
118+
return SL_STATUS_NOT_SUPPORTED;
119+
}
120+
121+
switch (frame_data[COMMAND_INDEX]) {
122+
case HUMIDITY_CONTROL_OPERATING_STATE_REPORT:
123+
return zwave_command_class_humidity_control_operating_state_handle_report(
124+
connection_info,
125+
frame_data,
126+
frame_length);
127+
default:
128+
return SL_STATUS_NOT_SUPPORTED;
129+
}
130+
}
131+
132+
sl_status_t zwave_command_class_humidity_control_operating_state_init()
133+
{
134+
attribute_store_register_callback_by_type(
135+
&zwave_command_class_humidity_control_operating_state_on_version_attribute_update,
136+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_VERSION);
137+
138+
attribute_resolver_register_rule(
139+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_CURRENT_STATE,
140+
NULL,
141+
&zwave_command_class_humidity_control_operating_state_get);
142+
143+
zwave_command_handler_t handler = {};
144+
handler.support_handler = NULL;
145+
handler.control_handler
146+
= zwave_command_class_humidity_control_operating_state_control_handler;
147+
handler.minimal_scheme = ZWAVE_CONTROLLER_ENCAPSULATION_NONE;
148+
handler.manual_security_validation = false;
149+
handler.command_class = COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE;
150+
handler.version = 1;
151+
handler.command_class_name = "Humidity Control Operating State";
152+
handler.comments = "Experimental";
153+
154+
return zwave_command_handler_register_handler(handler);
155+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
/******************************************************************************
3+
* # License
4+
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
5+
******************************************************************************
6+
* The licensor of this software is Silicon Laboratories Inc. Your use of this
7+
* software is governed by the terms of Silicon Labs Master Software License
8+
* Agreement (MSLA) available at
9+
* www.silabs.com/about-us/legal/master-software-license-agreement. This
10+
* software is distributed to you in Source Code format and is governed by the
11+
* sections of the MSLA applicable to Source Code.
12+
*
13+
*****************************************************************************/
14+
15+
/**
16+
* @defgroup zwave_command_class_humidity_control_operating_state
17+
* @brief Sound Switch Command Class handlers and control function
18+
*
19+
* This module implement some of the functions to control the
20+
* Sound Switch Command Class
21+
*
22+
* @{
23+
*/
24+
25+
#ifndef ZWAVE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_H
26+
#define ZWAVE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_H
27+
28+
#include "sl_status.h"
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
sl_status_t zwave_command_class_humidity_control_operating_state_init();
35+
36+
#ifdef __cplusplus
37+
}
38+
#endif
39+
40+
#endif //ZWAVE_COMMAND_CLASS_HUMIDITY_CONTROL_OPERATING_STATE_H
41+
/** @} end zwave_command_class_humidity_control_operating_state */

applications/zpc/components/zwave_command_classes/test/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,5 +742,20 @@ target_add_unittest(
742742
zpc_attribute_resolver_mock
743743
uic_dotdot_mqtt_mock)
744744

745+
# Humidity Control Mode test
746+
target_add_unittest(
747+
zwave_command_classes
748+
NAME
749+
zwave_command_class_humidity_control_operating_state_test
750+
SOURCES
751+
zwave_command_class_humidity_control_operating_state_test.c
752+
DEPENDS
753+
zpc_attribute_store_test_helper
754+
zwave_controller
755+
zwave_command_handler_mock
756+
uic_attribute_resolver_mock
757+
zpc_attribute_resolver_mock
758+
uic_dotdot_mqtt_mock)
759+
745760

746761

0 commit comments

Comments
 (0)