X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=arexxd.c;h=e083c52bce471caf59bca4ddc9f2b324fa4ba60a;hb=HEAD;hp=df1877b627ad99de529a484ebbe7aea5d5e1d991;hpb=04b748ae0227816a73a5edf5e6b624ce2a67b8b8;p=arexx.git diff --git a/arexxd.c b/arexxd.c index df1877b..e083c52 100644 --- a/arexxd.c +++ b/arexxd.c @@ -35,7 +35,7 @@ #define IGNORE_UNKNOWN_SENSORS #undef LOG_TO_RRD -#undef LOG_TO_MQTT +#define LOG_TO_MQTT typedef unsigned char byte; typedef unsigned int uint; @@ -46,7 +46,6 @@ static int use_syslog; static int debug_mode; static int debug_packets; static int debug_raw_data; -static int debug_usb; static char *log_dir = DEFAULT_LOG_DIR; static int no_fork; @@ -137,12 +136,15 @@ static void mqtt_init(void) if (!mosq) die("Mosquitto: initialization failed"); + if (mosquitto_tls_set(mosq, "/etc/burrow-mqtt/ca.crt", NULL, "/etc/burrow-mqtt/client.crt", "/etc/burrow-mqtt/client.key", NULL) != MOSQ_ERR_SUCCESS) + die("Mosquitto: unable to set TLS parameters"); + if (mosquitto_will_set(mosq, "status/arexxd", 4, "dead", 0, true) != MOSQ_ERR_SUCCESS) die("Mosquitto: unable to set will"); mosquitto_connect_callback_set(mosq, mqtt_conn_callback); - if (mosquitto_connect(mosq, "10.32.184.5", 1883, 60) != MOSQ_ERR_SUCCESS) + if (mosquitto_connect(mosq, "burrow-mqtt", 8883, 60) != MOSQ_ERR_SUCCESS) die("Mosquitto: connect failed"); if (mosquitto_loop_start(mosq)) @@ -254,7 +256,7 @@ static double correct_point(uint id, double val, const char **name) */ switch (id) { case 10415: - *name = "kitchen"; + *name = "terarium"; return val - 0.93; case 10707: *name = "catarium"; @@ -712,7 +714,6 @@ Options:\n\ -n, --no-fork Do not fork\n\ -p, --debug-packets Log all packets sent and received\n\ -r, --debug-raw Log conversion from raw values\n\ --u, --debug-usb Enable libusb debug messages (to stdout/stderr)\n\ -V, --version Show daemon version\n\ "); exit(1); @@ -721,7 +722,7 @@ Options:\n\ int main(int argc, char **argv) { int opt; - while ((opt = getopt_long(argc, argv, "dl:npruV", long_options, NULL)) >= 0) + while ((opt = getopt_long(argc, argv, "dl:nprV", long_options, NULL)) >= 0) switch (opt) { case 'd': debug_mode++; @@ -738,9 +739,6 @@ int main(int argc, char **argv) case 'r': debug_raw_data++; break; - case 'u': - debug_usb++; - break; case 'V': printf("arexxd " AREXXD_VERSION "\n"); printf("(c) 2011-2018 Martin Mares \n"); @@ -754,8 +752,6 @@ int main(int argc, char **argv) int err; if (err = libusb_init(&usb_ctxt)) die("Cannot initialize libusb: error %d", err); - if (debug_usb) - libusb_set_debug(usb_ctxt, 3); if (!debug_mode) { if (chdir(log_dir) < 0)