Skip to content

Commit 21e4efe

Browse files
committed
SiliconLabsGH-36: Send 0xFF by default for endpoint_find controllable with a flag
A new flag have been introduced to send the endpoint Generic/Specific class in multi_channel_endpoint_find. The default behavior is to send 0xFF to discover all endpoints. Forwarded: SiliconLabs#36 Bug-SiliconLabs: UIC-3160 Bug-Github: SiliconLabs#36
1 parent 3b43b68 commit 21e4efe

File tree

4 files changed

+126
-21
lines changed

4 files changed

+126
-21
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,10 @@ DEFINE_ATTRIBUTE(
613613
DEFINE_ATTRIBUTE(ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_AGGREGATED_MEMBERS,
614614
((COMMAND_CLASS_MULTI_CHANNEL_V3 << 8) | 0x06))
615615

616+
/** If set will send the endpoint Generic/Specific device class in ZW_MULTI_CHANNEL_END_POINT_FIND */
617+
DEFINE_ATTRIBUTE(ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_FLAG_SEND_TARGETED_DEVICE_CLASS,
618+
((COMMAND_CLASS_MULTI_CHANNEL_V3 << 8) | 0x07))
619+
616620
/////////////////////////////////////////////////
617621
// Notification Command Class
618622
DEFINE_ATTRIBUTE(ATTRIBUTE_COMMAND_CLASS_NOTIFICATION_VERSION,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ static const std::vector<attribute_schema_t> attribute_schema = {
249249
{ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_AGGREGATED_ENDPOINTS, "Aggregated Endpoints", ATTRIBUTE_ENDPOINT_ID, U8_STORAGE_TYPE},
250250
{ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_ALL_INDIVIDUAL_ENDPOINTS_FOUND, "All Endpoints discovered", ATTRIBUTE_ENDPOINT_ID, U8_STORAGE_TYPE},
251251
{ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_AGGREGATED_MEMBERS, "Aggregated endpoint members bitmask", ATTRIBUTE_ENDPOINT_ID, BYTE_ARRAY_STORAGE_TYPE},
252+
{ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_FLAG_SEND_TARGETED_DEVICE_CLASS, "If set will send the endpoint Generic/Specific device class in ZW_MULTI_CHANNEL_END_POINT_FIND", ATTRIBUTE_ENDPOINT_ID, U8_STORAGE_TYPE},
253+
252254
/////////////////////////////////////////////////////////////////////
253255
// Notification Command Class attributes
254256
/////////////////////////////////////////////////////////////////////

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

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -558,32 +558,46 @@ sl_status_t zwave_command_class_multi_channel_capability_get(
558558
static sl_status_t zwave_command_class_multi_channel_endpoint_find(
559559
attribute_store_node_t node, uint8_t *frame, uint16_t *frame_len)
560560
{
561-
uint8_t generic_device_class = 0;
562-
uint8_t specific_device_class = 0;
561+
uint8_t generic_device_class = 0xFF;
562+
uint8_t specific_device_class = 0xFF;
563563

564564
attribute_store_node_t endpoint_node
565565
= attribute_store_get_first_parent_with_type(node, ATTRIBUTE_ENDPOINT_ID);
566566

567-
sl_status_t result = attribute_store_get_child_reported(
567+
uint8_t endpoint_find_legacy = 0;
568+
sl_status_t status = attribute_store_get_child_reported(
568569
endpoint_node,
569-
ATTRIBUTE_ZWAVE_GENERIC_DEVICE_CLASS,
570-
&generic_device_class,
571-
sizeof(generic_device_class));
572-
573-
if (result != SL_STATUS_OK) {
574-
sl_log_warning(LOG_TAG, "Can't find generic device class. Setting to default 0xff");
575-
generic_device_class = 0xFF;
576-
}
577-
578-
result = attribute_store_get_child_reported(
579-
endpoint_node,
580-
ATTRIBUTE_ZWAVE_SPECIFIC_DEVICE_CLASS,
581-
&specific_device_class,
582-
sizeof(specific_device_class));
570+
ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_FLAG_SEND_TARGETED_DEVICE_CLASS,
571+
&endpoint_find_legacy,
572+
sizeof(endpoint_find_legacy));
573+
574+
// By default we use 0xFF to discover all endpoint supported by the device.
575+
// Some legacy device doesn't support 0xFF and needs to send the device Generic/Specific class instead
576+
// So we use a flag to control that behavior
577+
if (status == SL_STATUS_OK && endpoint_find_legacy) {
578+
sl_status_t result
579+
= attribute_store_get_child_reported(endpoint_node,
580+
ATTRIBUTE_ZWAVE_GENERIC_DEVICE_CLASS,
581+
&generic_device_class,
582+
sizeof(generic_device_class));
583+
584+
if (result != SL_STATUS_OK) {
585+
sl_log_warning(
586+
LOG_TAG,
587+
"Can't find generic device class. Setting to default 0xff");
588+
}
583589

584-
if (result != SL_STATUS_OK) {
585-
sl_log_warning(LOG_TAG, "Can't find specific device class. Setting to default 0xff");
586-
specific_device_class = 0xFF;
590+
result = attribute_store_get_child_reported(
591+
endpoint_node,
592+
ATTRIBUTE_ZWAVE_SPECIFIC_DEVICE_CLASS,
593+
&specific_device_class,
594+
sizeof(specific_device_class));
595+
596+
if (result != SL_STATUS_OK) {
597+
sl_log_warning(
598+
LOG_TAG,
599+
"Can't find specific device class. Setting to default 0xff");
600+
}
587601
}
588602

589603
// Create a frame for the attribute resolver

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

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void test_zwave_command_class_multi_channel_capability_get_happy_case()
179179
last_received_frame_length);
180180
}
181181

182-
void test_zwave_command_class_multi_channel_endpoint_find()
182+
void test_zwave_command_class_multi_channel_endpoint_find_with_flag()
183183
{
184184
attribute_store_node_t test_node = 0x9485;
185185
attribute_store_node_t test_endpoint_node = 0xf7;
@@ -189,6 +189,19 @@ void test_zwave_command_class_multi_channel_endpoint_find()
189189
ATTRIBUTE_ENDPOINT_ID,
190190
test_endpoint_node);
191191

192+
// Set legacy flag
193+
uint8_t legacy_flag = 1;
194+
attribute_store_get_child_reported_ExpectAndReturn(test_endpoint_node,
195+
ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_FLAG_SEND_TARGETED_DEVICE_CLASS,
196+
NULL,
197+
sizeof(uint8_t),
198+
SL_STATUS_OK);
199+
attribute_store_get_child_reported_IgnoreArg_value();
200+
attribute_store_get_child_reported_ReturnMemThruPtr_value(
201+
&legacy_flag,
202+
sizeof(legacy_flag));
203+
204+
192205
// Simulate not existing parameter
193206
uint8_t generic_device_class = 0xFF;
194207
attribute_store_get_child_reported_ExpectAndReturn(test_endpoint_node,
@@ -212,6 +225,8 @@ void test_zwave_command_class_multi_channel_endpoint_find()
212225
sizeof(specific_device_class));
213226

214227

228+
229+
215230
TEST_ASSERT_EQUAL(SL_STATUS_OK,
216231
zwave_command_class_multi_channel_endpoint_find(
217232
test_node,
@@ -227,7 +242,77 @@ void test_zwave_command_class_multi_channel_endpoint_find()
227242
last_received_frame,
228243
last_received_frame_length);
229244
}
245+
void test_zwave_command_class_multi_channel_endpoint_find_no_flag()
246+
{
247+
attribute_store_node_t test_node = 0x9485;
248+
attribute_store_node_t test_endpoint_node = 0xf7;
249+
250+
attribute_store_get_first_parent_with_type_ExpectAndReturn(
251+
test_node,
252+
ATTRIBUTE_ENDPOINT_ID,
253+
test_endpoint_node);
254+
255+
256+
attribute_store_get_child_reported_ExpectAndReturn(test_endpoint_node,
257+
ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_FLAG_SEND_TARGETED_DEVICE_CLASS,
258+
NULL,
259+
sizeof(uint8_t),
260+
SL_STATUS_FAIL);
261+
attribute_store_get_child_reported_IgnoreArg_value();
262+
263+
TEST_ASSERT_EQUAL(SL_STATUS_OK,
264+
zwave_command_class_multi_channel_endpoint_find(
265+
test_node,
266+
last_received_frame,
267+
&last_received_frame_length));
268+
269+
const uint8_t expected_frame_data[] = {COMMAND_CLASS_MULTI_CHANNEL_V4,
270+
MULTI_CHANNEL_END_POINT_FIND_V4,
271+
0xFF,
272+
0xFF};
273+
TEST_ASSERT_EQUAL(sizeof(expected_frame_data), last_received_frame_length);
274+
TEST_ASSERT_EQUAL_INT8_ARRAY(expected_frame_data,
275+
last_received_frame,
276+
last_received_frame_length);
277+
}
278+
279+
void test_zwave_command_class_multi_channel_endpoint_find_flag_but_off()
280+
{
281+
attribute_store_node_t test_node = 0x9485;
282+
attribute_store_node_t test_endpoint_node = 0xf7;
283+
284+
attribute_store_get_first_parent_with_type_ExpectAndReturn(
285+
test_node,
286+
ATTRIBUTE_ENDPOINT_ID,
287+
test_endpoint_node);
288+
289+
// Set legacy flag
290+
uint8_t legacy_flag = 0;
291+
attribute_store_get_child_reported_ExpectAndReturn(test_endpoint_node,
292+
ATTRIBUTE_COMMAND_CLASS_MULTI_CHANNEL_FLAG_SEND_TARGETED_DEVICE_CLASS,
293+
NULL,
294+
sizeof(uint8_t),
295+
SL_STATUS_OK);
296+
attribute_store_get_child_reported_IgnoreArg_value();
297+
attribute_store_get_child_reported_ReturnMemThruPtr_value(
298+
&legacy_flag,
299+
sizeof(legacy_flag));
230300

301+
TEST_ASSERT_EQUAL(SL_STATUS_OK,
302+
zwave_command_class_multi_channel_endpoint_find(
303+
test_node,
304+
last_received_frame,
305+
&last_received_frame_length));
306+
307+
const uint8_t expected_frame_data[] = {COMMAND_CLASS_MULTI_CHANNEL_V4,
308+
MULTI_CHANNEL_END_POINT_FIND_V4,
309+
0xFF,
310+
0xFF};
311+
TEST_ASSERT_EQUAL(sizeof(expected_frame_data), last_received_frame_length);
312+
TEST_ASSERT_EQUAL_INT8_ARRAY(expected_frame_data,
313+
last_received_frame,
314+
last_received_frame_length);
315+
}
231316
void test_zwave_command_class_multi_channel_aggregated_members_get_endpoint_0()
232317
{
233318
attribute_store_node_t test_node = 12345;

0 commit comments

Comments
 (0)