Skip to content

Commit c5cf19c

Browse files
nkljajicrzr
authored andcommitted
GH-39: Prioritize command classes for interview
First time we use COMMAND_CLASS_VERSION, query its own version supported. Prioritize COMMAND_CLASS_MANUFACTURER_SPECIFIC before others. UAM rules can match unique device model, so we could override supported command class version attributes for matching device model. Signed-off-by: Nenad Kljajic <nkljajic@control4.com>
1 parent 1daacdf commit c5cf19c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ static void
155155
zwave_command_class_version_command_class_version_get);
156156
attribute_resolver_set_attribute_depth(version_attribute[0], 0);
157157

158+
sl_log_debug(LOG_TAG, "Create CC 0x%02x version attribute for Endpoint ID %d\n",
159+
command_class, endpoint_node);
160+
158161
// Add it into the attribute store.
159162
attribute_store_add_if_missing(endpoint_node,
160163
version_attribute,
@@ -214,6 +217,26 @@ static void zwave_command_class_version_create_cc_version_attributes(
214217
uint8_t nif[ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH];
215218
uint8_t nif_length = 0;
216219

220+
// First time we use COMMAND_CLASS_VERSION, query its own version supported.
221+
add_command_class_version_attributes(COMMAND_CLASS_VERSION, endpoint_node);
222+
223+
// Prioritize COMMAND_CLASS_MANUFACTURER_SPECIFIC before others
224+
// UAM rules can match unique device model, so we could override
225+
// supported command class version attributes for matching device model.
226+
if (SL_STATUS_OK == attribute_store_read_value(endpoint_node,
227+
REPORTED_ATTRIBUTE,
228+
&endpoint_id,
229+
sizeof(endpoint_id))
230+
&& endpoint_id == 0) {
231+
232+
if(zwave_node_supports_command_class(COMMAND_CLASS_MANUFACTURER_SPECIFIC,
233+
node_id,
234+
endpoint_id)) {
235+
add_command_class_version_attributes(COMMAND_CLASS_MANUFACTURER_SPECIFIC,
236+
endpoint_node);
237+
}
238+
}
239+
217240
if ((non_secure_nif_node != ATTRIBUTE_STORE_INVALID_NODE)
218241
&& (SL_STATUS_OK
219242
== attribute_store_get_node_attribute_value(non_secure_nif_node,

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,13 @@ void test_on_nif_attribute_update()
280280
NULL);
281281
// Stop the stub, expect rule registrations for each Command Class.
282282
attribute_resolver_register_rule_Stub(NULL);
283+
284+
attribute_resolver_register_rule_ExpectAndReturn(
285+
ZWAVE_CC_VERSION_ATTRIBUTE(COMMAND_CLASS_VERSION),
286+
NULL,
287+
version_cc_get,
288+
SL_STATUS_OK);
289+
283290
for (size_t i = 0; i < supported_cc_list_length; i++) {
284291
if (supported_cc_list[i] >= COMMAND_CLASS_FIRST_APPLICATION_CC) {
285292
attribute_resolver_register_rule_ExpectAndReturn(
@@ -328,6 +335,13 @@ void test_on_nif_attribute_update()
328335
&supported_secure_cc_list_length,
329336
NULL,
330337
NULL);
338+
339+
attribute_resolver_register_rule_ExpectAndReturn(
340+
ZWAVE_CC_VERSION_ATTRIBUTE(COMMAND_CLASS_VERSION),
341+
NULL,
342+
version_cc_get,
343+
SL_STATUS_OK);
344+
331345
for (size_t i = 0; i < supported_cc_list_length; i++) {
332346
if (supported_cc_list[i] >= COMMAND_CLASS_FIRST_APPLICATION_CC) {
333347
attribute_resolver_register_rule_ExpectAndReturn(

0 commit comments

Comments
 (0)