/*
* Linux Interfece for Arexx Data Loggers
*
- * (c) 2011-2018 Martin Mares <mj@ucw.cz>
+ * (c) 2011-2020 Martin Mares <mj@ucw.cz>
*/
#include <stdio.h>
#define MAX_FUTURE_TIME 300
#define IGNORE_UNKNOWN_SENSORS
+#undef LOG_TO_RRD
+#undef LOG_TO_MQTT
+
typedef unsigned char byte;
typedef unsigned int uint;
static libusb_context *usb_ctxt;
/*** MQTT interface ***/
+#ifdef LOG_TO_MQTT
+
#include <mosquitto.h>
static struct mosquitto *mosq;
mqtt_publish(topic, "%.3f %lld", val, (long long) t);
}
+#endif
+
/*** RRD interface ***/
+#ifdef LOG_TO_RRD
+
#include <rrd.h>
#define MAX_ARGS 20
}
}
+#endif
+
/*** Transforms ***/
#define TIME_OFFSET 946681200 // Timestamp of 2000-01-01 00:00:00
}
data_point_counter++;
+#ifdef LOG_TO_RRD
rrd_point(t, name, val2, unit);
+#endif
+#ifdef LOG_TO_MQTT
mqtt_point(t, name, val2, unit);
+#endif
}
static void raw_point(uint t, uint id, int raw, int q)
use_syslog = 1;
}
+#ifdef LOG_TO_MQTT
mqtt_init();
+#endif
struct sigaction sa = { .sa_handler = sigterm_handler };
sigaction(SIGTERM, &sa, NULL);