Unify Framework Lib 1.6.0
attribute_store_helper.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_HELPER_H
15#define ATTRIBUTE_STORE_HELPER_H
16
17// Includes from this component
18#include "attribute_store.h"
19
20// Generic includes
21#include <stdbool.h>
22
23// Type that we use to represent "any" number
24typedef float number_t;
25
37#ifdef __cplusplus
38extern "C" {
39#endif
40
53
65
78
89
100
111
119
132 const void *value,
133 uint8_t value_size);
134
149 void *value,
150 size_t expected_size);
151
165 number_t value);
166
180 number_t value);
181
196
211
222 const char *string);
223
234 const char *string);
235
250 char *string,
251 size_t maximum_size);
252
266 char *string,
267 size_t maximum_size);
268
282 attribute_store_node_t node, char *string, size_t maximum_size);
283
295 const char *string);
296
309 const uint8_t *array,
310 uint8_t extra_array_length);
311
319
332 const void *value,
333 uint8_t value_size);
334
349 void *value,
350 size_t expected_size);
351
367 attribute_store_node_t node, void *value, size_t expected_size);
368
388 attribute_store_node_t destination_node,
390
410 void *read_value,
411 size_t expected_size);
412
431 const void *value,
432 uint8_t value_size);
433
453 const void *value,
454 uint8_t value_size);
455
474 const void *value,
475 uint8_t value_size);
476
492 void *value,
493 size_t expected_size);
494
514 const void *value,
515 uint8_t value_size);
516
534 const void *value,
535 uint8_t value_size);
536
556 const void *value,
557 uint8_t value_size);
558
576 const void *value,
577 uint8_t value_size);
578
588 void (*function)(attribute_store_node_t));
589
600
612 const attribute_store_type_t attributes[],
613 uint32_t count);
614
632 const void *value,
633 uint8_t value_size);
634
652 const void *value,
653 uint8_t value_size);
654
668 const attribute_store_type_t types[],
669 uint32_t types_count);
670
682
701
715
716
729 number_t value,
731
741
751
760uint8_t
762
763#ifdef __cplusplus
764}
765#endif
766
769#endif //attribute_store_helper_H
uint32_t attribute_store_type_t
Definition: attribute_store.h:50
float number_t
Definition: attribute_store_helper.h:24
attribute_store_node_value_state_t
This is the value state of a value.
Definition: attribute_store.h:121
datastore_attribute_id_t attribute_store_node_t
Handle to identify attribute store nodes.
Definition: attribute_store.h:101
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
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.
Definition: attribute_store_helper.c:492
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.
Definition: attribute_store_helper.c:528
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.
Definition: attribute_store_helper.c:583
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.
Definition: attribute_store_helper.c:76
sl_status_t attribute_store_set_desired_string(attribute_store_node_t node, const char *string)
Safely copies a String in the Attribute Store.
Definition: attribute_store_helper.c:171
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.
Definition: attribute_store_helper.c:294
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.
Definition: attribute_store_helper.c:329
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.
Definition: attribute_store_helper.c:455
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.
Definition: attribute_store_helper.c:682
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.
Definition: attribute_store_helper.c:675
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.
Definition: attribute_store_helper.c:830
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.
Definition: attribute_store_helper.c:853
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.
Definition: attribute_store_helper.c:349
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 ex...
Definition: attribute_store_helper.c:466
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.
Definition: attribute_store_helper.c:304
number_t attribute_store_get_reported_number(attribute_store_node_t node)
Gets a numerical value from an Attribute Store node.
Definition: attribute_store_helper.c:796
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.
Definition: attribute_store_helper.c:669
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.
Definition: attribute_store_helper.c:214
bool attribute_store_is_value_matched(attribute_store_node_t node)
Indicate whether reported and desired values are matched in the attribute store.
Definition: attribute_store_helper.c:55
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.
Definition: attribute_store_helper.c:507
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....
Definition: attribute_store_helper.c:408
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.
Definition: attribute_store_helper.c:481
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.
Definition: attribute_store_helper.c:93
number_t attribute_store_get_desired_number(attribute_store_node_t node)
Gets a numerical value from an Attribute Store node.
Definition: attribute_store_helper.c:801
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.
Definition: attribute_store_helper.c:382
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.
Definition: attribute_store_helper.c:50
sl_status_t attribute_store_set_reported_string(attribute_store_node_t node, const char *string)
Safely copies a String in the Attribute Store.
Definition: attribute_store_helper.c:160
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 ins...
Definition: attribute_store_helper.c:875
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.
Definition: attribute_store_helper.c:422
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.
Definition: attribute_store_helper.c:183
uint8_t attribute_store_get_desired_size(attribute_store_node_t node)
Returns the size of the desired value of a node.
Definition: attribute_store_helper.c:869
void attribute_store_undefine_reported(attribute_store_node_t node)
Set the Reported value to "undefined" (0 size no value)
Definition: attribute_store_helper.c:110
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.
Definition: attribute_store_helper.c:45
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....
Definition: attribute_store_helper.c:442
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.
Definition: attribute_store_helper.c:807
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.
Definition: attribute_store_helper.c:314
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.
Definition: attribute_store_helper.c:359
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.
Definition: attribute_store_helper.c:30
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.
Definition: attribute_store_helper.c:556
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.
Definition: attribute_store_helper.c:125
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.
Definition: attribute_store_helper.c:115
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.
Definition: attribute_store_helper.c:339
sl_status_t attribute_store_delete_all_children(attribute_store_node_t node)
Removes all children of an attribute store node.
Definition: attribute_store_helper.c:569
uint8_t attribute_store_get_reported_size(attribute_store_node_t node)
Returns the size of the reported value of a node.
Definition: attribute_store_helper.c:864
void attribute_store_walk_tree(attribute_store_node_t top, void(*function)(attribute_store_node_t))
Visit all nodes in the tree.
Definition: attribute_store_helper.c:518
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.
Definition: attribute_store_helper.c:540
void attribute_store_undefine_desired(attribute_store_node_t node)
Set the Desired value to "undefined" (0 size no value)
Definition: attribute_store_helper.c:324
uint32_t sl_status_t
Definition: sl_status.h:139