Zigbee Protocol Controller 1.6.0
zigpc_datastore.h
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
123#ifndef ZIGPC_DATASTORE_H
124#define ZIGPC_DATASTORE_H
125
126// Shared Unify includes
127#include <sl_status.h>
128#include <sl_log.h>
129
130// ZigPC includes
131#include <zigpc_common_zigbee.h>
132
133#ifdef __cplusplus
134extern "C" {
135#endif
136
141typedef struct {
146} __attribute__((__packed__)) zigpc_network_data_t;
147
152typedef struct {
157} __attribute__((__packed__)) zigpc_device_data_t;
158
163typedef struct {
164 uint8_t zcl_version;
165} __attribute__((__packed__)) zigpc_endpoint_data_t;
166
171typedef struct {
172 uint8_t dummy;
173} __attribute__((__packed__)) zigpc_cluster_data_t;
174
179typedef struct {
180 char group_name[ZCL_GROUP_NAME_LENGTH];
181} __attribute__((__packed__)) zigpc_group_data_t;
182
183/**********************************
184 **********************************
185 *
186 * Network Entity APIs
187 *
188 **********************************
189 **********************************/
190
200
210sl_status_t zigpc_datastore_read_network(zigpc_network_data_t *const data);
211
221sl_status_t zigpc_datastore_write_network(const zigpc_network_data_t *data);
222
231
232/**********************************
233 **********************************
234 *
235 * Device Entity APIs
236 *
237 **********************************
238 **********************************/
239
246
259 zigbee_eui64_t *const eui64);
260
272
284 zigpc_device_data_t *const data);
293
306 const zigpc_device_data_t *data);
307
317
327
328/**********************************
329 **********************************
330 *
331 * Endpoint Entity APIs
332 *
333 **********************************
334 **********************************/
335
343
359 const zigbee_eui64_t eui64, size_t index, zigbee_endpoint_id_t *endpoint_id);
360
373 zigbee_endpoint_id_t endpoint_id);
374
387 zigbee_endpoint_id_t endpoint_id,
388 zigpc_endpoint_data_t *const data);
389
402 zigbee_endpoint_id_t endpoint_id,
403 const zigpc_endpoint_data_t *data);
404
415 zigbee_endpoint_id_t endpoint_id);
416
417/**********************************
418 **********************************
419 *
420 * Group Entity APIs
421 *
422 **********************************
423 **********************************/
424
434 zigbee_endpoint_id_t endpoint_id,
435 bool is_reported);
436
455 zigbee_endpoint_id_t endpoint_id,
456 bool is_reported,
457 size_t index,
458 zigbee_group_id_t *group_id);
459
473 zigbee_endpoint_id_t endpoint_id,
474 bool is_reported,
475 zigbee_group_id_t group_id);
476
492 zigbee_endpoint_id_t endpoint_id,
493 bool is_reported,
494 zigbee_group_id_t group_id);
495
511 zigbee_endpoint_id_t endpoint_id,
512 bool is_reported,
513 zigbee_group_id_t group_id,
514 zigpc_group_data_t *const data);
515
531 zigbee_endpoint_id_t endpoint_id,
532 bool is_reported,
533 zigbee_group_id_t group_id,
534 const zigpc_group_data_t *data);
535
548 zigbee_endpoint_id_t endpoint_id,
549 bool is_reported,
550 zigbee_group_id_t group_id);
551/**********************************
552 **********************************
553 *
554 * Cluster Entity APIs
555 *
556 **********************************
557 **********************************/
558
568 zigbee_endpoint_id_t endpoint_id,
569 zcl_cluster_side_t cluster_side);
570
589 zigbee_endpoint_id_t endpoint_id,
590 zcl_cluster_side_t cluster_side,
591 size_t index,
592 zcl_cluster_id_t *cluster_id);
593
606 zigbee_endpoint_id_t endpoint_id,
607 zcl_cluster_side_t cluster_side,
608 zcl_cluster_id_t cluster_id);
609
624 zigbee_endpoint_id_t endpoint_id,
625 zcl_cluster_side_t cluster_side,
626 zcl_cluster_id_t cluster_id);
627
642 zigbee_endpoint_id_t endpoint_id,
643 zcl_cluster_side_t cluster_side,
644 zcl_cluster_id_t cluster_id,
645 zigpc_cluster_data_t *const data);
646
661 zigbee_endpoint_id_t endpoint_id,
662 zcl_cluster_side_t cluster_side,
663 zcl_cluster_id_t cluster_id,
664 const zigpc_cluster_data_t *data);
665
678 zigbee_endpoint_id_t endpoint_id,
679 zcl_cluster_side_t cluster_side,
680 zcl_cluster_id_t cluster_id);
681
682/**********************************
683 **********************************
684 *
685 * Cluster Attribute List API
686 *
687 **********************************
688 **********************************/
689
700 zigbee_endpoint_id_t endpoint_id,
701 zcl_cluster_side_t cluster_side,
702 zcl_cluster_id_t cluster_id);
703
723 zigbee_endpoint_id_t endpoint_id,
724 zcl_cluster_side_t cluster_side,
725 zcl_cluster_id_t cluster_id,
726 zcl_attribute_id_t *const attribute_list,
727 size_t *attribute_count);
728
746 zigbee_endpoint_id_t endpoint_id,
747 zcl_cluster_side_t cluster_side,
748 zcl_cluster_id_t cluster_id,
749 const zcl_attribute_id_t *attribute_list,
750 size_t attribute_count);
751
752/**********************************
753 **********************************
754 *
755 * Cluster Command List API
756 *
757 **********************************
758 **********************************/
759
772 zigbee_endpoint_id_t endpoint_id,
773 zcl_cluster_side_t cluster_side,
774 zcl_cluster_id_t cluster_id,
775 zcl_command_type_t command_type);
776
798 zigbee_endpoint_id_t endpoint_id,
799 zcl_cluster_side_t cluster_side,
800 zcl_cluster_id_t cluster_id,
801 zcl_command_type_t command_type,
802 zcl_command_id_t *const command_list,
803 size_t *command_count);
804
824 zigbee_endpoint_id_t endpoint_id,
825 zcl_cluster_side_t cluster_side,
826 zcl_cluster_id_t cluster_id,
827 zcl_command_type_t command_type,
828 const zcl_command_id_t *command_list,
829 size_t command_count);
830
831/**********************************
832 **********************************
833 *
834 * Utility Functions
835 *
836 **********************************
837 **********************************/
838
853 const zigbee_eui64_t eui64,
854 zcl_cluster_side_t cluster_side,
855 zcl_cluster_id_t cluster_id,
856 zigbee_endpoint_id_t *const endpoint_id);
857
858/**********************************
859 **********************************
860 *
861 * Utility Logging API
862 *
863 **********************************
864 **********************************/
865
873
885 sl_log_level_t log_level,
886 const char *log_prefix);
887
900 sl_log_level_t log_level,
901 const char *log_prefix,
902 const zigbee_eui64_t eui64);
903
912 const zigbee_eui64_t eui64,
913 const zigbee_endpoint_id_t endpoint_id);
914
915#ifdef __cplusplus
916}
917#endif
918
919#endif // ZIGPC_DATASTORE_H
920
#define data
Definition: ctimer.c:49
__attribute__((unused)) static const char *event_names[]
enum sl_log_level sl_log_level_t
Log levels.
uint32_t sl_status_t
Definition: sl_status.h:139
uint16_t zcl_attribute_id_t
A representation of the endpoint cluster attribute ID used in ZCL.
Definition: zigpc_common_zigbee.h:260
zigbee_node_network_status
The possible states that a Zigbee node can be in.
Definition: zigpc_common_zigbee.h:394
uint16_t zigbee_panid_t
Zigbee Network PAN ID.
Definition: zigpc_common_zigbee.h:212
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.
uint8_t zigbee_radio_channel_t
Zigbee Network Radio Channel.
Definition: zigpc_common_zigbee.h:224
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
uint8_t zigbee_ext_panid_t[ZIGBEE_EXTENDED_PAN_ID_SIZE]
Zigbee Network Extended PAN ID.
Definition: zigpc_common_zigbee.h:218
uint16_t zigbee_group_id_t
Zigbee Group Id The internal representation of a group_id.
Definition: zigpc_common_zigbee.h:230
#define ZCL_GROUP_NAME_LENGTH
Expected length of a zigbee group name, as supported in the ZCL specification.
Definition: zigpc_common_zigbee.h:100
uint8_t zigbee_endpoint_id_t
A representation of the endpoint id used on the Zigbee protocol.
Definition: zigpc_common_zigbee.h:248
uint8_t zcl_command_id_t
Definition: zigpc_common_zigbee.h:265
sl_status_t zigpc_datastore_remove_network(void)
Remove persisted network entity.
void zigpc_datastore_log_device_disc_state(const zigbee_eui64_t eui64)
Log the stored discovery information under a device which includes: endpoints, clusters,...
sl_status_t zigpc_datastore_create_device(const zigbee_eui64_t eui64)
Create device entity to be persisted under the network. The read/write APIs can be used to manipulate...
bool zigpc_datastore_contains_cluster(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id)
Determine if a particular cluster ID is supported under a device endpoint.
sl_status_t zigpc_datastore_read_command_list(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, zcl_command_type_t command_type, zcl_command_id_t *const command_list, size_t *command_count)
Read command list under a given cluster based on the command type passed in.
sl_status_t zigpc_datastore_write_command_list(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, zcl_command_type_t command_type, const zcl_command_id_t *command_list, size_t command_count)
Write command list under a given cluster based on the command type passed in. This function will over...
bool zigpc_datastore_is_device_contained(zigbee_eui64_uint_t device_eui64)
Check is the datastore contains a device entity.
sl_status_t zigpc_datastore_write_group(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, bool is_reported, zigbee_group_id_t group_id, const zigpc_group_data_t *data)
Write data to a persisted group entity.
sl_status_t zigpc_datastore_remove_endpoint(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id)
Remove persisted endpoint entity.
sl_status_t zigpc_datastore_create_network(void)
Create network entity to be persisted. The read/write APIs can be used to manipulate the data associa...
sl_status_t zigpc_datastore_remove_cluster(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id)
Remove persisted cluster entity.
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....
sl_status_t zigpc_datastore_read_attribute_list(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, zcl_attribute_id_t *const attribute_list, size_t *attribute_count)
Read the attribute list under a given cluster.
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_read_device(const zigbee_eui64_t eui64, zigpc_device_data_t *const data)
Read data from a persisted device entity.
size_t zigpc_datastore_get_command_count(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, zcl_command_type_t command_type)
Get count of commands persisted under a cluster based on the command type passed in.
sl_status_t zigpc_datastore_create_cluster(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id)
Create cluster entity to be persisted under a device endpoint. The read/write APIs can be used to man...
sl_status_t zigpc_datastore_read_endpoint(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zigpc_endpoint_data_t *const data)
Read data from a persisted endpoint entity.
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_remove_group(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, bool is_reported, zigbee_group_id_t group_id)
Remove persisted group entity.
sl_status_t zigpc_datastore_read_network(zigpc_network_data_t *const data)
Read data from persisted network entity.
sl_status_t zigpc_datastore_find_endpoint_containing_cluster(const zigbee_eui64_t eui64, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, zigbee_endpoint_id_t *const endpoint_id)
Find the endpoint identifier under a device containing a particular cluster identifier.
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) ...
sl_status_t zigpc_datastore_write_endpoint(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, const zigpc_endpoint_data_t *data)
Write data to a persisted device entity.
sl_status_t zigpc_datastore_log_network(const char *log_tag, sl_log_level_t log_level, const char *log_prefix)
Log the network information.
sl_status_t zigpc_datastore_read_cluster(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, zigpc_cluster_data_t *const data)
Read data from a persisted cluster entity.
sl_status_t zigpc_datastore_create_endpoint(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id)
Create endpoint entity to be persisted under a device. The read/write APIs can be used to manipulate ...
size_t zigpc_datastore_get_device_count(void)
Get count of devices persisted under the network.
sl_status_t zigpc_datastore_write_network(const zigpc_network_data_t *data)
Write data to persisted network entity.
sl_status_t zigpc_datastore_remove_device(const zigbee_eui64_t eui64)
Remove persisted device entity.
sl_status_t zigpc_datastore_write_device(const zigbee_eui64_t eui64, const zigpc_device_data_t *data)
Write data to a persisted device entity.
void zigpc_datastore_log_clusters(const zigbee_eui64_t eui64, const zigbee_endpoint_id_t endpoint_id)
Log clusters on an EUI64, endpoint. Logs both server and client clusters.
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...
bool zigpc_datastore_contains_group(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, bool is_reported, zigbee_group_id_t group_id)
Determine if a particular group ID is supported under a device endpoint.
sl_status_t zigpc_datastore_write_attribute_list(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, const zcl_attribute_id_t *attribute_list, size_t attribute_count)
Write attribute list under a given cluster. This function will overwrite any existing list by removin...
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 zigpc_datastore_read_group(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, bool is_reported, zigbee_group_id_t group_id, zigpc_group_data_t *const data)
Read data from a persisted group entity.
sl_status_t zigpc_datastore_log_device(const char *log_tag, sl_log_level_t log_level, const char *log_prefix, const zigbee_eui64_t eui64)
Log single device entity.
sl_status_t zigpc_datastore_remove_device_children(const zigbee_eui64_t eui64)
Remove persisted children under device entity.
size_t zigpc_datastore_get_attribute_count(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id)
Get count of attributes persisted under a cluster.
sl_status_t zigpc_datastore_write_cluster(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_side_t cluster_side, zcl_cluster_id_t cluster_id, const zigpc_cluster_data_t *data)
Write data to a persisted cluster entity.
sl_status_t zigpc_datastore_create_group(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, bool is_reported, zigbee_group_id_t group_id)
Create group entity to be persisted under a device endpoint. The read/write APIs can be used to manip...
SL Status Codes.
uint8_t endpoint_discovered_count
Definition: zigpc_datastore.h:156
zigbee_ext_panid_t ext_panid
Definition: zigpc_datastore.h:144
enum zigbee_node_network_status network_status
Definition: zigpc_datastore.h:153
zigbee_panid_t panid
Definition: zigpc_datastore.h:143
uint8_t endpoint_total_count
Definition: zigpc_datastore.h:155
zigbee_eui64_t gateway_eui64
Definition: zigpc_datastore.h:142
zigbee_radio_channel_t radio_channel
Definition: zigpc_datastore.h:145
uint8_t zcl_version
Definition: zigpc_datastore.h:164
uint8_t dummy
Definition: zigpc_datastore.h:172
uint32_t max_cmd_delay
Definition: zigpc_datastore.h:154