Zigbee Protocol Controller 1.6.0
attribute_store.h File Reference
#include "datastore_attributes.h"
#include "sl_status.h"
#include <stddef.h>

Go to the source code of this file.

Classes

struct  attribute_changed_event
 structure that contains information about the current state of a given node in the attribute store. More...
 

Macros

#define DEFINE_ATTRIBUTE(name, value)   enum { name = value };
 The macros below are used for defining attribute. More...
 
#define ATTRIBUTE_STORE_INVALID_ATTRIBUTE_TYPE    ((attribute_store_type_t)0x0000)
 This represents an invalid attribute Type. Shall not be used for nodes in the attribute store. More...
 
#define ATTRIBUTE_TREE_ROOT    ((attribute_store_type_t)0x0001)
 This represents the root of the attribute store tree. More...
 
#define ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH   DATASTORE_ATTRIBUTE_VALUE_SIZE
 Maximum length for a value associated to an attribute. More...
 
#define ATTRIBUTE_STORE_INVALID_NODE   (attribute_store_node_t)0
 Special attribute_store_node_t value indicating that it does not exist. More...
 

Typedefs

typedef uint32_t attribute_store_type_t
 
typedef datastore_attribute_id_t attribute_store_node_t
 Handle to identify attribute store nodes. More...
 
typedef void(* attribute_store_node_changed_callback_t) (attribute_store_node_t, attribute_store_change_t)
 Attribute store callback type for tree node updates. More...
 
typedef void(* attribute_store_node_touch_callback_t) (attribute_store_node_t)
 Attribute store callback type for "touch" events. More...
 
typedef void(* attribute_store_node_delete_callback_t) (attribute_store_node_t)
 Attribute store callback type for deletion events. More...
 
typedef struct attribute_changed_event attribute_changed_event_t
 structure that contains information about the current state of a given node in the attribute store. More...
 
typedef void(* attribute_store_node_update_callback_t) (attribute_changed_event_t *event_data)
 Attribute store callback type for tree node updates. More...
 

Enumerations

enum  attribute_store_change_t { ATTRIBUTE_CREATED , ATTRIBUTE_UPDATED , ATTRIBUTE_DELETED }
 Attribute Store type to indicate the modification type that triggered a callback. More...
 
enum  attribute_store_node_value_state_t { REPORTED_ATTRIBUTE , DESIRED_ATTRIBUTE , DESIRED_OR_REPORTED_ATTRIBUTE }
 This is the value state of a value. More...
 

Functions

attribute_store_node_t attribute_store_get_root ()
 Retrieve the root node of the tree. More...
 
attribute_store_node_t attribute_store_add_node (attribute_store_type_t type, attribute_store_node_t parent_node)
 Add a new node in the current attribute store. More...
 
sl_status_t attribute_store_delete_node (attribute_store_node_t node)
 Delete a node and all its children from the attribute store. More...
 
attribute_store_node_t attribute_store_get_node_parent (attribute_store_node_t node)
 Get the node handle of the parent of a node. More...
 
attribute_store_node_t attribute_store_get_first_parent_with_type (attribute_store_node_t node, attribute_store_type_t parent_type)
 Traverse up the tree from a node and finds the first parent with a given type. More...
 
sl_status_t attribute_store_set_node_attribute_value (attribute_store_node_t node, attribute_store_node_value_state_t value_state, const uint8_t *value, uint8_t value_size)
 Set the attribute value of a node in the current attribute store tree. More...
 
sl_status_t attribute_store_get_node_attribute_value (attribute_store_node_t node, attribute_store_node_value_state_t value_state, uint8_t *value, uint8_t *value_size)
 Get the attribute value of a node. More...
 
attribute_store_type_t attribute_store_get_node_type (attribute_store_node_t node)
 Get the type of a node. More...
 
attribute_store_node_t attribute_store_get_node_child (attribute_store_node_t node, uint32_t child_index)
 Get the node handle of a child of a node. More...
 
