Mosquitto MQTT broker#
The simpleswitch-mosquitto
offers a demo of MQTT.
By default the broker will handle requests on port 1883 and websocket requests on port 8883.
Registration
If you want to test SimpleCore™, SimpleSwitch™ or any of our packages from our SimpleCore™ incubator program, please register here and we will grant you access.
How to get it#
## From the base image run
$ skopeo login ghcr.io
$ export machine=$CONTAINER_HELPER_ARCH
$ export package=simpleswitch-mosquitto
$ export tag=$RELEASE_VERSION
$ container-helper registry-install ghcr.io ghcr.io/avnet-embedded/simpleswitch/${machine}/${package}:${tag}
$ simpleswitch-helper start ${package}
## On your computer run
$ scotty build simpleswitch-mosquitto
## On your computer run
$ bitbake simpleswitch-mosquitto
Note
This recipe needs meta-networking
in the layer setup, if you want to build it yourself.
## On your computer run
$ scotty setup --features-layers-set simpleswitch
## On your computer run
$ bitbake-layers add-layer <path to meta-networking>
Manually publish a message#
Sometimes it might be needed to manually publish a MQTT message. For this the simpleswitch-mosquitto package does offer the tool mosquitto_pub.
To publish a message run
$ simpleswitch-helper run simpleswitch-mosquitto mosquitto_pub -t "<topic>" -m "<message>"
e.g.
$ simpleswitch-helper run simpleswitch-mosquitto mosquitto_pub -t "foo/bar" -m "1"
Check published messages#
To check the messages published by other entities use mosquitto_sub, which is available out of the same SimpleSwitch™ container.
e.g.
$ simpleswitch-helper run simpleswitch-mosquitto mosquitto_sub -t "#"
will print every message published on this broker. You can adjust the -t parameter if you only want to see specific topics
MQTTX-Web#
You can also try our MQTTX-Web SimpleSwitch™ package, which provides you a browser based application to interact with the Mosquitto MQTT broker.