Skip to content

Commit

Permalink
GH-39: Prioritize command classes for interview
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nkljajic committed Apr 7, 2024
1 parent 3b43b68 commit 15ef046
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Expand Up @@ -155,6 +155,9 @@ static void
zwave_command_class_version_command_class_version_get);
attribute_resolver_set_attribute_depth(version_attribute[0], 0);

sl_log_debug(LOG_TAG, "Create CC 0x%02x version attribute for Endpoint ID %d\n",
command_class, endpoint_node);

// Add it into the attribute store.
attribute_store_add_if_missing(endpoint_node,
version_attribute,
Expand Down Expand Up @@ -214,6 +217,26 @@ static void zwave_command_class_version_create_cc_version_attributes(
uint8_t nif[ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH];
uint8_t nif_length = 0;

// First time we use COMMAND_CLASS_VERSION, query its own version supported.
add_command_class_version_attributes(COMMAND_CLASS_VERSION, endpoint_node);

// 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.
if (SL_STATUS_OK == attribute_store_read_value(endpoint_node,
REPORTED_ATTRIBUTE,
&endpoint_id,
sizeof(endpoint_id))
&& endpoint_id == 0) {

if(zwave_node_supports_command_class(COMMAND_CLASS_MANUFACTURER_SPECIFIC,
node_id,
endpoint_id)) {
add_command_class_version_attributes(COMMAND_CLASS_MANUFACTURER_SPECIFIC,
endpoint_node);
}
}

if ((non_secure_nif_node != ATTRIBUTE_STORE_INVALID_NODE)
&& (SL_STATUS_OK
== attribute_store_get_node_attribute_value(non_secure_nif_node,
Expand Down
Expand Up @@ -280,6 +280,13 @@ void test_on_nif_attribute_update()
NULL);
// Stop the stub, expect rule registrations for each Command Class.
attribute_resolver_register_rule_Stub(NULL);

attribute_resolver_register_rule_ExpectAndReturn(
ZWAVE_CC_VERSION_ATTRIBUTE(COMMAND_CLASS_VERSION),
NULL,
version_cc_get,
SL_STATUS_OK);

for (size_t i = 0; i < supported_cc_list_length; i++) {
if (supported_cc_list[i] >= COMMAND_CLASS_FIRST_APPLICATION_CC) {
attribute_resolver_register_rule_ExpectAndReturn(
Expand Down Expand Up @@ -328,6 +335,13 @@ void test_on_nif_attribute_update()
&supported_secure_cc_list_length,
NULL,
NULL);

attribute_resolver_register_rule_ExpectAndReturn(
ZWAVE_CC_VERSION_ATTRIBUTE(COMMAND_CLASS_VERSION),
NULL,
version_cc_get,
SL_STATUS_OK);

for (size_t i = 0; i < supported_cc_list_length; i++) {
if (supported_cc_list[i] >= COMMAND_CLASS_FIRST_APPLICATION_CC) {
attribute_resolver_register_rule_ExpectAndReturn(
Expand Down

0 comments on commit 15ef046

Please sign in to comment.