Zigbee Protocol Controller 1.6.0
Attributes storage.

Datastore API for Attributes (from the Attribute Store) More...

Classes

struct  _datastore_attribute_
 Struct used to store all the data associated to an attribute. More...
 

Macros

#define DATASTORE_ATTRIBUTE_VALUE_SIZE   255
 Maximum length that the value (desired or reported) of an attribute can take (in bytes) More...
 

Typedefs

typedef uint32_t datastore_attribute_id_t
 
typedef struct _datastore_attribute_ datastore_attribute_t
 Struct used to store all the data associated to an attribute. More...
 

Functions

sl_status_t datastore_store_attribute (datastore_attribute_id_t id, uint32_t type, datastore_attribute_id_t parent_id, const uint8_t *reported_value, uint8_t reported_value_size, const uint8_t *desired_value, uint8_t desired_value_size)
 Store an attribute in the persistent datastore. More...
 
sl_status_t datastore_fetch_attribute (const datastore_attribute_id_t id, uint32_t *type, datastore_attribute_id_t *parent_id, uint8_t *reported_value, uint8_t *reported_value_size, uint8_t *desired_value, uint8_t *desired_value_size)
 Fetch an attribute from the persistent datastore. More...
 
sl_status_t datastore_fetch_all_attributes (datastore_attribute_t *attribute)
 Fetch all attributes from the datastore. More...
 
sl_status_t datastore_fetch_attribute_child (datastore_attribute_id_t parent_id, uint32_t child_index, datastore_attribute_id_t *child_id, uint32_t *type, uint8_t *reported_value, uint8_t *reported_value_size, uint8_t *desired_value, uint8_t *desired_value_size)
 Fetch the child of an attribute from the persistent datastore. More...
 
sl_status_t datastore_fetch_attribute_child_id (datastore_attribute_id_t parent_id, uint32_t child_index, datastore_attribute_id_t *child_id)
 Fetch the Attribute ID of a child of an attribute from the persistent datastore. More...
 
bool datastore_contains_attribute (const datastore_attribute_id_t id)
 Check if the datastore contains an attribute for given key. More...
 
sl_status_t datastore_delete_attribute (const datastore_attribute_id_t id)
 Delete an attribute from the persistent datastore. More...
 
sl_status_t datastore_delete_all_attributes ()
 Delete the whole attribute table in the persistent datastore. More...
 

Detailed Description

Datastore API for Attributes (from the Attribute Store)

Persistent datastore, that allows for storing our Attribute Store. It uses a tailored table allowing to capture the Attribute Store tree.

DESCRIBE TABLE; gives the following:

Macro Definition Documentation

◆ DATASTORE_ATTRIBUTE_VALUE_SIZE

#define DATASTORE_ATTRIBUTE_VALUE_SIZE   255

Maximum length that the value (desired or reported) of an attribute can take (in bytes)

Typedef Documentation

◆ datastore_attribute_id_t

◆ datastore_attribute_t

Struct used to store all the data associated to an attribute.

Function Documentation

◆ datastore_contains_attribute()

bool datastore_contains_attribute ( const datastore_attribute_id_t  id)

Check if the datastore contains an attribute for given key.

Parameters
idUnique ID for the Attribute Store node to search for
Returns
true if the attribute datastore_id is present in the datatore
false if the key is not present in the datatore

◆ datastore_delete_all_attributes()

sl_status_t datastore_delete_all_attributes ( )

Delete the whole attribute table in the persistent datastore.

Returns
SL_STATUS_OK if successful
SL_STATUS_FAIL if an error happened

◆ datastore_delete_attribute()

sl_status_t datastore_delete_attribute ( const datastore_attribute_id_t  id)

Delete an attribute from the persistent datastore.

Parameters
idUnique ID for the Attribute Store node to be deleted
Returns
SL_STATUS_OK if successful
SL_STATUS_FAIL if an error happened

◆ datastore_fetch_all_attributes()

sl_status_t datastore_fetch_all_attributes ( datastore_attribute_t attribute)

Fetch all attributes from the datastore.

Invoking this function will initialize an iteration to a SQL query retrieving all attributes from the SQLite database

This function must be invoked repeatedly until it returns SL_STATUS_OK or SL_STATUS_FAIL

Parameters
attributePointer to copy the data received from the SQLite database
Returns
SL_STATUS_OK if it was the last row and there is no more data.
SL_STATUS_IN_PROGRESS if data was copied to the pointer and an iteration is ongoing.
SL_STATUS_FAIL if an error happened

