Add configs for toml in controller
This commit is contained in:
parent
750002daf2
commit
87b3f06092
6 changed files with 79 additions and 74 deletions
|
@ -9,11 +9,6 @@
|
||||||
|
|
||||||
config_t *global_config;
|
config_t *global_config;
|
||||||
|
|
||||||
|
|
||||||
#define CONFINI_IS_KEY(SECTION, KEY) \
|
|
||||||
(ini_array_match(SECTION, disp->append_to, '.', disp->format) && \
|
|
||||||
ini_string_match_ii(KEY, disp->data, disp->format))
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
config_load_log_level(config_t *config, char *value)
|
config_load_log_level(config_t *config, char *value)
|
||||||
{
|
{
|
||||||
|
@ -211,6 +206,8 @@ config_init()
|
||||||
global_config->user = NULL;
|
global_config->user = NULL;
|
||||||
global_config->group = NULL;
|
global_config->group = NULL;
|
||||||
|
|
||||||
|
global_config->include = NULL;
|
||||||
|
|
||||||
config_load_string(&global_config->content_dir, ".");
|
config_load_string(&global_config->content_dir, ".");
|
||||||
config_load_string(&global_config->not_found_file, "404.html");
|
config_load_string(&global_config->not_found_file, "404.html");
|
||||||
config_load_string(&global_config->not_found_file_type, "text/html");
|
config_load_string(&global_config->not_found_file_type, "text/html");
|
||||||
|
|
|
@ -81,7 +81,7 @@ handle_http_request(struct mg_connection *nc, struct http_message *hm)
|
||||||
response.content = NULL;
|
response.content = NULL;
|
||||||
response.alloced_content = false;
|
response.alloced_content = false;
|
||||||
|
|
||||||
M_RESPONSE_MSG(LOGGER_WARNING, &response, 500, "server did not create a response");
|
M_RESPONSE_MSG(LOGGER_NONE, &response, 500, "server did not create a response");
|
||||||
|
|
||||||
if(!endpoint)
|
if(!endpoint)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,13 @@ logger_log(int level, const char *filename, int line, const char *func, const ch
|
||||||
strftime(timestamp_str, 32, "%Y-%m-%d %H:%M:%S", localtime(&rawtime));
|
strftime(timestamp_str, 32, "%Y-%m-%d %H:%M:%S", localtime(&rawtime));
|
||||||
size_t timestamp_len = strlen(timestamp_str);
|
size_t timestamp_len = strlen(timestamp_str);
|
||||||
|
|
||||||
char *buffer = malloc(sizeof(char) * (128 + strlen(msg) + timestamp_len));
|
size_t buffer_size = 128;
|
||||||
|
buffer_size += timestamp_len;
|
||||||
|
buffer_size += strlen(filename);
|
||||||
|
buffer_size += strlen(func);
|
||||||
|
buffer_size += strlen(msg);
|
||||||
|
|
||||||
|
char *buffer = malloc(sizeof(char) * (buffer_size));
|
||||||
sprintf(buffer, "%s %s[%5s] %s:%d:%s " COLOR_NONE "%s", timestamp_str, color, level_str, filename, line, func, msg);
|
sprintf(buffer, "%s %s[%5s] %s:%d:%s " COLOR_NONE "%s", timestamp_str, color, level_str, filename, line, func, msg);
|
||||||
|
|
||||||
// start arg va_list and find log_len
|
// start arg va_list and find log_len
|
||||||
|
|
66
tests/emgauwa-controller-testing.conf
Normal file
66
tests/emgauwa-controller-testing.conf
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
[controller]
|
||||||
|
database = "emgauwa-controller.sqlite"
|
||||||
|
|
||||||
|
mqtt-host = "127.0.0.1"
|
||||||
|
|
||||||
|
[ports]
|
||||||
|
# 4422 for testing; 4421 for dev-env; 4420 for testing-env; 4419 for prod-env
|
||||||
|
discovery = 4422
|
||||||
|
# 1886 for testing; 1885 for dev-env; 1884 for testing-env; 1883 for prod-env
|
||||||
|
mqtt = 1886
|
||||||
|
|
||||||
|
[logging]
|
||||||
|
level = "debug"
|
||||||
|
file = "stdout"
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "piface"
|
||||||
|
pin = 0
|
||||||
|
inverted = 0
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "piface"
|
||||||
|
pin = 1
|
||||||
|
inverted = 0
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 5
|
||||||
|
inverted = 1
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 4
|
||||||
|
inverted = 1
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 3
|
||||||
|
inverted = 1
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 2
|
||||||
|
inverted = 1
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 1
|
||||||
|
inverted = 1
|
||||||
|
pulse-duration = 3
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 0
|
||||||
|
inverted = 1
|
||||||
|
pulse-duration = 3
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 16
|
||||||
|
inverted = 1
|
||||||
|
|
||||||
|
[[relays]]
|
||||||
|
driver = "gpio"
|
||||||
|
pin = 15
|
||||||
|
inverted = 1
|
|
@ -1,65 +0,0 @@
|
||||||
[controller]
|
|
||||||
name = new emgauwa device
|
|
||||||
|
|
||||||
: 4422 for testing; 4421 for dev-env; 4420 for testing-env; 4419 for prod-env
|
|
||||||
discovery-port = 4422
|
|
||||||
: 1886 for testing; 1885 for dev-env; 1884 for testing-env; 1883 for prod-env
|
|
||||||
mqtt-port = 1886
|
|
||||||
mqtt-host = localhost
|
|
||||||
|
|
||||||
relay-count = 10
|
|
||||||
database = controller.sqlite
|
|
||||||
log-level = debug
|
|
||||||
log-file = stdout
|
|
||||||
|
|
||||||
[relay-0]
|
|
||||||
driver = piface
|
|
||||||
pin = 0
|
|
||||||
inverted = 0
|
|
||||||
|
|
||||||
[relay-1]
|
|
||||||
driver = piface
|
|
||||||
pin = 1
|
|
||||||
inverted = 0
|
|
||||||
|
|
||||||
[relay-2]
|
|
||||||
driver = gpio
|
|
||||||
pin = 5
|
|
||||||
inverted = 1
|
|
||||||
|
|
||||||
[relay-3]
|
|
||||||
driver = gpio
|
|
||||||
pin = 4
|
|
||||||
inverted = 1
|
|
||||||
|
|
||||||
[relay-4]
|
|
||||||
driver = gpio
|
|
||||||
pin = 3
|
|
||||||
inverted = 1
|
|
||||||
|
|
||||||
[relay-5]
|
|
||||||
driver = gpio
|
|
||||||
pin = 2
|
|
||||||
inverted = 1
|
|
||||||
|
|
||||||
[relay-6]
|
|
||||||
driver = gpio
|
|
||||||
pin = 1
|
|
||||||
inverted = 1
|
|
||||||
pulse-duration = 3
|
|
||||||
|
|
||||||
[relay-7]
|
|
||||||
driver = gpio
|
|
||||||
pin = 0
|
|
||||||
inverted = 1
|
|
||||||
pulse-duration = 3
|
|
||||||
|
|
||||||
[relay-8]
|
|
||||||
driver = gpio
|
|
||||||
pin = 16
|
|
||||||
inverted = 1
|
|
||||||
|
|
||||||
[relay-9]
|
|
||||||
driver = gpio
|
|
||||||
pin = 15
|
|
||||||
inverted = 1
|
|
|
@ -15,7 +15,8 @@ then
|
||||||
mkdir -p controller
|
mkdir -p controller
|
||||||
cd controller
|
cd controller
|
||||||
|
|
||||||
git pull >/dev/null || git clone --quiet ssh://git@git.serguzim.me:3022/emgauwa/controller.git . || exit
|
echo "Trying to pull or clone controller"
|
||||||
|
git clone --quiet ssh://git@git.serguzim.me:3022/emgauwa/controller.git . >/dev/null 2>&1 || git pull >/dev/null || exit
|
||||||
|
|
||||||
git checkout dev >/dev/null 2>&1
|
git checkout dev >/dev/null 2>&1
|
||||||
git checkout $target_branch >/dev/null 2>&1
|
git checkout $target_branch >/dev/null 2>&1
|
||||||
|
@ -32,7 +33,7 @@ fi
|
||||||
|
|
||||||
echo "Emgauwa controller: $($EMGAUWA_CONTROLLER_EXE --version)"
|
echo "Emgauwa controller: $($EMGAUWA_CONTROLLER_EXE --version)"
|
||||||
|
|
||||||
$EMGAUWA_CONTROLLER_EXE start -c $source_dir/emgauwa-controller-testing.ini >$working_dir/controller.log 2>&1 &
|
$EMGAUWA_CONTROLLER_EXE -c $source_dir/emgauwa-controller-testing.conf >$working_dir/controller.log 2>&1 &
|
||||||
controller_id=$!
|
controller_id=$!
|
||||||
|
|
||||||
cd $working_dir
|
cd $working_dir
|
||||||
|
|
Loading…
Reference in a new issue