Skip to content

Database

suraj inamdar edited this page May 3, 2020 · 1 revision

Database

Database adds fine way to store all device configuration and important data for any application. all device configurations are stored in database with their individual structure format as a database table. Currently we are using device soft EEPROM as storage place for database. It has max size of 4096(SPI flash sector size).

EEPROM api's for data

we have three template api to fetch(load), save and clear any structure type data from/to eeprom. they have same argument i.e. first is structure object and second is its address in eeprom

/**
 * template to load table from database by their address in table object
 *
 * @param   type of database table struct  _object
 * @param   uint16_t  	configStart
 */
template <typename T> void loadConfig ( T * _object, uint16_t configStart );
/**
 * template to save table in database by their address from table object
 *
 * @param   type of database table struct  _object
 * @param   uint16_t  	configStart
 */
template <typename T> void saveConfig ( T * _object, uint16_t configStart );
/**
 * template to clear tables in database by their address
 *
 * @param   const type of database table struct  _object
 * @param   uint16_t  	_address
 */
template <typename T> void clearConfigs( const T * _object, uint16_t _address );

Database table api's

These are table apis which are used by individual tables to register, get, set and clear their data & structure from/to database. These api's uses above eeprom apis to perform table operations. Register table take address and table default data copy as argument. this api is called internally while initialising database tables All other api's takes table address only except set_table api which takes additional table data argument to set at given address

/**
 * register table with address and default copy
 *
 * @param   uint16_t  _table_address
 * @param   const T *  _default_table_copy
 */
void register_table( uint16_t _table_address, const T * _default_table_copy);
/**
 * set table in database by their address
 *
 * @param   type of database table struct  _object
 * @param   uint16_t  _address
 * @return  bool
 */
bool set_table( T * _object, uint16_t _address );
/**
 * return table in database by their address
 *
 * @param   uint16_t  _address
 * @return  type of database table
 */
T get_table( uint16_t _address );
/**
 * clear table in database by their address
 *
 * @param   uint16_t  _address
 * @return  bool
 */
bool clear_table( uint16_t _address );

Default Database Tables

By default framework uses some database tables to store the required default confrontational data by individual service. the available default tables are

Clone this wiki locally