pub-MQTT
The pub-<MsgEnv> for Windows. The ME is an MQTT broker, reached through the Eclipse Mosquitto client library.
Repository |
|
|---|---|
Wrapper library |
USAGE: pub-MQTT <0|1> <message>
What it does
-
Initialises the Mosquitto library and creates an
IPSME_MsgEnv, which connects to the broker. -
Subscribes a handler to the ME.
-
Publishes
<message>and processes what has arrived so far. -
Loops in steps of 100 ms, processing messages each step. With
0it takes ten steps, about one second, and exits; with1it printsRunning …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 |
|
|---|---|
Topic |
|
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.