Datastore API for Attributes (from the Attribute Store)
More...
|
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...
|
|
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:
◆ 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)
◆ datastore_attribute_id_t
◆ datastore_attribute_t
Struct used to store all the data associated to an attribute.
◆ datastore_contains_attribute()
Check if the datastore contains an attribute for given key.
- Parameters
-
id | Unique 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()
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()
Delete an attribute from the persistent datastore.
- Parameters
-
id | Unique 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()
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
-
attribute | Pointer 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()
Fetch an attribute from the persistent datastore.
- Parameters
-
id | Unique ID for the Attribute Store node to be fetched. |
type | Pointer to copy the node type from the Attribute Store. |
parent_id | Pointer where the Unique ID of the parent will be written |
reported_value | Pointer 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_size | Pointer to a variable where the size of the reported value/payload written to the reported value pointer will be written. |
desired_value | Pointer 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_size | Pointer 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()
Fetch the child of an attribute from the persistent datastore.
- Parameters
-
parent_id | Unique ID for the Attribute Store node of which the nth child will be returned. |
child_index | The index of the child to find. 0 for the first child, 1 for the second child, etc. |
child_id | Pointer where the Unique ID of the found child will be copied |
type | Pointer to copy the type of the found child from the Attribute Store. |
reported_value | Pointer 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_size | Pointer to a variable where the size of the reported value/payload written to the reported value pointer will be written. |
desired_value | Pointer 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_size | Pointer 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()
Fetch the Attribute ID of a child of an attribute from the persistent datastore.
- Parameters
-
parent_id | Unique ID for the Attribute Store node of which the nth child will be returned. |
child_index | The index of the child to find. 0 for the first child, 1 for the second child, etc. |
child_id | Pointer 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()
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
-
id | Unique ID for the Attribute Store node to be inserted/updated. It has to be >0, as 0 is reserved for "no parents". |
type | Node type from the Attribute Store. |
parent_id | Unique 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_value | Pointer to the value to write the the attribute (REPORTED value) |
reported_value_size | Size of the data contained in the reported_value pointer. |
desired_value | Pointer to the value to write the the attribute (DESIRED value) |
desired_value_size | Size of the data contained in the desired_value pointer. |
- Returns
- SL_STATUS_OK if successful
-
SL_STATUS_FAIL if an error happened