Commit 4cef0167 authored by Hermann Mayer's avatar Hermann Mayer

[Utils][Config] Added configuration parsing for the custom hooks. (See #16)

parent f84d7b41
......@@ -62,6 +62,11 @@ struct config* init_config(struct config *conf)
conf->sensor.light_dev = "/dev/spidev0.0";
conf->sensor.light_channel = 0;
conf->hooks.motion_pre = "";
conf->hooks.motion_post = "";
conf->hooks.turn_off_pre = "";
conf->hooks.turn_off_post = "";
return conf;
}
......@@ -142,6 +147,14 @@ struct config get_config(const char *path)
config_lookup_string(c, "light_sensor_device", &conf.sensor.light_dev);
config_lookup_int(c, "light_sensor_channel", &conf.sensor.light_channel);
/*
* Custom hooks
*/
config_lookup_string(c, "motion_pre_hook", &conf.hooks.motion_pre);
config_lookup_string(c, "motion_post_hook", &conf.hooks.motion_post);
config_lookup_string(c, "turn_off_pre_hook", &conf.hooks.turn_off_pre);
config_lookup_string(c, "turn_off_post_hook", &conf.hooks.turn_off_post);
free((char*) actor_command);
free((char*) desired_actor_state);
conf.ptr = c;
......
......@@ -49,6 +49,12 @@ struct config {
const char *light_dev;
int light_channel;
} sensor;
struct config_hooks {
const char *motion_pre;
const char *motion_post;
const char *turn_off_pre;
const char *turn_off_post;
} hooks;
struct config_t *ptr;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment