Skip to content

Commit 2d8e00e

Browse files
committed
GH-32: Update Thermostat Supported mode attribute
ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_SUPPORTED_MODES is now a uint32_t to allow easy mapping to .uam. WARNING : This change will break existing Thermostat Supported Modes attribute. Either undefined reported value or include the device again. Forwarded: #32 Bug-SiliconLabs: UIC-3069 Bug-Github: #32
1 parent 3b43b68 commit 2d8e00e

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static const std::vector<attribute_schema_t> attribute_schema = {
289289
/////////////////////////////////////////////////////////////////////
290290
{ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_MODE_VERSION, "Thermostat Mode Version", ATTRIBUTE_ENDPOINT_ID, U8_STORAGE_TYPE},
291291
{ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_MODE, "Thermostat Mode", ATTRIBUTE_ENDPOINT_ID, I32_STORAGE_TYPE},
292-
{ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_SUPPORTED_MODES, "Thermostat Supported Modes", ATTRIBUTE_ENDPOINT_ID, BYTE_ARRAY_STORAGE_TYPE},
292+
{ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_SUPPORTED_MODES, "Thermostat Supported Modes", ATTRIBUTE_ENDPOINT_ID, U32_STORAGE_TYPE},
293293
/////////////////////////////////////////////////////////////////////
294294
// Thermostat Setpoint Command Class attributes
295295
/////////////////////////////////////////////////////////////////////

applications/zpc/components/zwave_command_classes/src/zwave_command_class_thermostat_mode.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,23 @@ static sl_status_t zwave_command_class_thermostat_mode_handle_supported_report(
189189

190190
uint8_t bitmask_length
191191
= frame_length - THERMOSTAT_MODE_SUPPORTED_REPORT_BITMASK_INDEX;
192+
uint32_t supported_thermostat_bitmask = 0x0000;
192193

193-
attribute_store_set_node_attribute_value(
194-
supported_modes_node,
195-
REPORTED_ATTRIBUTE,
196-
&frame_data[THERMOSTAT_MODE_SUPPORTED_REPORT_BITMASK_INDEX],
197-
bitmask_length);
194+
// Since we are using uint32_t we can't have more that 4 bit mask
195+
if (bitmask_length > 4) {
196+
sl_log_error(LOG_TAG,
197+
"Supported Thermostat Mode type Bit Mask length is not supported\n");
198+
return SL_STATUS_NOT_SUPPORTED;
199+
}
200+
201+
for (int i = bitmask_length; i > 0; i--) {
202+
supported_thermostat_bitmask
203+
= (supported_thermostat_bitmask << 8) | frame_data[1 + i];
204+
}
205+
206+
attribute_store_set_reported(supported_modes_node,
207+
&supported_thermostat_bitmask,
208+
sizeof(supported_thermostat_bitmask));
198209

199210
return SL_STATUS_OK;
200211
}

applications/zpc/components/zwave_command_classes/test/zwave_command_class_thermostat_mode_test.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -371,31 +371,29 @@ void test_thermostat_mode_incoming_supported_report_happy_case()
371371
ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_SUPPORTED_MODES,
372372
endpoint_id_node);
373373

374+
uint8_t bit1 = 0b0000101;
375+
uint8_t bit2 = 0b0000011;
376+
uint8_t bit3 = 0b1111111;
374377
const uint8_t incoming_report_frame[] = {COMMAND_CLASS_THERMOSTAT_MODE_V3,
375378
THERMOSTAT_MODE_SUPPORTED_REPORT_V3,
376-
1,
377-
3,
378-
4,
379-
5,
380-
6};
379+
bit1,
380+
bit2,
381+
bit3};
381382

382383
TEST_ASSERT_EQUAL(
383384
SL_STATUS_OK,
384385
thermostat_mode_handler.control_handler(&connection_info,
385386
incoming_report_frame,
386387
sizeof(incoming_report_frame)));
387388

388-
uint8_t received_bitmask[20] = {};
389-
uint8_t received_bitmask_length = 0;
390-
attribute_store_get_node_attribute_value(supported_modes_node,
391-
REPORTED_ATTRIBUTE,
392-
received_bitmask,
393-
&received_bitmask_length);
394-
395-
TEST_ASSERT_EQUAL(5, received_bitmask_length);
396-
TEST_ASSERT_EQUAL_UINT8_ARRAY(&incoming_report_frame[2],
397-
received_bitmask,
398-
received_bitmask_length);
389+
uint32_t received_bitmask = 0;
390+
attribute_store_get_reported(supported_modes_node,
391+
&received_bitmask,
392+
sizeof(received_bitmask));
393+
394+
TEST_ASSERT_EQUAL_MESSAGE((bit3) << 16 | (bit2) << 8 | bit1,
395+
received_bitmask,
396+
"Received Bitmask mismatch");
399397
}
400398

401399
void test_thermostat_mode_incoming_supported_report_too_short()

0 commit comments

Comments
 (0)