You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

###Configuration###
#Enter pre-configured broker's name within "":
:local broker "pc"
#Enter the topic name within "", per the broker's configuration:
:local topic "v1/devices/me/telemetry"

###Variables####
:global lat
:global lon

###GPS####
:put ("[*] Capturing GPS coordinates...")
/system gps monitor once do={
:set $lat $("latitude");
:set $lon $("longitude");}

:local message \
"{\"latitude\":$lat,\
\"longitude\":$lon}"

###MQTT###
:if ($lat != "none") do={\
:put ("[*] Sending message to MQTT broker...");
/iot mqtt publish broker=$broker topic=$topic message=$message} else={:put ("[*] Lattitude=none, not posting anything!");:log info "Latitude=none, not posting anything!"}

  • No labels