Z-Wave Protocol Controller Reference
zwave_command_class_user_code.c File Reference
#include "zwave_command_class_user_code.h"
#include "zwave_command_classes_utils.h"
#include "ZW_classcmd.h"
#include "attribute_store_defined_attribute_types.h"
#include "zwave_command_class_indices.h"
#include "zwave_command_handler.h"
#include "zwave_controller_connection_info.h"
#include "zwave_controller_utils.h"
#include "zpc_attribute_store_network_helper.h"
#include "zpc_attribute_resolver.h"
#include "attribute_store.h"
#include "attribute_store_helper.h"
#include "attribute_resolver.h"
#include <string.h>
#include "sl_log.h"
Include dependency graph for zwave_command_class_user_code.c:

Macros

#define LOG_TAG   "zwave_command_class_user_code"
 
#define ATTRIBUTE(type)   ATTRIBUTE_COMMAND_CLASS_USER_CODE_##type
 
#define KEY_BITMASK_SIZE   16
 

Functions

static attribute_store_node_t get_user_code_data_node (const zwave_controller_connection_info_t *info)
 
static attribute_store_node_t get_user_code_capabilities_node (attribute_store_node_t endpoint_node)
 
static attribute_store_node_t get_user_id_node (attribute_store_node_t data_node, uint16_t user_id)
 
static void set_user_code_to_available (attribute_store_node_t user_id_node)
 Checks if the user_id_node type is correct and sets the user code data to Available underneath. More...
 
