You can then specify the "Topic" (a string used by a broker to filter messages), "Message" (the message itself), "QoS" (indicates Quality of Service level for
the message), and "Retain" (whether to retain the message or discard it) parameters.
:
note "Broker" and "Topic" field configuration is required. "Message", "QoS", and "Retain" can be optional or required - depends on how the server/broker is
set up.
MQTT with script scenario
MQTT broker can be configured with
.
Create a new script, use the template as a reference, change the parameters accordingly and run the script.
Every line that begins with a symbol " " is instructional and it describes the parameter that is going to be configured below the line. Change the parameters
#
within quotation marks "" that would apply to your specific case.
Script example:
# Required packages: iot
################################ Configuration ################################
# Name of an existing MQTT broker that should be used for publishing
:local broker "Demo Device"
# MQTT topic where the message should be published
:local topic "v1/devices/me/telemetry"
# Interface whose MAC should be used as 'Locator ID'
:local locatorIface "ether1"
# POSIX regex for filtering advertisement Bluetooth addresses. E.g. "^BC:33:AC"
# would only include addresses which start with those 3 octets.
# To disable this filter, set it to ""
:local addressRegex ""
# POSIX regex for filtering Bluetooth advertisements based on their data. Same
# usage as with 'addressRegex'.
:local advertisingDataRegex ""
# Signal strength filter. E.g. -40 would only include Bluetooth advertisements
# whose signal strength is stronger than -40dBm.
# To disable this filter, set it to ""
:local rssiThreshold ""
#################################### System ###################################
:put ("[*] Gathering system info...")
:local ifaceMac [/interface get [/interface find name=$locatorIface] mac-address]
:local cpuLoad [/system resource get cpu-load]
:local freeMemory [/system resource get free-memory]
:local usedMemory ([/system resource get total-memory] - $freeMemory)
:local rosVersion [/system package get value-name=version \
[/system package find where name ~ "^routeros"]]
:local model [/system routerboard get value-name=model]
:local serialNumber [/system routerboard get value-name=serial-number]
# Health is a bit iffy since '/system health' does not have 'find' in ROS6
:local health [/system health print as-value]
:local supplyVoltage 0
:local boardTemp 0
:foreach entry in=$health do={
:if ($entry->"name" = "voltage") do={:set $supplyVoltage ($entry->"value")}
:if ($entry->"name" = "board-temperature1") do={:set $boardTemp ($entry->"value")}
}