From 8b8a32f9b731ca3fd871358efafd7725c16ed53e Mon Sep 17 00:00:00 2001 From: thdubois Date: Mon, 22 Jan 2024 15:00:31 +0100 Subject: [PATCH] GH-23: Stop setting undefine reported on UserID attributes creation. Previously we were using ADD_IF_MISSING which creates a GET/REPORT sequence for each UserID. This was slowing down the interview process. User Code and User Id Status are now set to default value, which can be updated using GetAllPinCodes command. Bug-SiliconLabs: UIC-3062 Signed-off-by: Thomas du Boisrouvray Forwarded-SiliconLabs: thdubois/UIC-3072/c4/develop (cherry picked from commit ad72e34eb291502c60940a59e5db7d52cd744e41) --- .../src/zwave_command_class_user_code.c | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/applications/zpc/components/zwave_command_classes/src/zwave_command_class_user_code.c b/applications/zpc/components/zwave_command_classes/src/zwave_command_class_user_code.c index f31f24110..82147c8d5 100644 --- a/applications/zpc/components/zwave_command_classes/src/zwave_command_class_user_code.c +++ b/applications/zpc/components/zwave_command_classes/src/zwave_command_class_user_code.c @@ -48,8 +48,6 @@ static const attribute_store_type_t default_attributes[] ATTRIBUTE(CAPABILITIES)}; static const attribute_store_type_t v2_attributes[] = {ATTRIBUTE(KEYPAD_MODE)}; -static const attribute_store_type_t user_id_attributes[] - = {ATTRIBUTE(CODE), ATTRIBUTE(USER_ID_STATUS)}; static const attribute_store_type_t capabilities_attributes[] = {ATTRIBUTE(SUPPORTED_FLAGS), @@ -583,7 +581,7 @@ static sl_status_t zwave_command_class_user_code_keypad_mode_get( } if (supporting_node_version == 1) { - sl_log_warning(LOG_TAG, "Admin Code attribute found for v1 node. Deleting"); + sl_log_warning(LOG_TAG, "Keypad Mode attribute found for v1 node. Deleting"); attribute_store_delete_node(node); *frame_length = 0; return SL_STATUS_ALREADY_EXISTS; @@ -626,7 +624,7 @@ static sl_status_t zwave_command_class_user_code_keypad_mode_set( } if (supporting_node_version == 1) { - sl_log_warning(LOG_TAG, "Admin Code attribute found for v1 node. Deleting"); + sl_log_warning(LOG_TAG, "Keypad mode attribute found for v1 node. Deleting"); attribute_store_delete_node(node); *frame_length = 0; return SL_STATUS_ALREADY_EXISTS; @@ -952,18 +950,6 @@ static void zwave_command_class_user_code_on_number_of_users_update( attribute_store_node_t endpoint_node = attribute_store_get_first_parent_with_type(updated_node, ATTRIBUTE_ENDPOINT_ID); - attribute_store_node_t version_node - = attribute_store_get_first_child_by_type(endpoint_node, - ATTRIBUTE(VERSION)); - // We need to check the version of the supporting node: - zwave_cc_version_t supporting_node_version = 0; - attribute_store_get_reported(version_node, - &supporting_node_version, - sizeof(supporting_node_version)); - if (supporting_node_version == 1) { - sl_log_debug(LOG_TAG, "Skip creating User ID nodes for CC UserCode V1."); - return; - } attribute_store_node_t data_node = attribute_store_get_first_child_by_type(endpoint_node, ATTRIBUTE(DATA)); @@ -976,12 +962,13 @@ static void zwave_command_class_user_code_on_number_of_users_update( static void zwave_command_class_user_code_on_user_id_created( attribute_store_node_t node, attribute_store_change_t change) { + const uint8_t user_id_status = 0; + const char empty_string = '\0'; if (change != ATTRIBUTE_CREATED) { return; } - attribute_store_add_if_missing(node, - user_id_attributes, - COUNT_OF(user_id_attributes)); + attribute_store_emplace(node, ATTRIBUTE(CODE), &empty_string, sizeof(empty_string)); + attribute_store_emplace(node, ATTRIBUTE(USER_ID_STATUS), &user_id_status, sizeof(user_id_status)); } static void zwave_command_class_user_code_on_capabilities_created( @@ -1564,7 +1551,6 @@ sl_status_t zwave_command_class_user_code_init() attribute_store_register_callback_by_type( &zwave_command_class_user_code_on_capabilities_created, ATTRIBUTE(CAPABILITIES)); - // Attribute resolver rules attribute_resolver_register_rule(ATTRIBUTE(NUMBER_OF_USERS), NULL,