22#ifndef ZIGPC_DATASTORE_ACCESSOR_HPP
23#define ZIGPC_DATASTORE_ACCESSOR_HPP
36static constexpr char LOG_TAG[] =
"zigpc_datastore";
89 std::string key_str = ss.str();
92 if (input_valid ==
false) {
94 "%s: %s entity[NodeId:%u] Failed to find parent node",
102 reinterpret_cast<uint8_t *
>(&key),
103 sizeof(search_key_t),
132 while (child_valid) {
167 uint8_t child_size(
sizeof(search_key_t));
171 reinterpret_cast<uint8_t *
>(key),
192 std::stringstream ss;
194 std::string key_str = ss.str();
196 found_node = this->
find(parent, key);
204 "%s: Failed to create entity %s",
211 uint8_t key_size =
sizeof(search_key_t);
216 reinterpret_cast<uint8_t *
>(&key),
220 "%s: %s entity[NodeId:%u]: Failed to populate entity data",
247 if (
data ==
nullptr) {
250 found_node = this->
find(parent, key);
257 uint8_t data_size =
sizeof(data_t);
261 reinterpret_cast<uint8_t *
>(
data),
264 std::stringstream ss;
266 std::string key_str = ss.str();
268 "%s: %s entity[NodeId:%u]: Failed to read entity data",
295 if (
data ==
nullptr) {
298 found_node = this->
find(parent, key);
305 uint8_t data_size =
sizeof(data_t);
309 reinterpret_cast<const uint8_t *
>(
data),
312 std::stringstream ss;
314 std::string key_str = ss.str();
316 "%s: %s entity[NodeId:%u]: Failed to write entity data",
339 std::stringstream ss;
341 std::string key_str = ss.str();
349 "%s: %s entity[NodeId:%u]: Failed to remove entity",
376 std::stringstream ss;
378 std::string key_str = ss.str();
382 "%s: Failed to find entity %s to remove children under",
394 "%s: Failed to remove child[%u] remove entity",
416 std::ostringstream ss;
421 ss << this->label <<
": ";
422 uint8_t *buffer =
reinterpret_cast<uint8_t *
>(&
data);
423 for (
size_t i = 0U; i <
sizeof(data_t); i++) {
424 ss << *buffer <<
" ";
458 list_entry_t *
const list,
459 size_t list_capacity)
463 if (
list ==
nullptr) {
466 for (
size_t i = 0; (status ==
SL_STATUS_OK) && (i < list_capacity); i++) {
488 const list_entry_t *
list,
493 if (
list ==
nullptr) {
507 for (
size_t i = 0; (status ==
SL_STATUS_OK) && (i < list_count); i++) {
508 status = this->list_entry.
create(list_parent,
list[i]);
527 size_t list_index = 0U;
577 public StoreAccessor<zigbee_eui64_uint_t, zigpc_device_data_t>
595 public StoreAccessor<zigbee_endpoint_id_t, zigpc_endpoint_data_t>
629 return is_reported ?
"ReportedGroup" :
"DesiredGroup";
uint32_t attribute_store_type_t
Definition: attribute_store.h:50
Definition: zigpc_datastore_accessor.hpp:662
static std::string get_label_type(zcl_cluster_side_t cluster_side)
Get the label based on the cluster side used.
Definition: zigpc_datastore_accessor.hpp:675
static attribute_store_type_t get_entity_type(zcl_cluster_side_t cluster_side)
Retrieve the attribute store node type of the cluster based on the cluster side received.
Definition: zigpc_datastore_accessor.hpp:690
zcl_cluster_side_t cluster_side
Definition: zigpc_datastore_accessor.hpp:664
ClusterAccessor(zcl_cluster_side_t cluster_side)
std::string to_str(attribute_store_node_t parent, zcl_cluster_id_t cluster_id) override
Return string representation of cluster entity.
Definition: zigpc_datastore_accessor.hpp:711
std::string to_str(attribute_store_node_t parent, size_t list_count) override
Return string representation of attribute list.
ClusterAttributeListAccessor()
static std::string get_label_type(void)
Get the label type of the attribute list.
Definition: zigpc_datastore_accessor.hpp:720
Definition: zigpc_datastore_accessor.hpp:737
zcl_command_type_t command_type
Definition: zigpc_datastore_accessor.hpp:739
static std::string get_label_type(zcl_command_type_t command_type)
Get the label type based on the command type passed in.
Definition: zigpc_datastore_accessor.hpp:750
std::string to_str(attribute_store_node_t parent, size_t list_count) override
Return string representation of command list.
static attribute_store_type_t get_entity_type(zcl_command_type_t command_type)
Retrieve the attribute store node type of the command based on the command type received.
Definition: zigpc_datastore_accessor.hpp:765
ClusterCommandListAccessor(zcl_command_type_t command_type)
Definition: zigpc_datastore_accessor.hpp:578
std::string to_str(attribute_store_node_t parent, zigbee_eui64_uint_t eui64) override
Return string representation of device entity.
Definition: zigpc_datastore_accessor.hpp:596
std::string to_str(attribute_store_node_t parent, zigbee_endpoint_id_t endpoint_id) override
Return string representation of endpoint entity.
Definition: zigpc_datastore_accessor.hpp:614
bool is_reported
Definition: zigpc_datastore_accessor.hpp:616
std::string to_str(attribute_store_node_t parent, zigbee_group_id_t group_id) override
Return string representation of group entity.
GroupAccessor(bool is_reported)
static attribute_store_type_t get_entity_type(bool is_reported)
Retrieve the attribute store node type of the group based on the reported/desired type received.
Definition: zigpc_datastore_accessor.hpp:641
static std::string get_label_type(bool is_reported)
Get the label type of the group.
Definition: zigpc_datastore_accessor.hpp:627
Definition: zigpc_datastore_accessor.hpp:561
std::string to_str(attribute_store_node_t parent, uint8_t index) override
Return string representation of network entity.
Template class for accessing entities using the attribute store API.
Definition: zigpc_datastore_accessor.hpp:53
virtual ~StoreAccessor()=default
sl_status_t remove(attribute_store_node_t parent, search_key_t key)
Remove the entity from the store.
Definition: zigpc_datastore_accessor.hpp:335
sl_status_t remove_children(attribute_store_node_t parent, search_key_t key)
Remove all child entities from the store.
Definition: zigpc_datastore_accessor.hpp:370
virtual std::string to_str(attribute_store_node_t parent, search_key_t key)
Get string representation of entity in byte buffer representation.
Definition: zigpc_datastore_accessor.hpp:414
attribute_store_node_t find(attribute_store_node_t parent, search_key_t key)
Find an entity based based on the key.
Definition: zigpc_datastore_accessor.hpp:83
sl_status_t write(attribute_store_node_t parent, search_key_t key, const data_t *data)
Write information to the entity.
Definition: zigpc_datastore_accessor.hpp:290
attribute_store_type_t node_type
Definition: zigpc_datastore_accessor.hpp:55
std::string label
Definition: zigpc_datastore_accessor.hpp:56
attribute_store_type_t get_node_type(void) const
Definition: zigpc_datastore_accessor.hpp:70
std::string get_label(void) const
Definition: zigpc_datastore_accessor.hpp:65
StoreAccessor(attribute_store_type_t node_type, std::string label)
Definition: zigpc_datastore_accessor.hpp:59
sl_status_t create(attribute_store_node_t parent, search_key_t key)
Create a new entity based on the search key.
Definition: zigpc_datastore_accessor.hpp:187
size_t child_count(attribute_store_node_t parent, search_key_t key, attribute_store_type_t child_type)
Retrive the count of child entities by type.
Definition: zigpc_datastore_accessor.hpp:118
sl_status_t read(attribute_store_node_t parent, search_key_t key, data_t *const data)
Read information of the entity.
Definition: zigpc_datastore_accessor.hpp:242
sl_status_t find_by_index(attribute_store_node_t parent, size_t index, search_key_t *key)
Find the search key of the child entity based on the index.
Definition: zigpc_datastore_accessor.hpp:154
Definition: zigpc_datastore_accessor.hpp:434
virtual ~StoreListAccessor()=default
sl_status_t read_list(attribute_store_node_t list_parent, list_entry_t *const list, size_t list_capacity)
Read the list of entries.
Definition: zigpc_datastore_accessor.hpp:457
sl_status_t remove_list(attribute_store_node_t list_parent)
Remove a list under the node ID passed in.
Definition: zigpc_datastore_accessor.hpp:520
StoreListAccessor(attribute_store_type_t node_type, std::string label)
Definition: zigpc_datastore_accessor.hpp:439
StoreAccessor< list_entry_t, uint8_t > list_entry
Definition: zigpc_datastore_accessor.hpp:436
virtual std::string to_str(attribute_store_node_t parent, size_t list_count)=0
sl_status_t create_list(attribute_store_node_t list_parent, const list_entry_t *list, size_t list_count)
Create the list into the store if it doesn't exist already.
Definition: zigpc_datastore_accessor.hpp:487
bool attribute_store_node_exists(attribute_store_node_t node)
Verify whether a node is in the Attribute Store.
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.
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_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.
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.
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.
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_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.
#define ATTRIBUTE_STORE_INVALID_NODE
Special attribute_store_node_t value indicating that it does not exist.
Definition: attribute_store.h:106
@ 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
#define data
Definition: ctimer.c:49
#define sl_log_warning(tag, fmtstr,...)
Definition: sl_log.h:143
#define sl_log_error(tag, fmtstr,...)
Definition: sl_log.h:145
#define SL_STATUS_OK
No error.
Definition: sl_status.h:49
#define SL_STATUS_ALREADY_EXISTS
Item already exists.
Definition: sl_status.h:101
uint32_t sl_status_t
Definition: sl_status.h:139
#define SL_STATUS_FAIL
Generic error.
Definition: sl_status.h:50
#define SL_STATUS_NULL_POINTER
Invalid null pointer received as argument.
Definition: sl_status.h:89
#define SL_STATUS_NOT_FOUND
Item could not be found.
Definition: sl_status.h:100
enum e_zcl_cluster_side zcl_cluster_side_t
An enum representing the role of the cluster on the network.
uint16_t zcl_cluster_id_t
A representation of the endpoint cluster id used in ZCL.
Definition: zigpc_common_zigbee.h:254
zcl_command_type_t
Definition: zigpc_common_zigbee.h:267
uint64_t zigbee_eui64_uint_t
Zigbee Device Identifier (stored as integer)
Definition: zigpc_common_zigbee.h:199
uint16_t zigbee_group_id_t
Zigbee Group Id The internal representation of a group_id.
Definition: zigpc_common_zigbee.h:230
uint8_t zigbee_endpoint_id_t
A representation of the endpoint id used on the Zigbee protocol.
Definition: zigpc_common_zigbee.h:248
@ ZCL_CLUSTER_GENERATED_COMMAND
Definition: zigpc_common_zigbee.h:268
@ ZCL_CLUSTER_SERVER_SIDE
Definition: zigpc_common_zigbee.h:321
static constexpr char LOG_TAG[]
Definition: zigpc_datastore_accessor.hpp:36
@ ZIGPC_DS_TYPE_GROUP_REPORTED
Definition: zigpc_datastore_id.h:47
@ ZIGPC_DS_TYPE_CLIENT_CLUSTER
Definition: zigpc_datastore_id.h:43
@ ZIGPC_DS_TYPE_SERVER_CLUSTER
Definition: zigpc_datastore_id.h:42
@ ZIGPC_DS_TYPE_GROUP_DESIRED
Definition: zigpc_datastore_id.h:48
@ ZIGPC_DS_TYPE_CLUSTER_GENERATED_COMMAND
Definition: zigpc_datastore_id.h:45
@ ZIGPC_DS_TYPE_CLUSTER_RECEIVED_COMMAND
Definition: zigpc_datastore_id.h:46