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

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

Many RouterOS devices have GPS support. It allows RouterOS to determine the precise location of its GPS receiver. GPS coordinates will indicate latitude and longitude values of the current position.

Let's say, you have LTAP (or any other device with GPS support) and you wish to track its location.




###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