Zigbee Protocol Controller 1.6.0
Unify Datastore

Persistent Unify Datastore. More...

Modules

 Attributes storage.
 Datastore API for Attributes (from the Attribute Store)
 
 Unify Datastore Fixture
 Persistent Datastore fixture.
 

Typedefs

typedef const char * datastore_key_t
 

Functions

sl_status_t datastore_init (const char *database_path)
 Initialize the Datastore component. More...
 
sl_status_t datastore_start_transaction ()
 start a datastore transaction More...
 
sl_status_t datastore_commit_transaction ()
 commit an open transaction More...
 
sl_status_t datastore_teardown ()
 Tear down the Datastore component. More...
 
sl_status_t datastore_store_int (datastore_key_t key, int64_t value)
 Store integer in the persistent datastore. More...
 
sl_status_t datastore_fetch_int (datastore_key_t key, int64_t *value)
 Fetch integer from the persistent datastore. More...
 
sl_status_t datastore_store_arr (datastore_key_t key, const uint8_t *value, unsigned int size)
 Store array in the persistent datastore. More...
 
sl_status_t datastore_fetch_arr (datastore_key_t key, uint8_t *value, unsigned int *size)
 Fetch array from the persistent datastore. More...
 
bool datastore_contains_arr (datastore_key_t key)
 Check if the datastore contains an array value for given key. More...
 
bool datastore_contains_int (datastore_key_t key)
 Check if the datastore contains an int value for given key. More...
 
bool datastore_is_initialized ()
 Checks if the datastore is initialized and can be used. More...
 

Detailed Description

Persistent Unify Datastore.

Persistent datastore, that allows for storing key-value pair. The users of this component must handle updating own values if format change between versions. Keys are zero terminated strings

Typedef Documentation

◆ datastore_key_t

typedef const char* datastore_key_t

Function Documentation

◆ datastore_commit_transaction()

sl_status_t datastore_commit_transaction ( )

commit an open transaction

  • Returns
    sl_status_t SL_STATUS_OK for success SL_STATUS_FAIL if an error occurred

◆ datastore_contains_arr()

bool datastore_contains_arr ( datastore_key_t  key)

Check if the datastore contains an array value for given key.

Parameters
keyKey to check if is in the datastore
Returns
true if key is present in the datatore else false

◆ datastore_contains_int()

bool datastore_contains_int ( datastore_key_t  key)

Check if the datastore contains an int value for given key.

Parameters
keyKey to check if is in the datastore
Returns
true if key is present in the datatore else false

◆ datastore_fetch_arr()

sl_status_t datastore_fetch_arr ( datastore_key_t  key,
uint8_t *  value,
unsigned int *  size 
)

Fetch array from the persistent datastore.

Parameters
keyKey to fetch value under
valueDestination for the key
sizeIn: the size of value, Out: Number of bytes written to value
Returns
sl_status_t SL_STATUS_OK if successful, SL_STATUS_NOT_FOUND if key is not found, SL_STATUS_WOULD_OVERFLOW if fetched data is larger than size SL_STATUS_FAIL if other failure,

◆ datastore_fetch_int()

sl_status_t datastore_fetch_int ( datastore_key_t  key,
int64_t *  value 
)

Fetch integer from the persistent datastore.

Parameters
keyKey to fetch value under
valueDestination for the key
Returns
sl_status_t SL_STATUS_OK if successful, SL_STATUS_NOT_FOUND if key is not found, SL_STATUS_FAIL if other failure,

◆ datastore_init()

sl_status_t datastore_init ( const char *  database_path)

Initialize the Datastore component.

If the datastore init fails, then there is no reason to call datastore_teardown() If it initialized successful, then datastore_teardown() shall be called before exiting

Parameters
database_pathPath to the database file, The directory the path must exist, or init will fail (or ":memory:" to use in memory database)
Returns
sl_status_t SL_STATUS_OK for success SL_STATUS_FAIL if an error occurred

◆ datastore_is_initialized()

bool datastore_is_initialized ( )

Checks if the datastore is initialized and can be used.

Returns
true if the datastore can be used
false if the datastore cannot be used.

◆ datastore_start_transaction()

sl_status_t datastore_start_transaction ( )

start a datastore transaction

With transactions, datastore calls will be cached so that they can be commited in one go. This increases the throughput of data. Only one transaction at the time can be open, otherwise SL_STATUS_ABORT is returned.

  • Returns
    sl_status_t SL_STATUS_OK for success SL_STATUS_IN_PROGRESS if there is an ongoing transaction SL_STATUS_FAIL if an error occurred

◆ datastore_store_arr()

sl_status_t datastore_store_arr ( datastore_key_t  key,
const uint8_t *  value,
unsigned int  size 
)

Store array in the persistent datastore.

NOTE: If a record already exists for the given key, the stored value will be overwritten by the value provided.

NOTE: If casting larger data types into the array, the component doing this shall be able to handle different endianess, as because of back-up/restore it shall be supported to move the database from Big Endian to Little Endian and vice versa. For uint8_t arrays there are no issues, as they are unaffected by endianess

Parameters
keyKey to store value under, must be unique
valueValue to store under key
sizeSize of value array
Returns
sl_status_t SL_STATUS_OK if successful, SL_STATUS_FAIL if failure

◆ datastore_store_int()

sl_status_t datastore_store_int ( datastore_key_t  key,
int64_t  value 
)

Store integer in the persistent datastore.

Parameters
keyKey to store value under, must be unique
valueValue to store under key
Returns
sl_status_t SL_STATUS_OK if successful, SL_STATUS_FAIL if failure

◆ datastore_teardown()

sl_status_t datastore_teardown ( )

Tear down the Datastore component.

Shall be called before exiting the application to close database file

Returns
sl_status_t SL_STATUS_OK for success, SL_STATUS_ERROR for failure