Data Logger: MQTT Sink

Requirements

  • An MQTT implementation of the SinkLogger interface, using mosquitto (see below)

  • A wrapper class around the plain C struct mosquitto that can take a SensorValues instance, like

    SensorValues 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

Ubuntu
$ sudo apt install mosquitto-dev
Fedora
$ sudo dnf install mosquitto-devel

Wrapper

  • Constructor: allocate client using mosquitto_new(), and use mosquitto_connect() on it

  • Destructor: 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

Dependencies

cluster_fh2021 WS2023/24: Group Project - Tasks fh2021_datalogger (DONE) Data Logger fh2021_datalogger_mqtt_sink Data Logger: MQTT Sink fh2021_datalogger_mqtt_sink->fh2021_datalogger