static void set_user_code_range_to_available (attribute_store_node_t data_node, uint16_t first_id, uint16_t last_id)
 Sets all users Id in the Range [first_id..last_id[ to available (user code not set) More...
 
static void set_all_user_codes_to_available (attribute_store_node_t node)
 Navigates up the tree from a node and makes sure that all user codes are set to "disabled" with no pin code. More...
 
static void undefine_user_code (attribute_store_node_t user_id_node)
 Checks if the User ID node matches what we expect and undefines the User Code data underneath. More...
 
static void undefine_all_user_codes (attribute_store_node_t endpoint_node)
 Navigates under the endpoint node and undefines all the known user code data. More...
 
static void set_default_v1_capabilities (attribute_store_node_t node)
 Sets all the default capabilities for version 1 supporting nodes. More...
 
static bool is_pin_code_supported (attribute_store_node_t endpoint_node, const char *pin_code)
 Checks the nodes capabilities and verifies if a character is supported for setting in a PIN code. More...
 
static bool is_mucr_supported (attribute_store_node_t endpoint_node)
 Checks the nodes capabilities and verifies if it supports MUCR (Multiple User Code Reports) More...
 
static sl_status_t zwave_command_class_user_code_number_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a Users Number Get Command. More...
 
static sl_status_t zwave_command_class_user_code_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a (opt. Extended) User Code Get Command. More...
 
static sl_status_t zwave_command_class_user_code_capabilities_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a (opt. Extended) User Code Get Command. More...
 
static sl_status_t zwave_command_class_user_code_checksum_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a User Code Checksum Get Command. More...
 
static sl_status_t zwave_command_class_user_code_admin_code_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates an Admin Code Get Command. More...
 
static sl_status_t zwave_command_class_user_code_keypad_mode_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a Keypad Mode Get Command. More...
 
static sl_status_t zwave_command_class_user_code_keypad_mode_set (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a Keypad Mode Set Command. More...
 
static sl_status_t zwave_command_class_user_code_set (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a (opt. Extended) User Code Set Command. More...
 
static sl_status_t zwave_command_class_user_code_admin_code_set (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a Admin Code Set Command. More...
 
static sl_status_t zwave_command_class_user_code_delete_all (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a User Code Set or Extended User Code Set that will delete all User Codes. More...
 
static void zwave_command_class_user_code_on_version_attribute_update (attribute_store_node_t updated_node, attribute_store_change_t change)
 
static void zwave_command_class_user_code_on_number_of_users_update (attribute_store_node_t updated_node, attribute_store_change_t change)
 
static void zwave_command_class_user_code_on_user_id_created (attribute_store_node_t node, attribute_store_change_t change)
 
static void zwave_command_class_user_code_on_capabilities_created (attribute_store_node_t node, attribute_store_change_t change)
 
static void on_delete_all_send_data_complete (attribute_store_node_t node, resolver_rule_type_t rule_type, zpc_resolver_event_t event)
 Handles the Send Data Complete for a "delete all user codes". More...
 
static sl_status_t handle_users_number_report (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming User Number Report Command. More...
 
static sl_status_t handle_users_code_checksum_report (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming User Code Checksum Report Command. More...
 
static sl_status_t handle_user_code_report (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming User Code Report Command. More...
 
static sl_status_t handle_admin_code_report (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming Admin Code Report Command. More...
 
static sl_status_t handle_extended_user_code_report (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming Extended User Code Report Command. More...
 
static sl_status_t handle_user_code_capabilities_report (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming User Code Capabilities Report Command. More...
 
static sl_status_t handle_keypad_mode_report (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming Keypad Mode Report Command. More...
 
static sl_status_t zwave_command_class_user_code_control_handler (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Dispatches incoming User Code Commands to individual command handlers. More...
 
sl_status_t zwave_command_class_user_code_init ()
 Initializes the User Code Command Class handler. More...
 

Variables

static const attribute_store_type_t default_attributes []
 
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 []
 
static const uint8_t V1_SUPPORTED_KEYS [KEY_BITMASK_SIZE]
 

Macro Definition Documentation

◆ ATTRIBUTE

#define ATTRIBUTE (   type)    ATTRIBUTE_COMMAND_CLASS_USER_CODE_##type

◆ KEY_BITMASK_SIZE

#define KEY_BITMASK_SIZE   16

◆ LOG_TAG

#define LOG_TAG   "zwave_command_class_user_code"

Function Documentation

◆ get_user_code_capabilities_node()

static attribute_store_node_t get_user_code_capabilities_node ( attribute_store_node_t  endpoint_node)
static
Here is the caller graph for this function:

◆ get_user_code_data_node()

static attribute_store_node_t get_user_code_data_node ( const zwave_controller_connection_info_t info)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_user_id_node()

static attribute_store_node_t get_user_id_node ( attribute_store_node_t  data_node,
uint16_t  user_id 
)
static
Here is the caller graph for this function:

◆ handle_admin_code_report()

static sl_status_t handle_admin_code_report ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Process an incoming Admin Code Report Command.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_extended_user_code_report()

static sl_status_t handle_extended_user_code_report ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Process an incoming Extended User Code Report Command.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_keypad_mode_report()

static sl_status_t handle_keypad_mode_report ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Process an incoming Keypad Mode Report Command.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_user_code_capabilities_report()

static sl_status_t handle_user_code_capabilities_report ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Process an incoming User Code Capabilities Report Command.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_user_code_report()

static sl_status_t handle_user_code_report ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Process an incoming User Code Report Command.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_users_code_checksum_report()

static sl_status_t handle_users_code_checksum_report ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Process an incoming User Code Checksum Report Command.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_users_number_report()

static sl_status_t handle_users_number_report ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Process an incoming User Number Report Command.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_mucr_supported()

static bool is_mucr_supported ( attribute_store_node_t  endpoint_node)
static

Checks the nodes capabilities and verifies if it supports MUCR (Multiple User Code Reports)

Parameters
endpoint_nodeAttribute Store node for the Endpoint
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_pin_code_supported()

static bool is_pin_code_supported ( attribute_store_node_t  endpoint_node,
const char *  pin_code 
)
static

Checks the nodes capabilities and verifies if a character is supported for setting in a PIN code.

NOTE: This function assumes to receive a NULL terminated PIN Code.

Parameters
endpoint_nodeAttribute Store node for the Endpoint
pin_codePIN Code to check all chars
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_delete_all_send_data_complete()

static void on_delete_all_send_data_complete ( attribute_store_node_t  node,
resolver_rule_type_t  rule_type,
zpc_resolver_event_t  event 
)
static

Handles the Send Data Complete for a "delete all user codes".

The resolver alone does not support this case, because the attribute being resolved and the attributes affected are located in different places.

This function manually traverses the tree and adjust the value of User ID statuses / User Codes based on the outcome of the Delete All Command

Parameters
nodeAttribute Store node that was resolved
rule_typeType of rule that was applied to the node
eventResolution outcome/event
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_all_user_codes_to_available()

static void set_all_user_codes_to_available ( attribute_store_node_t  node)
static

Navigates up the tree from a node and makes sure that all user codes are set to "disabled" with no pin code.

Parameters
nodeAttribute Store node located under the ATTRIBUTE(DATA)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_default_v1_capabilities()

static void set_default_v1_capabilities ( attribute_store_node_t  node)
static

Sets all the default capabilities for version 1 supporting nodes.

Parameters
nodeAttribute Store ATTRIBUTE(CAPABILITIES) node
Here is the caller graph for this function:

◆ set_user_code_range_to_available()

static void set_user_code_range_to_available ( attribute_store_node_t  data_node,
uint16_t  first_id,
uint16_t  last_id 
)
static

Sets all users Id in the Range [first_id..last_id[ to available (user code not set)

Parameters
user_id_nodeAttribute Store node for the User ID.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_user_code_to_available()

static void set_user_code_to_available ( attribute_store_node_t  user_id_node)
static

Checks if the user_id_node type is correct and sets the user code data to Available underneath.

Parameters
user_id_nodeAttribute Store node for the User ID.
Here is the caller graph for this function:

◆ undefine_all_user_codes()

static void undefine_all_user_codes ( attribute_store_node_t  endpoint_node)
static

Navigates under the endpoint node and undefines all the known user code data.

Parameters
nodeAttribute Store node for the Endpoint.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ undefine_user_code()

static void undefine_user_code ( attribute_store_node_t  user_id_node)
static

Checks if the User ID node matches what we expect and undefines the User Code data underneath.

Parameters
user_id_nodeAttribute Store node for the User ID.
Here is the caller graph for this function:

◆ zwave_command_class_user_code_admin_code_get()

static sl_status_t zwave_command_class_user_code_admin_code_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates an Admin Code Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_user_code_admin_code_set()

static sl_status_t zwave_command_class_user_code_admin_code_set ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a Admin Code Set Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_user_code_capabilities_get()

static sl_status_t zwave_command_class_user_code_capabilities_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a (opt. Extended) User Code Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_user_code_checksum_get()

static sl_status_t zwave_command_class_user_code_checksum_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a User Code Checksum Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_user_code_control_handler()

static sl_status_t zwave_command_class_user_code_control_handler ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Dispatches incoming User Code Commands to individual command handlers.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_user_code_delete_all()

static sl_status_t zwave_command_class_user_code_delete_all ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a User Code Set or Extended User Code Set that will delete all User Codes.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_user_code_get()

static sl_status_t zwave_command_class_user_code_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a (opt. Extended) User Code Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_user_code_keypad_mode_get()

static sl_status_t zwave_command_class_user_code_keypad_mode_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a Keypad Mode Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_user_code_keypad_mode_set()

static sl_status_t zwave_command_class_user_code_keypad_mode_set ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a Keypad Mode Set Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_user_code_number_get()

static sl_status_t zwave_command_class_user_code_number_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a Users Number Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_user_code_on_capabilities_created()

static void zwave_command_class_user_code_on_capabilities_created ( attribute_store_node_t  node,
attribute_store_change_t  change 
)
static
Here is the caller graph for this function:

◆ zwave_command_class_user_code_on_number_of_users_update()

static void zwave_command_class_user_code_on_number_of_users_update ( attribute_store_node_t  updated_node,
attribute_store_change_t  change 
)
static
Here is the caller graph for this function:

◆ zwave_command_class_user_code_on_user_id_created()

static void zwave_command_class_user_code_on_user_id_created ( attribute_store_node_t  node,
attribute_store_change_t  change 
)
static
Here is the caller graph for this function:

◆ zwave_command_class_user_code_on_version_attribute_update()

static void zwave_command_class_user_code_on_version_attribute_update ( attribute_store_node_t  updated_node,
attribute_store_change_t  change 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_user_code_set()

static sl_status_t zwave_command_class_user_code_set ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a (opt. Extended) User Code Set Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ capabilities_attributes

const attribute_store_type_t capabilities_attributes[]
static
Initial value:
= {ATTRIBUTE(SUPPORTED_FLAGS),
ATTRIBUTE(SUPPORTED_USER_ID_STATUS),
ATTRIBUTE(SUPPORTED_KEYPAD_MODES),
ATTRIBUTE(SUPPORTED_KEYS)}
#define ATTRIBUTE(type)
Definition: zwave_command_class_user_code.c:40

◆ default_attributes

const attribute_store_type_t default_attributes[]
static
Initial value:
= {ATTRIBUTE(DELETE_ALL_REQUESTED),
ATTRIBUTE(NUMBER_OF_USERS),
ATTRIBUTE(CAPABILITIES)}

◆ user_id_attributes

const attribute_store_type_t user_id_attributes[] = {ATTRIBUTE(CODE), ATTRIBUTE(USER_ID_STATUS)}
static

◆ V1_SUPPORTED_KEYS

const uint8_t V1_SUPPORTED_KEYS[KEY_BITMASK_SIZE]
static
Initial value:
= {0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0xFF,
0x03,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00}

◆ v2_attributes

const attribute_store_type_t v2_attributes[] = {ATTRIBUTE(KEYPAD_MODE)}
static