Data Logger: MQTT Sink¶
Requirements¶
An MQTT implementation of the
SinkLogger
interface, usingmosquitto
(see below)A wrapper class around the plain C
struct mosquitto
that can take aSensorValues
instance, likeSensorValues v = sensor_config.getAllMeasurements(); // ... Mosquitto client("localhost", 1883 /*default MQTT port*/); client.publish(v);
A definition of the MQTT transport format in JSON, like
{ "sensor1": 37.5, "sensor2": 42.666 }
Write unit tests to define the format
Implementation¶
MQTT Implementation: mosquitto
¶
Cross development is a burden, especially when you do C++ with a
handmade Raspberry toolchain. mosquitto
is written in pure C.
Installation¶
$ sudo apt install mosquitto-dev
$ sudo dnf install mosquitto-devel
Wrapper¶
Constructor: allocate client using
mosquitto_new()
, and usemosquitto_connect()
on itDestructor:
mosquitto_destroy()
Prohibit copy
Testing¶
Unit test for JSON format
Sample publish program using the wrapper class, in
bin/
Future (Not Part Of This Development Cycle)¶
The wrapper class will become more widely available when the boiling pot ((DONE) Boiling Pot (The Beginning)) goes IoT. The pot will broadcast “switch-on”/”switch-off” events and temperature measurements (it only has a single sensor, the temperature of the pot itself) - will need a more flexible input than just
SensorValues