remove: lmdb

add: sqlite
add: new commands
This commit is contained in:
Tobias Reisinger 2020-08-24 16:00:08 +02:00
parent a37bdc4870
commit 9602e6e937
33 changed files with 1403 additions and 752 deletions

View file

@ -24,8 +24,6 @@
#include <confini.h>
config_t global_config;
controller_t *global_controller;
MDB_env *global_mdb_env;
static struct mg_mgr mgr;
@ -39,7 +37,7 @@ terminate(int signum)
//mg_mgr_free(&mgr);
LOGGER_DEBUG("closing database\n");
mdb_env_close(global_mdb_env);
database_free();
LOGGER_DEBUG("freeing global controller\n");
controller_free(global_controller);
@ -114,13 +112,19 @@ main(int argc, const char** argv)
}
/******************** SETUP DATABASE, SOCKETS AND THIS CONTROLLER ********************/
/******************** INIT DATABASE, SOCKETS AND THIS CONTROLLER ********************/
mg_mgr_init(&mgr, NULL);
database_setup(&global_mdb_env, &global_config);
database_init();
global_controller = controller_load(global_mdb_env);
global_controller = controller_load();
if(!global_controller)
{
global_controller = controller_create();
controller_save();
}
connection_discovery_bind(&mgr);
connection_mqtt_connect(&mgr);
@ -128,7 +132,7 @@ main(int argc, const char** argv)
global_controller->command_port = helper_get_port(c_command->sock);
controller_save(global_controller, global_mdb_env);
controller_save();
helper_drop_privileges();
@ -139,7 +143,7 @@ main(int argc, const char** argv)
int piface_setup = 0;
for(uint_fast8_t i = 0; i < global_controller->relay_count; ++i)
for(uint_fast8_t i = 0; i < global_config.relay_count; ++i)
{
int relay_default = global_config.relay_configs[i].init;
if(relay_default == -1)