size_t attribute_store_get_node_child_count (attribute_store_node_t node)
 Get the number of children of the given node. More...
 
size_t attribute_store_get_node_child_count_by_type (attribute_store_node_t node, attribute_store_type_t child_type)
 Get the number of children of a certain type for a node. More...
 
size_t attribute_store_get_node_total_child_count (attribute_store_node_t node)
 Get the number of total children of the given node. More...
 
attribute_store_node_t attribute_store_get_node_child_by_type (attribute_store_node_t node, attribute_store_type_t child_type, uint32_t child_index)
 Get the node handle of a child of a node with a certain type. More...
 
static attribute_store_node_t attribute_store_get_first_child_by_type (attribute_store_node_t node, attribute_store_type_t child_type)
 
attribute_store_node_t attribute_store_get_node_child_by_value (attribute_store_node_t node, attribute_store_type_t child_type, attribute_store_node_value_state_t value_state, const uint8_t *value, uint8_t value_size, uint32_t child_index)
 Get the node handle of a child of a node with a certain type and value. More...
 
sl_status_t attribute_store_register_callback (attribute_store_node_update_callback_t callback_function)
 Register a callback function to any node change. More...
 
sl_status_t attribute_store_register_touch_notification_callback (attribute_store_node_touch_callback_t callback_function)
 Register a callback function that will be called on touch events. More...
 
sl_status_t attribute_store_register_delete_callback (attribute_store_node_delete_callback_t callback_function)
 Register a callback function that will be called when an attribute is deleted. More...
 
sl_status_t attribute_store_register_callback_by_type (attribute_store_node_changed_callback_t callback_function, attribute_store_type_t type)
 Register a callback function to any node with a given type. More...
 
sl_status_t attribute_store_register_callback_by_type_and_state (attribute_store_node_changed_callback_t callback_function, attribute_store_type_t type, attribute_store_node_value_state_t value_state)
 Register a callback function to any node with a given type for a given value_state update. More...
 
bool attribute_store_node_exists (attribute_store_node_t node)
 Verify whether a node is in the Attribute Store. More...
 
bool attribute_store_is_node_a_child (attribute_store_node_t node, attribute_store_node_t possible_parent)
 Verify whether a node is a child of another node. More...
 
uint8_t attribute_store_get_node_value_size (attribute_store_node_t node, attribute_store_node_value_state_t value_state)
 Checks the size of the REPORTED or DESIRED value for a node. More...
 
sl_status_t attribute_store_refresh_node_and_children_callbacks (attribute_store_node_t node)
 Invoking update of callbacks for the given node and all children nodes. More...
 
void attribute_store_log (void)
 Log the content of the Attribute Store tree using Unify Logging system. More...
 
void attribute_store_log_node (attribute_store_node_t node, bool log_children)
 Log the content of the Attribute Store tree using Unify Logging system from a given node. More...
 

Macro Definition Documentation

◆ ATTRIBUTE_STORE_INVALID_ATTRIBUTE_TYPE

#define ATTRIBUTE_STORE_INVALID_ATTRIBUTE_TYPE    ((attribute_store_type_t)0x0000)

This represents an invalid attribute Type. Shall not be used for nodes in the attribute store.

◆ ATTRIBUTE_TREE_ROOT

#define ATTRIBUTE_TREE_ROOT    ((attribute_store_type_t)0x0001)

This represents the root of the attribute store tree.

◆ DEFINE_ATTRIBUTE

#define DEFINE_ATTRIBUTE (   name,
  value 
)    enum { name = value };

The macros below are used for defining attribute.

DEFINE_ATTRIBUTE has 3 deferent implementations which is used in different contexts.

  • If ATTRIBUTE_TYPE_MAP is define this macro output a key_value pair where the type is the key
  • If ATTRIBUTE_NAME_MAP is define this macro output a key_value pair where the name is the key
  • Otherwise this declares a anonymous enum value. In this way the attribute can be used both expressions and in switch statements.

Typedef Documentation

◆ attribute_store_type_t