User Manual
Table Of Contents
#################################### MQTT #####################################
:local message \
"{\
\"clientId\":\"$[/iot mqtt brokers get value-name=client-id \
[/iot mqtt brokers find name=$broker]]\",\
\"t\":0,\
\"v\":1,\
\"OldestAdvertisementTimestamp\":$btOldestAdvertisementTimestamp,\
\"locs\":[{\
\"id\":\"$[$minimizeMac address=$ifaceMac]\",\
\"tags\":[$advJson],\
\"ed\":{\
\"model\":\"$model\",\
\"sn\":\"$serialNumber\",\
\"ros\":\"$rosVersion\",\
\"cpu\":$cpuLoad,\
\"umem\":$usedMemory,\
\"fmem\":$freeMemory,\
\"psu\":$supplyVoltage,\
\"temp\":$boardTemp\
}\
}]\
}"
:log info "$message";
:put ("[*] Total message size: $[:len $message] bytes")
:put ("[*] Sending message to MQTT broker...")
/iot mqtt publish broker=$broker topic=$topic message=$message
:put ("[*] Done")
To run this script, the Broker should be pre-configured:
For example, only requires settings that are shown in the screenshot above. When you successfully configure the broker, the only thing that thingsboard
needs to be changed in the script is:
:local broker "Demo Device"
line, where you should specify the broker's name within the quotation marks "".
Another line that should be taken into account is:
:local topic "v1/devices/me/telemetry"
, where you should specify the topic.