◆ datastore_fetch_attribute()

sl_status_t datastore_fetch_attribute ( const datastore_attribute_id_t  id,
uint32_t type,
datastore_attribute_id_t parent_id,
uint8_t *  reported_value,
uint8_t *  reported_value_size,
uint8_t *  desired_value,
uint8_t *  desired_value_size 
)

Fetch an attribute from the persistent datastore.

Parameters
idUnique ID for the Attribute Store node to be fetched.
typePointer to copy the node type from the Attribute Store.
parent_idPointer where the Unique ID of the parent will be written
reported_valuePointer to the stored reported value of the attribute will be copied. The value buffer must be able to contain ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH bytes.
reported_value_sizePointer to a variable where the size of the reported value/payload written to the reported value pointer will be written.
desired_valuePointer to the stored desired value of the attribute will be copied. The value buffer must be able to contain ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH bytes.
desired_value_sizePointer to a variable where the size of the desired value/payload written to the desired value pointer will be written.
Returns
SL_STATUS_OK if successful
SL_STATUS_FAIL if an error happened
SL_STATUS_NOT_FOUND the id was not found in the database.

◆ datastore_fetch_attribute_child()

sl_status_t datastore_fetch_attribute_child ( datastore_attribute_id_t  parent_id,
uint32_t  child_index,
datastore_attribute_id_t child_id,
uint32_t type,
uint8_t *  reported_value,
uint8_t *  reported_value_size,
uint8_t *  desired_value,
uint8_t *  desired_value_size 
)

Fetch the child of an attribute from the persistent datastore.

Parameters
parent_idUnique ID for the Attribute Store node of which the nth child will be returned.
child_indexThe index of the child to find. 0 for the first child, 1 for the second child, etc.
child_idPointer where the Unique ID of the found child will be copied
typePointer to copy the type of the found child from the Attribute Store.
reported_valuePointer to the stored reported value of the attribute will be copied. The value buffer must be able to contain ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH bytes.
reported_value_sizePointer to a variable where the size of the reported value/payload written to the reported value pointer will be written.
desired_valuePointer to the stored desired value of the attribute will be copied. The value buffer must be able to contain ATTRIBUTE_STORE_MAXIMUM_VALUE_LENGTH bytes.
desired_value_sizePointer to a variable where the size of the desired value/payload written to the desired value pointer will be written.
Returns
SL_STATUS_OK if successful
SL_STATUS_FAIL if an error happened
SL_STATUS_NOT_FOUND nth child or parent does not exist.

◆ datastore_fetch_attribute_child_id()

sl_status_t datastore_fetch_attribute_child_id ( datastore_attribute_id_t  parent_id,
uint32_t  child_index,
datastore_attribute_id_t child_id 
)

Fetch the Attribute ID of a child of an attribute from the persistent datastore.

Parameters
parent_idUnique ID for the Attribute Store node of which the nth child will be returned.
child_indexThe index of the child to find. 0 for the first child, 1 for the second child, etc.
child_idPointer where the Unique ID of the found child will be copied
Returns
SL_STATUS_OK if successful
SL_STATUS_FAIL if an error happened
SL_STATUS_NOT_FOUND nth child or parent does not exist.

◆ datastore_store_attribute()

sl_status_t datastore_store_attribute ( datastore_attribute_id_t  id,
uint32_t  type,
datastore_attribute_id_t  parent_id,
const uint8_t *  reported_value,
uint8_t  reported_value_size,
const uint8_t *  desired_value,
uint8_t  desired_value_size 
)

Store an attribute in the persistent datastore.

It will insert it if no ID already exists, else it will update the data in the data store.

Parameters
idUnique ID for the Attribute Store node to be inserted/updated. It has to be >0, as 0 is reserved for "no parents".
typeNode type from the Attribute Store.
parent_idUnique ID of the Attribute Store parent node for the node to be inserted/updated. Set this to 0x00 for a node without parent (root node)
reported_valuePointer to the value to write the the attribute (REPORTED value)
reported_value_sizeSize of the data contained in the reported_value pointer.
desired_valuePointer to the value to write the the attribute (DESIRED value)
desired_value_sizeSize of the data contained in the desired_value pointer.
Returns
SL_STATUS_OK if successful
SL_STATUS_FAIL if an error happened