Unify Framework Lib 1.6.0
datastore_attributes.c File Reference
#include "datastore.h"
#include "datastore_internals.h"
#include "datastore_attributes.h"
#include "sl_log.h"
#include "sl_status.h"
#include <sqlite3.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>

Macros

#define LOG_TAG   "datastore_attributes"
 

Functions

static void log_database_not_initialized ()
 
static void log_binding_failed ()
 
sl_status_t datastore_attribute_table_init ()
 Attribute table initialization. More...
 
sl_status_t datastore_attribute_statement_init ()
 Statement initialization for the attribute table. More...
 
sl_status_t datastore_attribute_statement_teardown ()
 Statement teardown for the attribute table. More...
 
sl_status_t datastore_store_attribute (datastore_attribute_id_t id, uint32_t type, uint32_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 (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 (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...
 

Variables

static sqlite3_stmt * upsert_statement = NULL
 
static sqlite3_stmt * select_statement = NULL
 
static sqlite3_stmt * select_all_statement = NULL
 
static sqlite3_stmt * select_child_index_statement = NULL
 
static sqlite3_stmt * delete_statement = NULL
 
const char select_all_sql []
 

Macro Definition Documentation

◆ LOG_TAG

#define LOG_TAG   "datastore_attributes"

Function Documentation

◆ datastore_attribute_statement_init()

sl_status_t datastore_attribute_statement_init ( )

Statement initialization for the attribute table.

Returns
SL_STATUS_OK on success
SL_STATUS_FAIL on failure

◆ datastore_attribute_statement_teardown()

sl_status_t datastore_attribute_statement_teardown ( )

Statement teardown for the attribute table.

Returns
SL_STATUS_OK

◆ datastore_attribute_table_init()

sl_status_t datastore_attribute_table_init ( )

Attribute table initialization.

Returns
SL_STATUS_OK on success
SL_STATUS_FAIL on failure

◆ log_binding_failed()

static void log_binding_failed ( )
inlinestatic

◆ log_database_not_initialized()

static void log_database_not_initialized ( )
inlinestatic

Variable Documentation

◆ delete_statement

sqlite3_stmt* delete_statement = NULL
static

◆ select_all_sql

const char select_all_sql[]
Initial value:
= "SELECT id, type, parent_id, reported_value, "
"desired_value FROM " DATASTORE_TABLE_ATTRIBUTES ";"
#define DATASTORE_TABLE_ATTRIBUTES
Table for storing the attribute store.
Definition: datastore_internals.h:25

◆ select_all_statement

sqlite3_stmt* select_all_statement = NULL
static

◆ select_child_index_statement

sqlite3_stmt* select_child_index_statement = NULL
static

◆ select_statement

sqlite3_stmt* select_statement = NULL
static

◆ upsert_statement

sqlite3_stmt* upsert_statement = NULL
static