Zigbee Protocol Controller 1.6.0
|
Helper functions to perform actions on the attribute store. More...
Functions | |
bool | attribute_store_is_value_defined (attribute_store_node_t node, attribute_store_node_value_state_t value_state) |
Indicate whether a value is defined in the attribute store. More... | |
bool | attribute_store_is_reported_defined (attribute_store_node_t node) |
Indicate whether the reported value of a node is defined in the attribute store. More... | |
bool | attribute_store_is_desired_defined (attribute_store_node_t node) |
Indicate whether the desired value of a node is defined in the attribute store. More... | |
bool | attribute_store_is_value_matched (attribute_store_node_t node) |
Indicate whether reported and desired values are matched in the attribute store. More... | |
sl_status_t | attribute_store_set_desired_as_reported (attribute_store_node_t node) |
Set the Desired value to the same as the Reported value. More... | |
sl_status_t | attribute_store_set_reported_as_desired (attribute_store_node_t node) |
Set the Reported value to the same as the Desired value. More... | |
void | attribute_store_undefine_reported (attribute_store_node_t node) |
Set the Reported value to "undefined" (0 size no value) More... | |
sl_status_t | attribute_store_set_reported (attribute_store_node_t node, const void *value, uint8_t value_size) |
Set the Reported value of an Attribute Store node. More... | |
sl_status_t | attribute_store_get_reported (attribute_store_node_t node, void *value, size_t expected_size) |
Reads the reported value of an attribute store node. More... | |
sl_status_t | attribute_store_set_reported_number (attribute_store_node_t node, number_t value) |
Sets a numerical value for an Attribute Store node. More... | |
sl_status_t | attribute_store_set_desired_number (attribute_store_node_t node, number_t value) |
Sets a numerical value for an Attribute Store node. More... | |
number_t | attribute_store_get_reported_number (attribute_store_node_t node) |
Gets a numerical value from an Attribute Store node. More... | |
number_t | attribute_store_get_desired_number (attribute_store_node_t node) |
Gets a numerical value from an Attribute Store node. More... | |
sl_status_t | attribute_store_set_reported_string (attribute_store_node_t node, const char *string) |
Safely copies a String in the Attribute Store. More... | |
sl_status_t | attribute_store_set_desired_string (attribute_store_node_t node, const char *string) |
Safely copies a String in the Attribute Store. More... | |
sl_status_t | attribute_store_get_reported_string (attribute_store_node_t node, char *string, size_t maximum_size) |
Safely retrieves a String from the Attribute Store. More... | |
sl_status_t | attribute_store_get_desired_string (attribute_store_node_t node, char *string, size_t maximum_size) |
Safely retrieves a String from the Attribute Store. More... | |
sl_status_t | attribute_store_get_desired_else_reported_string (attribute_store_node_t node, char *string, size_t maximum_size) |
Safely retrieves a String from the Attribute Store. More... | |
sl_status_t | attribute_store_concatenate_to_reported_string (attribute_store_node_t node, const char *string) |
Safely concatenate a string to a String attribute in the Attribute Store. More... | |
sl_status_t | attribute_store_append_to_reported (attribute_store_node_t node, const uint8_t *array, uint8_t extra_array_length) |
Safely append a new byte array to a byte array attribute in the Attribute Store. More... | |
void | attribute_store_undefine_desired (attribute_store_node_t node) |
Set the Desired value to "undefined" (0 size no value) More... | |
sl_status_t | attribute_store_set_desired (attribute_store_node_t node, const void *value, uint8_t value_size) |
Set the Desired value of an Attribute Store node. More... | |
sl_status_t | attribute_store_get_desired (attribute_store_node_t node, void *value, size_t expected_size) |
Reads the desired value of an attribute store node. More... | |
sl_status_t | attribute_store_get_desired_else_reported (attribute_store_node_t node, void *value, size_t expected_size) |
Reads the desired value of an attribute store node, or the reported if desired is undefined. More... | |
sl_status_t | attribute_store_copy_value (attribute_store_node_t source_node, attribute_store_node_t destination_node, attribute_store_node_value_state_t value_state) |
Copy the value from a node to another. More... | |
sl_status_t | attribute_store_read_value (attribute_store_node_t node, attribute_store_node_value_state_t value_state, void *read_value, size_t expected_size) |
Read an arbitrary sized value from the attribute store and writes it to a pointer. More... | |
sl_status_t | attribute_store_set_child_reported (attribute_store_node_t parent, attribute_store_type_t type, const void *value, uint8_t value_size) |
Adds if missing and sets the value of the first child of a node with a given type. and writes its reported value. More... | |
sl_status_t | attribute_store_set_all_children_reported (attribute_store_node_t parent, attribute_store_type_t type, const void *value, uint8_t value_size) |
Sets the value of the all children of a node with a given type. and writes their reported value. More... | |
sl_status_t | attribute_store_set_child_desired (attribute_store_node_t parent, attribute_store_type_t type, const void *value, uint8_t value_size) |
Adds if missing and sets the value of the first child of a node with a given type. and writes its desired value. More... | |
sl_status_t | attribute_store_get_child_reported (attribute_store_node_t parent, attribute_store_type_t type, void *value, size_t expected_size) |
Finds the reported value of the first child of a node with a given type. More... | |
sl_status_t | attribute_store_set_child_reported_only_if_missing (attribute_store_node_t parent, attribute_store_type_t type, const void *value, uint8_t value_size) |
Adds and sets the reported value of the first child of a node with a given type only if it did not exist. More... | |
sl_status_t | attribute_store_set_child_reported_only_if_exists (attribute_store_node_t parent, attribute_store_type_t type, const void *value, uint8_t value_size) |
Sets the value of the child node, only if the child node already exists in the Attribute Store. More... | |
sl_status_t | attribute_store_set_child_reported_only_if_undefined (attribute_store_node_t parent, attribute_store_type_t type, const void *value, uint8_t value_size) |
Finds the first child of a node and and sets the reported value only if it undefined. More... | |
sl_status_t | attribute_store_set_child_desired_only_if_exists (attribute_store_node_t parent, attribute_store_type_t type, const void *value, uint8_t value_size) |
Sets the value of the child node, only if the child node already exists in the Attribute Store. More... | |
void | attribute_store_walk_tree (attribute_store_node_t top, void(*function)(attribute_store_node_t)) |
Visit all nodes in the tree. More... | |
void | attribute_store_walk_tree_with_return_value (attribute_store_node_t top, sl_status_t(*function)(attribute_store_node_t)) |
Visit all nodes in the tree, applying a function. More... | |
void | attribute_store_add_if_missing (attribute_store_node_t parent_node, const attribute_store_type_t attributes[], uint32_t count) |
Add multiple nodes to a parent if they are not already present. More... | |
attribute_store_node_t | attribute_store_emplace (attribute_store_node_t parent_node, attribute_store_type_t type, const void *value, uint8_t value_size) |
Adds a child with a given reported value under a parent node, if it does not already exist. More... | |
attribute_store_node_t | attribute_store_emplace_desired (attribute_store_node_t parent_node, attribute_store_type_t type, const void *value, uint8_t value_size) |
Adds a child with a given desired value under a parent node, if it does not already exist. More... | |
sl_status_t | attribute_store_register_callback_by_type_to_array (attribute_store_node_changed_callback_t callback_function, const attribute_store_type_t types[], uint32_t types_count) |
Loop helper that register the same callback function for many attribute types. More... | |
sl_status_t | attribute_store_delete_all_children (attribute_store_node_t node) |
Removes all children of an attribute store node. More... | |
attribute_store_node_t | attribute_store_create_child_if_missing (attribute_store_node_t node, attribute_store_type_t type) |
Finds and returns the first child with a type under a node, creates it if missing. More... | |
number_t | attribute_store_get_number (attribute_store_node_t node, attribute_store_node_value_state_t value_state) |
Helper function that sets the Reported or Desired value of a number. More... | |
sl_status_t | attribute_store_set_number (attribute_store_node_t node, number_t value, attribute_store_node_value_state_t value_state) |
Helper function that sets the Reported or Desired value of a number. More... | |
uint8_t | attribute_store_get_reported_size (attribute_store_node_t node) |
Returns the size of the reported value of a node. More... | |
uint8_t | attribute_store_get_desired_size (attribute_store_node_t node) |
Returns the size of the desired value of a node. More... | |
uint8_t | attribute_store_get_desired_else_reported_size (attribute_store_node_t node) |
Returns the size of the desired value of a node, and if 0, returns the size of the reported value instead. More... | |
Helper functions to perform actions on the attribute store.
This module contains various helper function to ease the access of the attribute store.
void attribute_store_add_if_missing | ( | attribute_store_node_t | parent_node, |
const attribute_store_type_t | attributes[], | ||
uint32_t | count | ||
) |
Add multiple nodes to a parent if they are not already present.
This is a helper function that will add a list of nodes to the parent if they are not already present.
parent_node | Parent node for the nodes to add. |
attributes | array of attribute types |
count | number of attributes to add. |
sl_status_t attribute_store_append_to_reported | ( | attribute_store_node_t | node, |
const uint8_t * | array, | ||
uint8_t | extra_array_length | ||
) |
Safely append a new byte array to a byte array attribute in the Attribute Store.
node | The Attribute store node under which the value must be appended |
array | byte array containing bytes |
extra_array_length | Size of the new array which will be append to the existing |
sl_status_t attribute_store_concatenate_to_reported_string | ( | attribute_store_node_t | node, |
const char * | string | ||
) |
Safely concatenate a string to a String attribute in the Attribute Store.
node | The Attribute store node under which the value must be concatenated |
string | C char array containing a String |
sl_status_t attribute_store_copy_value | ( | attribute_store_node_t | source_node, |
attribute_store_node_t | destination_node, | ||
attribute_store_node_value_state_t | value_state | ||
) |
Copy the value from a node to another.
source_node | The node that contains a value to be copied to another node. |
destination_node | The node that the source_node's value will be copied into. |
value_state | The value state to be copied from source_node to destination_node |
attribute_store_node_t attribute_store_create_child_if_missing | ( | attribute_store_node_t | node, |
attribute_store_type_t | type | ||
) |
Finds and returns the first child with a type under a node, creates it if missing.
This is a helper function that will return the first child with a type under a node and create it if needed.
node | Attribute Store Node under which the child of a type is to be returned |
type | Attribute Store type of the child we are looking for |
sl_status_t attribute_store_delete_all_children | ( | attribute_store_node_t | node | ) |
Removes all children of an attribute store node.
This is a helper function that will make sure a node has no more children.
node | Node for which all the children should be deleted |
attribute_store_node_t attribute_store_emplace | ( | attribute_store_node_t | parent_node, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Adds a child with a given reported value under a parent node, if it does not already exist.
This is a helper function that will add a child with a given reported value if the child does not already exist.
parent_node | Parent node. |
type | Attribute Store type of the child node. |
value | A pointer to a variable containing the data to be set for the reported value |
value_size | The number of bytes to read from the value pointer. |
attribute_store_node_t attribute_store_emplace_desired | ( | attribute_store_node_t | parent_node, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Adds a child with a given desired value under a parent node, if it does not already exist.
This is a helper function that will add a child with a given desired value if the child does not already exist.
parent_node | Parent node. |
type | Attribute Store type of the child node. |
value | A pointer to a variable containing the data to be set for the desired value |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_get_child_reported | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
void * | value, | ||
size_t | expected_size | ||
) |
Finds the reported value of the first child of a node with a given type.
parent | The Attribute store node under which the child's reported value must be read |
type | The type of the child |
value | A pointer to a variable containing the data to be read from the node's child. |
expected_size | The expected size of the memory to be copied in the value pointer |
sl_status_t attribute_store_get_desired | ( | attribute_store_node_t | node, |
void * | value, | ||
size_t | expected_size | ||
) |
Reads the desired value of an attribute store node.
node | The Attribute store node under which the value must be retrieved |
value | Pointer where to copy the value |
expected_size | The size of the pointer of read_value |
sl_status_t attribute_store_get_desired_else_reported | ( | attribute_store_node_t | node, |
void * | value, | ||
size_t | expected_size | ||
) |
Reads the desired value of an attribute store node, or the reported if desired is undefined.
node | The Attribute store node under which the value must be retrieved |
value | Pointer where to copy the value |
expected_size | The size of the pointer of read_value |
uint8_t attribute_store_get_desired_else_reported_size | ( | attribute_store_node_t | node | ) |
Returns the size of the desired value of a node, and if 0, returns the size of the reported value instead.
node | The Attribute store node under for which we want to know the desired else reported value length |
sl_status_t attribute_store_get_desired_else_reported_string | ( | attribute_store_node_t | node, |
char * | string, | ||
size_t | maximum_size | ||
) |
Safely retrieves a String from the Attribute Store.
node | The Attribute store node where a string is saved. |
string | [out] C char array pointer where the string data will be copied NULL termination is guaranteed. |
maximum_size | Capacity of the string pointer |
number_t attribute_store_get_desired_number | ( | attribute_store_node_t | node | ) |
Gets a numerical value from an Attribute Store node.
Note: The storage type will be taken from Attribute Store registration The default type will be int32_t is no registration has been made for a given attribute
node | The Attribute store node to get |
uint8_t attribute_store_get_desired_size | ( | attribute_store_node_t | node | ) |
Returns the size of the desired value of a node.
node | The Attribute store node under for which we want to know the desired value length |
sl_status_t attribute_store_get_desired_string | ( | attribute_store_node_t | node, |
char * | string, | ||
size_t | maximum_size | ||
) |
Safely retrieves a String from the Attribute Store.
node | The Attribute store node where a string is saved. |
string | [out] C char array pointer where the string data will be copied NULL termination is guaranteed. |
maximum_size | Capacity of the string pointer |
number_t attribute_store_get_number | ( | attribute_store_node_t | node, |
attribute_store_node_value_state_t | value_state | ||
) |
Helper function that sets the Reported or Desired value of a number.
Note: Does not work with the DESIRED_OR_REPORTED attribute value type.
node | Attribute Store node to read the value from |
value_state | The type of value ot set, REPORTED_ATTRIBUTE or DESIRED_ATTRIBUTE |
sl_status_t attribute_store_get_reported | ( | attribute_store_node_t | node, |
void * | value, | ||
size_t | expected_size | ||
) |
Reads the reported value of an attribute store node.
node | The Attribute store node under which the value must be retrieved |
value | Pointer where to copy the value |
expected_size | The size of the pointer of read_value |
number_t attribute_store_get_reported_number | ( | attribute_store_node_t | node | ) |
Gets a numerical value from an Attribute Store node.
Note: The storage type will be taken from Attribute Store registration The default type will be int32_t is no registration has been made for a given attribute
node | The Attribute store node to get |
uint8_t attribute_store_get_reported_size | ( | attribute_store_node_t | node | ) |
Returns the size of the reported value of a node.
node | The Attribute store node under for which we want to know the reported value length |
sl_status_t attribute_store_get_reported_string | ( | attribute_store_node_t | node, |
char * | string, | ||
size_t | maximum_size | ||
) |
Safely retrieves a String from the Attribute Store.
node | The Attribute store node where a string is saved. |
string | [out] C char array pointer where the string data will be copied NULL termination is guaranteed. |
maximum_size | Capacity of the string pointer |
bool attribute_store_is_desired_defined | ( | attribute_store_node_t | node | ) |
Indicate whether the desired value of a node is defined in the attribute store.
node | The Attribute store node under which the desired value must be retrieved |
bool attribute_store_is_reported_defined | ( | attribute_store_node_t | node | ) |
Indicate whether the reported value of a node is defined in the attribute store.
node | The Attribute store node under which the reported value must be retrieved |
bool attribute_store_is_value_defined | ( | attribute_store_node_t | node, |
attribute_store_node_value_state_t | value_state | ||
) |
Indicate whether a value is defined in the attribute store.
node | The Attribute store node under which the value must be retrieved |
value_state | The value_state to retrieve |
bool attribute_store_is_value_matched | ( | attribute_store_node_t | node | ) |
Indicate whether reported and desired values are matched in the attribute store.
node | The Attribute store node under which the value must be retrieved |
sl_status_t attribute_store_read_value | ( | attribute_store_node_t | node, |
attribute_store_node_value_state_t | value_state, | ||
void * | read_value, | ||
size_t | expected_size | ||
) |
Read an arbitrary sized value from the attribute store and writes it to a pointer.
node | The Attribute store node under which the value must be retrieved |
value_state | The value_state to retrieve |
read_value | A pointer where to copy the read value from the attribute store. |
expected_size | The size of the pointer of read_value |
sl_status_t attribute_store_register_callback_by_type_to_array | ( | attribute_store_node_changed_callback_t | callback_function, |
const attribute_store_type_t | types[], | ||
uint32_t | types_count | ||
) |
Loop helper that register the same callback function for many attribute types.
callback_function | The function to invoke when the node's value is updated. |
types | Array of attribute types for which a callback will be registered. |
types_count | The number of elements in the types array. |
sl_status_t attribute_store_set_all_children_reported | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Sets the value of the all children of a node with a given type. and writes their reported value.
If there is no child of the given type for the parent, nothing will happen
parent | The Attribute store node under which the children reported values must be written |
type | The type of the children |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_child_desired | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Adds if missing and sets the value of the first child of a node with a given type. and writes its desired value.
If there is no child of the given type for the parent, it will be created.
parent | The Attribute store node under which the child's desired value must be written |
type | The type of the child |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_child_desired_only_if_exists | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Sets the value of the child node, only if the child node already exists in the Attribute Store.
parent | The Attribute store node under which the child's desired value must be written |
type | The type of the child |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_child_reported | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Adds if missing and sets the value of the first child of a node with a given type. and writes its reported value.
If there is no child of the given type for the parent, it will be created.
parent | The Attribute store node under which the child's reported value must be written |
type | The type of the child |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_child_reported_only_if_exists | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Sets the value of the child node, only if the child node already exists in the Attribute Store.
parent | The Attribute store node under which the child's reported value must be written |
type | The type of the child |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_child_reported_only_if_missing | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Adds and sets the reported value of the first child of a node with a given type only if it did not exist.
If the child already exists, it will not be created.
parent | The Attribute store node under which the child's reported value must be written |
type | The type of the child |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_child_reported_only_if_undefined | ( | attribute_store_node_t | parent, |
attribute_store_type_t | type, | ||
const void * | value, | ||
uint8_t | value_size | ||
) |
Finds the first child of a node and and sets the reported value only if it undefined.
If the child does not exist, it will not be created and nothing will happen.
parent | The Attribute store node under which the child's reported value must be written |
type | The type of the child |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_desired | ( | attribute_store_node_t | node, |
const void * | value, | ||
uint8_t | value_size | ||
) |
Set the Desired value of an Attribute Store node.
node | The Attribute store node for which DESIRED must be updated |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_desired_as_reported | ( | attribute_store_node_t | node | ) |
Set the Desired value to the same as the Reported value.
node | The Attribute store node for which DESIRED must be aligned to REPORTED |
sl_status_t attribute_store_set_desired_number | ( | attribute_store_node_t | node, |
number_t | value | ||
) |
Sets a numerical value for an Attribute Store node.
Note: The storage type will be taken from Attribute Store registration The default type will be int32_t is no registration has been made for a given attribute
node | The Attribute store node to set |
value | Value to set |
sl_status_t attribute_store_set_desired_string | ( | attribute_store_node_t | node, |
const char * | string | ||
) |
Safely copies a String in the Attribute Store.
node | The Attribute store node under which the value must be written |
string | C char array containing a String |
sl_status_t attribute_store_set_number | ( | attribute_store_node_t | node, |
number_t | value, | ||
attribute_store_node_value_state_t | value_state | ||
) |
Helper function that sets the Reported or Desired value of a number.
Note: Does not work with the DESIRED_OR_REPORTED attribute value type.
node | Attribute Store node to read the value from |
value | The value to set |
value_state | The value state/type to set (desired or reported) |
sl_status_t attribute_store_set_reported | ( | attribute_store_node_t | node, |
const void * | value, | ||
uint8_t | value_size | ||
) |
Set the Reported value of an Attribute Store node.
node | The Attribute store node for which REPORTED must be updated |
value | A pointer to a variable containing the data to be written for the node. |
value_size | The number of bytes to read from the value pointer. |
sl_status_t attribute_store_set_reported_as_desired | ( | attribute_store_node_t | node | ) |
Set the Reported value to the same as the Desired value.
node | The Attribute store node for which REPORTED must be aligned to DESIRED |
sl_status_t attribute_store_set_reported_number | ( | attribute_store_node_t | node, |
number_t | value | ||
) |
Sets a numerical value for an Attribute Store node.
Note: The storage type will be taken from Attribute Store registration The default type will be int32_t is no registration has been made for a given attribute
node | The Attribute store node to set |
value | Value to set |
sl_status_t attribute_store_set_reported_string | ( | attribute_store_node_t | node, |
const char * | string | ||
) |
Safely copies a String in the Attribute Store.
node | The Attribute store node under which the value must be written |
string | C char array containing a String |
void attribute_store_undefine_desired | ( | attribute_store_node_t | node | ) |
Set the Desired value to "undefined" (0 size no value)
node | The Attribute store node for which DESIRED must be set to nothing |
void attribute_store_undefine_reported | ( | attribute_store_node_t | node | ) |
Set the Reported value to "undefined" (0 size no value)
node | The Attribute store node for which REPORTED must be set to nothing |
void attribute_store_walk_tree | ( | attribute_store_node_t | top, |
void(*)(attribute_store_node_t) | function | ||
) |
Visit all nodes in the tree.
This function visits all the attribute store nodes under the "top" node and applies the function passed in parameter.
top | First node to be visited |
function | function to execute |
void attribute_store_walk_tree_with_return_value | ( | attribute_store_node_t | top, |
sl_status_t(*)(attribute_store_node_t) | function | ||
) |
Visit all nodes in the tree, applying a function.
This function visits all the attribute store nodes under the "top" node and applies the function passed in parameter.
top | First node to be visited |
function | function to execute |