Z-Wave Protocol Controller Reference
user_credential_helpers.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
14#ifndef USER_CREDENTIAL_HELPERS_H
15#define USER_CREDENTIAL_HELPERS_H
16
17// Get attribute store names
19// User credential types
21
22// Unify Cpp
23#include "attribute.hpp"
25
27{
28
29using attribute_callback = std::function<void(attribute_store::attribute &)>;
30
32// Data struct
34
35// Represent a credential ID (slot, type, user unique ID)
37 attribute_store::attribute slot_node;
38 attribute_store::attribute type_node;
39 attribute_store::attribute user_unique_id_node;
40};
41
57template<typename T> attribute_store::attribute
58 create_or_update_desired_value(attribute_store::attribute base_node,
59 attribute_store_type_t attribute_type,
60 T value)
61{
62 auto node = base_node.child_by_type_and_value(attribute_type,
63 value,
64 DESIRED_ATTRIBUTE);
65 if (!node.is_valid()) {
66 node = base_node.emplace_node(attribute_type, value);
67 } else {
68 node.set_reported(value);
69 node.clear_desired();
70 }
71
72 return node;
73}
74
87void set_operation_type(attribute_store::attribute base_node,
88 attribute_store_type_t operation_type_node_type,
99void set_user_operation_type(attribute_store_node_t user_node,
100 user_credential_operation_type_t operation_type);
101
112 attribute_store_node_t slot_node,
113 user_credential_operation_type_t operation_type);
114
124 attribute_store_node_t slot_node,
125 user_credential_operation_type_t operation_type);
126
135bool user_exists(attribute_store::attribute endpoint_node,
137
149attribute_store::attribute
150 get_user_unique_id_node(attribute_store::attribute endpoint_node,
152 attribute_store_node_value_state_t state);
153
165attribute_store::attribute
166 get_credential_type_node(attribute_store::attribute user_id_node,
167 user_credential_type_t cred_type,
168 attribute_store_node_value_state_t state);
169
181attribute_store::attribute
182 get_credential_slot_node(attribute_store::attribute cred_type_node,
183 user_credential_slot_t cred_slot,
184 attribute_store_node_value_state_t state);
193 attribute_store::attribute user_id_node,
195 user_credential_type_t credential_type = 0);
196
204void for_each_credential_type_nodes(attribute_store::attribute endpoint_node,
206 user_credential_type_t credential_type = 0);
217bool is_credential_available(attribute_store_node_t endpoint_node,
218 user_credential_type_t credential_type,
219 user_credential_slot_t credential_slot);
220
231 get_credential_identifier_nodes(attribute_store_node_t child_node);
232
233template<typename T> struct identifier_state {
235 attribute_store_node_value_state_t state;
236};
250 const attribute_store::attribute &endpoint_node,
254
265bool is_admin_code_empty(const std::vector<uint8_t>& admin_pin_code);
276void set_empty_admin_code(attribute_store::attribute &admin_pin_code_node,
277 attribute_store_node_value_state_t state);
278
279} // namespace user_credential_helpers
280
281#endif // USER_CREDENTIAL_HELPERS_H
uint16_t user_credential_user_unique_id_t
‍User Unique ID. uint16_t
Definition: zwave_command_class_user_credential_types.h:37
uint16_t user_credential_slot_t
‍Credential slot. uint16_t
Definition: zwave_command_class_user_credential_types.h:67
uint8_t user_credential_type_t
‍Credential type. uint8_t
Definition: zwave_command_class_user_credential_types.h:61
uint8_t user_credential_operation_type_t
Definition: zwave_command_class_user_credential_types.h:73
Definition: user_credential_helpers.hpp:27
bool is_admin_code_empty(const std::vector< uint8_t > &admin_pin_code)
Return true if given admin pin code is considered empty.
std::function< void(attribute_store::attribute &)> attribute_callback
Definition: user_credential_helpers.hpp:29
void set_operation_type(attribute_store::attribute base_node, attribute_store_type_t operation_type_node_type, user_credential_operation_type_t operation_type)
Create operation_type_node_type if it doesn't exists, and set the desired value to operation_type (an...
bool user_exists(attribute_store::attribute endpoint_node, user_credential_user_unique_id_t user_id)
Get node associated with user ID (desired or reported)
void for_each_credential_type_nodes_for_user(attribute_store::attribute user_id_node, const attribute_callback &callback, user_credential_type_t credential_type=0)
Iterate on each credential type nodes for a given user.
void set_empty_admin_code(attribute_store::attribute &admin_pin_code_node, attribute_store_node_value_state_t state)
Set the admin pin code node to an empty value.
void set_credential_operation_type(attribute_store_node_t slot_node, user_credential_operation_type_t operation_type)
Set Credential Operation.
credential_id_nodes get_credential_identifier_nodes(attribute_store_node_t child_node)
Get associated credential identifier nodes.
void set_credential_learn_operation_type(attribute_store_node_t slot_node, user_credential_operation_type_t operation_type)
Set Credential Learn Operation.
attribute_store::attribute get_user_unique_id_node(attribute_store::attribute endpoint_node, user_credential_user_unique_id_t user_id, attribute_store_node_value_state_t state)
Get node associated with user ID (desired or reported)
void for_each_credential_type_nodes(attribute_store::attribute endpoint_node, const attribute_callback &callback, user_credential_type_t credential_type=0)
Iterate on each credential type nodes.
void set_user_operation_type(attribute_store_node_t user_node, user_credential_operation_type_t operation_type)
Set User Operation.
bool is_credential_available(attribute_store_node_t endpoint_node, user_credential_type_t credential_type, user_credential_slot_t credential_slot)
Checks if given credential ID (credential type, credential slot) is available.
attribute_store::attribute get_credential_slot_node(attribute_store::attribute cred_type_node, user_credential_slot_t cred_slot, attribute_store_node_value_state_t state)
Get credential slot node associated with credential type.
attribute_store::attribute get_credential_type_node(attribute_store::attribute user_id_node, user_credential_type_t cred_type, attribute_store_node_value_state_t state)
Get credential type node associated with user ID.
attribute_store::attribute create_or_update_desired_value(attribute_store::attribute base_node, attribute_store_type_t attribute_type, T value)
Update desired value if found, or create the node otherwise.
Definition: user_credential_helpers.hpp:58
Definition: user_credential_helpers.hpp:36
attribute_store::attribute type_node
Definition: user_credential_helpers.hpp:38
attribute_store::attribute slot_node
Definition: user_credential_helpers.hpp:37
attribute_store::attribute user_unique_id_node
Definition: user_credential_helpers.hpp:39
Definition: user_credential_helpers.hpp:233
T value
Definition: user_credential_helpers.hpp:234
attribute_store_node_value_state_t state
Definition: user_credential_helpers.hpp:235
static send_data_state_t state
Definition: zwave_crc16_transport.c:52
static void callback(uint8_t status, const zwapi_tx_report_t *tx_info, void *user)
Z-Wave Tx Send data callback function.
Definition: zwave_s0_transport.c:601