pub-MQTT

The pub-<MsgEnv> for Windows. The ME is an MQTT broker, reached through the Eclipse Mosquitto client library.

Repository

https://gitlab.com/industry-of-integrations/pub-MQTT

Wrapper library

https://github.com/IPSME/cpp-msgenv-MQTT

USAGE: pub-MQTT <0|1> <message>

What it does

  1. Initialises the Mosquitto library and creates an IPSME_MsgEnv, which connects to the broker.

  2. Subscribes a handler to the ME.

  3. Publishes <message> and processes what has arrived so far.

  4. Loops in steps of 100 ms, processing messages each step. With 0 it takes ten steps, about one second, and exits; with 1 it prints Running …​ and loops until stopped with ^C, writing a progress dot to stderr every few seconds.

Every message heard is printed to stdout as handler_1_: Received message: …​. The tool’s own message comes back and is printed like any other; there is no referer filtering here.

On the wire

Broker

localhost, port 1883

Topic

IPSME

QoS

0, not retained

Payload

the string, as the message body

A broker must be running on localhost before the tool starts, or the connection fails. Mosquitto is what it has been tested against.

Source and build

The repository is a Visual Studio 2022 solution (pub-MQTT.sln, x64); the tool is pub-MQTT.cpp. The wrapper library cpp-msgenv-MQTT comes in as a git submodule and provides IPSME_MsgEnv (subscribe(), publish(), process_msgs()). It keeps one Mosquitto client for subscribing and one for publishing.

Build dependencies are the Mosquitto devel headers and mosquitto.lib. At run time mosquitto.dll, libssl-3-x64.dll and libcrypto-3-x64.dll must sit beside pub-MQTT.exe or on PATH; the Release build copies them next to the executable.