Z-Wave Protocol Controller Reference
user_credential_helpers Namespace Reference

Classes

struct  credential_id_nodes
 
struct  identifier_state
 

Typedefs

using attribute_callback = std::function< void(attribute_store::attribute &)>
 

Functions

template<typename T >
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. More...
 
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 (and clear reported) More...
 
void set_user_operation_type (attribute_store_node_t user_node, user_credential_operation_type_t operation_type)
 Set User Operation. More...
 
void set_credential_operation_type (attribute_store_node_t slot_node, user_credential_operation_type_t operation_type)
 Set Credential Operation. More...
 
void set_credential_learn_operation_type (attribute_store_node_t slot_node, user_credential_operation_type_t operation_type)
 Set Credential Learn Operation. More...
 
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) More...
 
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) More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
credential_id_nodes get_credential_identifier_nodes (attribute_store_node_t child_node)
 Get associated credential identifier nodes. More...
 
credential_id_nodes get_credential_identifier_nodes (const attribute_store::attribute &endpoint_node, identifier_state< user_credential_user_unique_id_t > user_id, identifier_state< user_credential_type_t > credential_type, identifier_state< user_credential_slot_t > credential_slot)
 Get associated credential identifier nodes. More...
 
bool is_admin_code_empty (const std::vector< uint8_t > &admin_pin_code)
 Return true if given admin pin code is considered empty. More...
 
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. More...
 

Typedef Documentation

◆ attribute_callback

using user_credential_helpers::attribute_callback = typedef std::function<void(attribute_store::attribute &)>

Function Documentation

◆ create_or_update_desired_value()

template<typename T >
attribute_store::attribute user_credential_helpers::create_or_update_desired_value ( attribute_store::attribute  base_node,
attribute_store_type_t  attribute_type,
value 
)

Update desired value if found, or create the node otherwise.

Check for the value in the desired value of attribute_type (with parent base_node). If we found it, we update the reported value and clear the desired value. Otherwise we create the node with the given value and set it to reported.

Template Parameters
TType of the value to set
Parameters
base_nodeBase node to search for the attribute
attribute_typeType of the attribute to search for
valueValue to search/set
Returns
attribute_store::attribute Node that was created/updated

◆ for_each_credential_type_nodes()

void user_credential_helpers::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.

Parameters
endpoint_nodeEndpoint point node
callbackCallback function to call for each credential type node
credential_typeCredential type to find. If 0, process all credential types

◆ for_each_credential_type_nodes_for_user()

void user_credential_helpers::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.

Parameters
user_id_nodeUser ID node
callbackCallback function to call for each credential type node
credential_typeCredential type to find. If 0, process all credential types

◆ get_credential_identifier_nodes() [1/2]

credential_id_nodes user_credential_helpers::get_credential_identifier_nodes ( attribute_store_node_t  child_node)

Get associated credential identifier nodes.

Parameters
child_nodeNot that have a CREDENTIAL_SLOT, CREDENTIAL_TYPE and USER_UNIQUE_ID as respective parents
Exceptions
std::runtime_errorIf one of the nodes is not found
Returns
credential_id_nodes Credential identifier nodes

◆ get_credential_identifier_nodes() [2/2]

credential_id_nodes user_credential_helpers::get_credential_identifier_nodes ( const attribute_store::attribute &  endpoint_node,
identifier_state< user_credential_user_unique_id_t user_id,
identifier_state< user_credential_type_t credential_type,
identifier_state< user_credential_slot_t credential_slot 
)

Get associated credential identifier nodes.

Parameters
endpoint_nodeEndpoint node
user_idUser ID with given state
credential_typeCredential type with given state
credential_slotCredential slot with given state
Exceptions
std::runtime_errorIf one of the nodes is not found
Returns
credential_id_nodes Credential identifier nodes

◆ get_credential_slot_node()

attribute_store::attribute user_credential_helpers::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.

Parameters
cred_type_nodeCredential type node
cred_slotCredential slot
stateCheck reported or desired value (or desired else reported)
Exceptions
std::runtime_errorIf Credential slot for given cred_type_node does not exist with given state
Returns
Credential slot node

◆ get_credential_type_node()

attribute_store::attribute user_credential_helpers::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.

Parameters
user_id_nodeUser ID node
cred_typeCredential type
stateCheck reported or desired value (or desired else reported)
Exceptions
std::runtime_errorIf Credential type for given user_id_node does not exist with given state
Returns
Credential type node

◆ get_user_unique_id_node()

attribute_store::attribute user_credential_helpers::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)

Parameters
endpoint_nodeCurrent endpoint node
user_idUser ID
stateCheck reported or desired value (or desired else reported)
Exceptions
std::runtime_errorIf User ID does not exist with given state
Returns
User ID Node

◆ is_admin_code_empty()

bool user_credential_helpers::is_admin_code_empty ( const std::vector< uint8_t > &  admin_pin_code)

Return true if given admin pin code is considered empty.

We need this function since the attribute store doesn't support empty vector.

Parameters
admin_pin_codeAdmin pin code
Returns
true Admin pin code is empty
false Admin pin code is not empty

◆ is_credential_available()

bool user_credential_helpers::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.

Parameters
endpoint_nodeEndpoint node
credential_typeCredential type
credential_slotCredential slot
Returns
true Credential is available
false Credential is not available : if an user already have the combination of given credential type and slot.

◆ set_credential_learn_operation_type()

void user_credential_helpers::set_credential_learn_operation_type ( attribute_store_node_t  slot_node,
user_credential_operation_type_t  operation_type 
)

Set Credential Learn Operation.

Set the operation type as desired and clear reported to call SET function

Parameters
slot_nodeSlot node
operation_typeOperation type to set

◆ set_credential_operation_type()

void user_credential_helpers::set_credential_operation_type ( attribute_store_node_t  slot_node,
user_credential_operation_type_t  operation_type 
)

Set Credential Operation.

Set the operation type as desired and clear reported to call SET function

Parameters
slot_nodeSlot node
operation_typeOperation type to set

◆ set_empty_admin_code()

void user_credential_helpers::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.

We need this function since the attribute store doesn't support empty vector.

Parameters
admin_pin_code_nodeAdmin pin code node
stateState (REPORTED or DESIRED)
Exceptions
std::runtime_errorIf admin_pin_code_node is not valid

◆ set_operation_type()

void user_credential_helpers::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 (and clear reported)

See also
set_user_operation_type
set_credential_operation_type
set_credential_learn_operation_type
Parameters
base_nodeBase node to search for the attribute
operation_type_node_typeType of the operation type node
operation_typeOperation type to set

◆ set_user_operation_type()

void user_credential_helpers::set_user_operation_type ( attribute_store_node_t  user_node,
user_credential_operation_type_t  operation_type 
)

Set User Operation.

Set the operation type as desired and clear reported to call SET function

Parameters
user_nodeUser node
operation_typeOperation type to set

◆ user_exists()

bool user_credential_helpers::user_exists ( attribute_store::attribute  endpoint_node,
user_credential_user_unique_id_t  user_id 
)

Get node associated with user ID (desired or reported)

Parameters
endpoint_nodeCurrent endpoint node
user_idUser ID
Returns
True is user exists, false otherwise