Zigbee Protocol Controller 1.6.0
zigpc_datastore.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 *******************************************************************************
5 *
6 * The licensor of this software is Silicon Laboratories Inc. Your use of this
7 * software is governed by the terms of Silicon Labs Master Software License
8 * Agreement (MSLA) available at
9 * www.silabs.com/about-us/legal/master-software-license-agreement. This
10 * software is distributed to you in Source Code format and is governed by the
11 * sections of the MSLA applicable to Source Code.
12 *
13 ******************************************************************************/
14
27#ifndef ZIGPC_DATASTORE_HPP
28#define ZIGPC_DATASTORE_HPP
29
30#include <vector>
31#include <list>
32
33// ZigPC includes
34#include <zigpc_common_zigbee.h>
35#include "zigpc_datastore.h"
36
38{
39namespace device
40{
46inline std::vector<zigbee_eui64_uint_t> get_id_list(void)
47{
49
50 const size_t dev_count = zigpc_datastore_get_device_count();
51
52 std::vector<zigbee_eui64_uint_t> dev_list(dev_count);
53 for (size_t i = 0; (status == SL_STATUS_OK) && (i < dev_count); i++) {
54 zigbee_eui64_t eui64;
55 status = zigpc_datastore_find_device_by_index(i, &eui64);
56 if (status == SL_STATUS_OK) {
57 dev_list[i] = zigbee_eui64_to_uint(eui64);
58 }
59 }
60
61 return dev_list;
62}
63
64} // namespace device
65
66namespace endpoint
67{
74inline std::vector<zigbee_endpoint_id_t> get_id_list(const zigbee_eui64_t eui64)
75{
77 size_t ep_count = 0;
78
79 if (eui64 == nullptr) {
81 } else {
82 ep_count = zigpc_datastore_get_endpoint_count(eui64);
83 }
84
85 std::vector<zigbee_endpoint_id_t> ep_list(ep_count);
86 for (size_t i = 0; (status == SL_STATUS_OK) && (i < ep_count); i++) {
87 status
88 = zigpc_datastore_find_endpoint_by_index(eui64, i, ep_list.data() + i);
89 }
90
91 return ep_list;
92}
93
94} // namespace endpoint
95
96namespace cluster
97{
106inline std::vector<zcl_cluster_id_t>
109 zcl_cluster_side_t cluster_side)
110{
111 sl_status_t status = SL_STATUS_OK;
112 size_t cluster_count = 0;
113
114 if (eui64 == nullptr) {
115 status = SL_STATUS_NULL_POINTER;
116 } else {
117 cluster_count
118 = zigpc_datastore_get_cluster_count(eui64, ep_id, cluster_side);
119 }
120
121 std::vector<zcl_cluster_id_t> cluster_list(cluster_count);
122 for (size_t i = 0; (status == SL_STATUS_OK) && (i < cluster_count); i++) {
124 ep_id,
125 cluster_side,
126 i,
127 cluster_list.data() + i);
128 }
129
130 return cluster_list;
131}
132
133} // namespace cluster
134
135namespace group
136{
146inline std::vector<zigbee_group_id_t> get_group_list(const zigbee_eui64_t eui64,
148 bool is_reported)
149{
150 sl_status_t status = SL_STATUS_OK;
151 size_t group_count = 0;
152
153 if (eui64 == nullptr) {
154 status = SL_STATUS_NULL_POINTER;
155 } else {
156 group_count = zigpc_datastore_get_group_count(eui64, ep_id, is_reported);
157 }
158
159 std::vector<zigbee_group_id_t> group_list(group_count);
160 for (size_t i = 0; (status == SL_STATUS_OK) && (i < group_count); i++) {
162 ep_id,
163 is_reported,
164 i,
165 group_list.data() + i);
166 }
167
168 return group_list;
169}
170} // namespace group
171
172namespace binding
173{
189 zigbee_eui64_uint_t source,
190 zigbee_binding_t binding);
191
203 zigbee_eui64_uint_t source,
204 zigbee_binding_t binding);
205
218 zigbee_eui64_uint_t source,
219 std::list<zigbee_binding_t>& binding_table_dest);
220
232}
233
234
235} // namespace zigpc_datastore
236
237#endif // ZIGPC_DATASTORE_HPP
238
#define SL_STATUS_OK
No error.
Definition: sl_status.h:49
uint32_t sl_status_t
Definition: sl_status.h:139
#define SL_STATUS_NULL_POINTER
Invalid null pointer received as argument.
Definition: sl_status.h:89
uint8_t zigbee_eui64_t[ZIGBEE_EUI64_SIZE]
Zigbee Device EUI64 ID.
Definition: zigpc_common_zigbee.h:193
enum e_zcl_cluster_side zcl_cluster_side_t
An enum representing the role of the cluster on the network.
zigbee_eui64_uint_t zigbee_eui64_to_uint(const zigbee_eui64_t eui64)
Convert the array EUI64 representation into 64-bit uint representation.
Definition: zigpc_common_zigbee.c:23
uint64_t zigbee_eui64_uint_t
Zigbee Device Identifier (stored as integer)
Definition: zigpc_common_zigbee.h:199
uint8_t zigbee_endpoint_id_t
A representation of the endpoint id used on the Zigbee protocol.
Definition: zigpc_common_zigbee.h:248
sl_status_t zigpc_datastore_find_device_by_index(size_t index, zigbee_eui64_t *const eui64)
Find a particular device entity and retrieve its search key (EUI64) based on an index....
size_t zigpc_datastore_get_endpoint_count(const zigbee_eui64_t eui64)
Get count of endpoints persisted under a device.
sl_status_t zigpc_datastore_find_group_by_index(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, bool is_reported, size_t index, zigbee_group_id_t *group_id)
Find a particular group entity persisted under a device endpoint and retrieve its search key (group_i...
sl_status_t zigpc_datastore_find_endpoint_by_index(const zigbee_eui64_t eui64, size_t index, zigbee_endpoint_id_t *endpoint_id)
Find a particular endpoint entity persisted under a device and retrieve its search key (endpoint_id) ...
size_t zigpc_datastore_get_device_count(void)
Get count of devices persisted under the network.
sl_status_t zigpc_datastore_find_cluster_by_index(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, size_t index, zcl_cluster_id_t *cluster_id)
Find a particular cluster entity persisted under a device endpoint and retrieve its search key (clust...
size_t zigpc_datastore_get_group_count(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, bool is_reported)
Get count of groups persisted under an endpoint.
size_t zigpc_datastore_get_cluster_count(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side)
Get count of clusters persisted under a device endpoint.
sl_status_t read_binding_table(zigbee_eui64_uint_t source, std::list< zigbee_binding_t > &binding_table_dest)
datastore::binding::read_binding_table Reads the stored binding table of a given node.
size_t read_binding_count(zigbee_eui64_uint_t source)
datastore::binding::add_binding Remove a binding from the binding table of a given source address.
sl_status_t add_binding(zigbee_eui64_uint_t source, zigbee_binding_t binding)
datastore::binding::add_binding Add a binding to the stored binding table of a given source address....
sl_status_t remove_binding(zigbee_eui64_uint_t source, zigbee_binding_t binding)
datastore::binding::remove_binding Remove a binding from the binding table of a given source address.
std::vector< zcl_cluster_id_t > get_id_list(const zigbee_eui64_t eui64, zigbee_endpoint_id_t ep_id, zcl_cluster_side_t cluster_side)
Get list of cluster IDs under an endpoint based on the cluser side.
Definition: zigpc_datastore.hpp:107
std::vector< zigbee_eui64_uint_t > get_id_list(void)
Get list of devices on the network.
Definition: zigpc_datastore.hpp:46
std::vector< zigbee_endpoint_id_t > get_id_list(const zigbee_eui64_t eui64)
Get list of endpoint IDs under a device.
Definition: zigpc_datastore.hpp:74
std::vector< zigbee_group_id_t > get_group_list(const zigbee_eui64_t eui64, zigbee_endpoint_id_t ep_id, bool is_reported)
Get list of group IDs under an endpoint based on the report/desired state.
Definition: zigpc_datastore.hpp:146
Definition: zigpc_datastore.hpp:38
Definition: zigpc_common_zigbee.h:380