Commit 5d442aa2 authored by Hermann Mayer's avatar Hermann Mayer

[Config][Docs] Added motion_sensor_locktime and actor_command config parameters.…

[Config][Docs] Added motion_sensor_locktime and actor_command config parameters. Added a Makefile to the man page directory. (See #6)
parent ba0a71dd
......@@ -14,6 +14,6 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 2
[Makefile,Makefile.shared]
[Makefile]
trim_trailing_whitespace = true
indent_style = tab
......@@ -3,6 +3,9 @@ include Makefile.shared
BINS = $(patsubst src/test/%.c,%,$(wildcard src/test/*.c))
TEST_BINS = $(BINS:%=test-%)
MAN_PAGES = $(patsubst docs/man/%,%,$(wildcard docs/man/*.[0-9]))
DOCS = $(MAN_PAGES:%=docs-%)
build:
$(MAKE) build -C src/
clean:
......@@ -11,6 +14,8 @@ test:
$(MAKE) test -C src/test/
$(TEST_BINS):
$(MAKE) $@ -C src/test/
$(DOCS):
$(MAKE) $@ -C docs/man/
all: build
.PHONY: all clean test
......@@ -3,7 +3,8 @@ export PRINTF := printf
export RM := rm
export FIND := find
export GCC := gcc
export MAN := man
XML_CONF := xml2-config
export CFLAGS = $(shell $(XML_CONF) --cflags) -Wall -Werror -g
export INCLUDES = $(shell $(XML_CONF) --libs) -lcurl -lcrypto -lconfig
export INCLUDES = $(shell $(XML_CONF) --libs) -lcurl -lcrypto -lconfig -lbcm2835
PAGE_FILES = $(wildcard *.[0-9])
PAGES = $(PAGE_FILES:%=docs-%)
$(PAGES): PAGE = $(@:docs-%=%)
$(PAGES): docs-%:%
$(MAN) ./$(PAGE)
.PHONY: $(PAGES)d
......@@ -59,13 +59,29 @@ This value is a"
This parameter will specify be the default actor for
.BR "avmctl".
.B "actor_command"
The specified command will be send to the actor in case a motion
was detected. Available commands are:
.RI "`" "on" "`, `" "off" "`, `" "toggle" "`."
Defaults to
.RI "`" "on" "`."
This parameter is
.I ignored by
.BR "avmctl".
This value is a
.IR "string".
.B "turn_device_off_after"
Turn off the device after n seconds (eg. 10 minutes).
0 will disable automatic turn off. This parameter is
Specifying
.IR "0" " will disable automatic turn off. Defaults to "
.IR "0".
This parameter is
.I ignored by
.BR "avmctl".
This value is a
This value is a
.IR "integer".
.IP "Sensor thresholds"
......@@ -74,10 +90,24 @@ This value is a"
The daemon takes care of a PIR motion trigger if the value of the light is
below the specified threshold. 0 will disable the light sensor check.
With a 10-bit ADC (eg. MCP3008) the range is 0-1023. This parameter is
With a 10-bit ADC (eg. MCP3008) the range is 0-1023.
This parameter is
.I ignored by
.BR "avmctl".
This value is a
This value is a
.IR "integer".
.B "motion_sensor_locktime"
If you set the turn_device_off_after parameter to 0 you probably want
to build a toggle-by-motion setup. In this case it is advisable to specify
a time range which prevent jitter triggering. So no action is performed
for n seconds after a motion was detected. Defaults to
.IR "30" " seconds."
This parameter is
.I ignored by
.BR "avmctl".
This value is a
.IR "integer".
.IP "Sensor ports"
......@@ -85,20 +115,21 @@ This value is a"
.B "motion_sensor_gpio"
Specify a GPIO pin for the PIR motion sensor. The daemon assumes a state
change from LOW to HIGH represents a recognized motion. This parameter is
change from LOW to HIGH represents a recognized motion.
This parameter is
.I ignored by
.BR "avmctl".
This value is a
This value is a
.IR "integer".
.B "light_sensor_channel"
The daemon assumes to read the light level from a MCP3008 which is connected
to the SPI bus. With this setting you can configure which channel of the chip
will be read out. This parameter is
will be read out. This parameter is
.I ignored by
.BR "avmctl".
This value is a
This value is a
.IR "integer".
.SH AUTHOR
......
......@@ -45,11 +45,16 @@ struct config* init_config(struct config *conf)
conf->avm.hostname = "fritz.box";
conf->avm.username = "";
conf->avm.password = (const wchar_t*) strwchar_t("0000");
conf->device.ain = "";
conf->device.actor_command = "on";
conf->device.turn_off_after = 0;
conf->tholds.light_sensor = 0;
conf->tholds.motion_locktime = 30;
conf->sensor.motion_gpio = 0;
conf->sensor.light_channel = 0;
conf->tholds.light_sensor = 0;
return conf;
}
......@@ -102,6 +107,12 @@ struct config get_config(const char *path, char verbosity)
}
}
if (!config_lookup_string(&c, "actor_command", &conf.device.actor_command)) {
if (verbosity >= VERBOSE_DEBUG) {
fwprintf(stderr, L"[DEBUG] No actor command was configured\n");
}
}
if (!config_lookup_int(&c, "turn_device_off_after", &conf.device.turn_off_after)) {
if (verbosity >= VERBOSE_INFO) {
fwprintf(stderr, L"%s - %s", "[INFO] No timeout for auto device turn off was configured",
......@@ -119,14 +130,21 @@ struct config get_config(const char *path, char verbosity)
}
}
if (!config_lookup_int(&c, "motion_sensor_locktime", &conf.tholds.motion_locktime)) {
if (verbosity >= VERBOSE_INFO) {
fwprintf(stderr, L"%s - %s", "[INFO] No sensor lock time was configured",
"we won't prevent jitter\n");
}
}
/*
* Sensor ports section settings
*/
if (!config_lookup_int(&c, "motion_sensor_gpio", &conf.sensor.motion_gpio)) {
fwprintf(stderr, L"%s%s", "[ERROR] No GPIO pin for the motion sensor was configured",
"(this is mandatory)");
config_destroy(&c);
exit(EXIT_FAILURE);
if (verbosity >= VERBOSE_INFO) {
fwprintf(stderr, L"%s%s", "[ERROR] No GPIO pin for the motion sensor was configured",
"(this is mandatory)");
}
}
if (!config_lookup_int(&c, "light_sensor_channel", &conf.sensor.light_channel)) {
......
......@@ -34,10 +34,12 @@ struct config {
} avm;
struct config_device {
const char *ain;
const char *actor_command;
int turn_off_after;
} device;
struct config_tholds {
int light_sensor;
int motion_locktime;
} tholds;
struct config_sensor {
int motion_gpio;
......
......@@ -21,6 +21,10 @@ ain = "08:96:D7:F7:DE:5A";
# Turn off the device after n seconds (10 minutes)
# 0 will disable automatic turn off
turn_device_off_after = 600;
# The specified command will be send to the actor in case a motion
# was detected. Available commands are: `on`, `off`, `toggle`.
# Defaults to `on`.
# actor_command = "on";
#
# Sensor thresholds
......@@ -31,6 +35,12 @@ turn_device_off_after = 600;
# 0 will disable the light sensor check
# light_sensor_thold = 500;
# If you set the turn_device_off_after parameter to 0 you probably want
# to build a toggle-by-motion setup. In this case it is advisable to specify
# a time range which prevent jitter triggering. So no action is performed
# for n seconds after a motion was detected. Defaults to 30 seconds.
# motion_sensor_locktime = 0;
#
# Sensor ports
#
......
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