Summary
MQTT is an open OASIS and ISO standard lightweight, publish-subscribe network protocol that transports messages between devices. You can find more information about the MQTT protocol following the link.
Configuration
Sub-menu: /iot mqtt
note: iot package is required.
IoT package is available with RouterOS version 6.48.3. You can get it from our download page - under "Extra packages".
You can find more application examples with MQTT and our KNOT product following this link.
Broker
To add a new broker, run the following command:
[admin@device] /iot mqtt brokers add
Configurable properties are shown below:
Property | Description |
---|---|
address (IP|hostname; Default: ) | IP address or hostname of the broker |
certificate (string; Default: ) | The certificate that is going to be used for the SSL connection |
client-id (string; Default: ) | A unique ID used for the connection. The broker uses this ID to identify the client. |
name (string; Default: ) | Descriptive name of the broker |
password (string; Default: ) | Password for the broker (if required by the broker) |
port (integer:0..4294967295; Default: 1883) | Network port used by the broker |
ssl (yes | no; Default: no) | Secure Socket Layer configuration |
username (string; Default: ) | Username for the broker (if required by the broker) |
Publish
Property | Description |
---|---|
broker (string; Default: ) | Select the broker where to publish the message |
message (string; Default: ) | The message that you wish to publish to the broker |
qos (integer:0..4294967295; Default: 0) | Quality of service parameter, as defined by the broker |
retain (yes | no; Default: no) | Whether to retain the message or to discard it if no one is subscribed to the topic. This parameter is defined by the broker. |
topic (string; Default: ) | Topic, as defined by the broker |
An example of MQTT publish would look like this:
[admin@device] /iot mqtt> publish broker=x topic=y message=z
where x is an actual broker's name that was configured in the broker section, y is a topic (as it is configured on the server-side/on the broker itself) and z is the message you wish to publish (retain and qos parameters are optional - both are defined by the broker).