Zigbee Protocol Controller 1.6.0
attribute_store.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 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 ATTRIBUTE_STORE_H
15#define ATTRIBUTE_STORE_H
16
17// Includes from this component
18
19// Includes from other components
21#include "sl_status.h"
22#include <stddef.h>
23
34#ifdef ATTRIBUTE_TYPE_MAP
35#define DEFINE_ATTRIBUTE(name, value) {value, #name},
36#else
37#ifdef ATTRIBUTE_NAME_MAP
38#define DEFINE_ATTRIBUTE(name, value) {#name, value},
39#else
40#define DEFINE_ATTRIBUTE(name, value) enum { name = value };
41#endif
42#endif
43
44#define ATTRIBUTE_STORE_INVALID_ATTRIBUTE_TYPE \
45 ((attribute_store_type_t)0x0000)
46
47#define ATTRIBUTE_TREE_ROOT \
48 ((attribute_store_type_t)0x0001)
49
51
100//typedef void *attribute_store_node_t;
102
104#define ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH DATASTORE_ATTRIBUTE_VALUE_SIZE
106#define ATTRIBUTE_STORE_INVALID_NODE (attribute_store_node_t)0
107
112typedef enum {
117
121typedef enum {
126
132
137
142
153
159
160#ifdef __cplusplus
161extern "C" {
162#endif
163
172
185 attribute_store_node_t parent_node);
198
209
222
244 const uint8_t *value,
245 uint8_t value_size);
246
271 uint8_t *value,
272 uint8_t *value_size);
273
284
301 uint32_t child_index);
302
311
322
331
349 attribute_store_type_t child_type,
350 uint32_t child_index);
351
352static inline attribute_store_node_t
354 attribute_store_type_t child_type)
355{
356 return attribute_store_get_node_child_by_type(node, child_type, 0);
357}
358
384 attribute_store_type_t child_type,
386 const uint8_t *value,
387 uint8_t value_size,
388 uint32_t child_index);
389
404
416 attribute_store_node_touch_callback_t callback_function);
417
427
440
457
467
479 attribute_store_node_t possible_parent);
480
492
507
512
522
525#ifdef __cplusplus
526}
527#endif
528
529#endif //ATTRIBUTE_STORE_H
uint32_t attribute_store_type_t
Definition: attribute_store.h:50
bool attribute_store_node_exists(attribute_store_node_t node)
Verify whether a node is in the Attribute Store.
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.
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.
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.
void(* attribute_store_node_touch_callback_t)(attribute_store_node_t)
Attribute store callback type for "touch" events.
Definition: attribute_store.h:136
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.
attribute_store_change_t
Attribute Store type to indicate the modification type that triggered a callback.
Definition: attribute_store.h:112
attribute_store_node_value_state_t
This is the value state of a value.
Definition: attribute_store.h:121
void attribute_store_log(void)
Log the content of the Attribute Store tree using Unify Logging system.
attribute_store_node_t attribute_store_get_node_parent(attribute_store_node_t node)
Get the node handle of the parent of a node.
attribute_store_node_t attribute_store_get_root()
Retrieve the root node of the tree.
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.
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.
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.
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.
void(* attribute_store_node_delete_callback_t)(attribute_store_node_t)
Attribute store callback type for deletion events.
Definition: attribute_store.h:141
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.
sl_status_t attribute_store_register_callback(attribute_store_node_update_callback_t callback_function)
Register a callback function to any node change.
datastore_attribute_id_t attribute_store_node_t
Handle to identify attribute store nodes.
Definition: attribute_store.h:101
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.
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.
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.
void(* attribute_store_node_changed_callback_t)(attribute_store_node_t, attribute_store_change_t)
Attribute store callback type for tree node updates.
Definition: attribute_store.h:130
size_t attribute_store_get_node_total_child_count(attribute_store_node_t node)
Get the number of total children of the given node.
attribute_store_type_t attribute_store_get_node_type(attribute_store_node_t node)
Get the type of a node.
void(* attribute_store_node_update_callback_t)(attribute_changed_event_t *event_data)
Attribute store callback type for tree node updates.
Definition: attribute_store.h:157
static attribute_store_node_t attribute_store_get_first_child_by_type(attribute_store_node_t node, attribute_store_type_t child_type)
Definition: attribute_store.h:353
size_t attribute_store_get_node_child_count(attribute_store_node_t node)
Get the number of children of the given node.
sl_status_t attribute_store_delete_node(attribute_store_node_t node)
Delete a node and all its children from the attribute store.
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.
struct attribute_changed_event attribute_changed_event_t
structure that contains information about the current state of a given node in the attribute store.
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.
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.
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.
@ ATTRIBUTE_CREATED
Definition: attribute_store.h:113
@ ATTRIBUTE_DELETED
Definition: attribute_store.h:115
@ ATTRIBUTE_UPDATED
Definition: attribute_store.h:114
@ DESIRED_OR_REPORTED_ATTRIBUTE
Retrieve the desired value if it exists if not then provide the reported attribute only used for read...
Definition: attribute_store.h:124
@ REPORTED_ATTRIBUTE
This is the value reported by the node or actual value.
Definition: attribute_store.h:122
@ DESIRED_ATTRIBUTE
This is the value to be applied to the node.
Definition: attribute_store.h:123
uint32_t datastore_attribute_id_t
Definition: datastore_attributes.h:46
uint32_t sl_status_t
Definition: sl_status.h:139
SL Status Codes.
structure that contains information about the current state of a given node in the attribute store.
Definition: attribute_store.h:147
attribute_store_node_value_state_t value_state
Definition: attribute_store.h:150
attribute_store_node_t updated_node
Definition: attribute_store.h:148
attribute_store_change_t change
Definition: attribute_store.h:151
attribute_store_type_t type
Definition: attribute_store.h:149
Definition: process.c:68