How to setup Mikrotik device in Onebrella

Step 1. Preparing the Device.

Make sure your Mikrotik device has GPS hardware that is enabled and working. Set GPS format in RouterOS to "dd". Find your Mikrotik device IMEI and ID (to be used in the below scripts). Make sure your Mikrotik device is connected to the Internet. To make the device send the GPS coordinates automatically to the server, you need to use the script as below.

Step 2.

Go to your Mikrotik device menu "System" > "Script". Create a new script and add the code below(using your device's IMEI and ID):

 
:local serverurl "198.244.179.168";
:local serverport "7737";
:local imei "3556XXXXXXXXXXX";
:local id "D729XXXXXXXX";

:global Lat
:global Lon
:global Altitude
:global Bearing
:global Speed
:global Satellites
:global Valid

/system gps monitor once do={
:set $Lat $("latitude")
:set $Lon $("longitude")
:local altitudetxt $("altitude")
:set $Altitude [:pick $altitudetxt 0 5]
:local bearinval $("true-bearing")
:set $Bearing [:pick $bearinval 0 9]
:local speedtxt $("speed")
:set $Speed [:pick $speedtxt 0 8]
:set $Satellites $("satellites")
:set $Valid $("valid")
}

:local longdegree;
:set longdegree "+";
:local latdegree;
:set latdegree "+";

:set Lon ($longdegree . $Lon);
:set Lat ($latdegree . $Lat);


:log info message="GPS Script: Posting update. lat=$Lat, lon=$Lon altitude=$Altitude speed=$Speed course=$Bearing satelites=$Satellites gps=$Satellites valid=$Valid";

:do {/tool fetch keep-result=no check-certificate=no url=("http://" . $serverurl . ":" . $serverport ."/\?id=$id&imei=$imei&lat=$Lat&lon=$Lon&altitude=$Altitude&speed=$Speed&course=$Bearing&satelites=$Satellites&gps=$Satellites&valid=$Valid")
} on-error={:log error message="Fetch failed..."}

:log info message="GPS Script: Posting update DONE";

Step 3.

Go to your Mikrotik device menu "System" > "Scheduler". Create a new Scheduled job, specifying the execution frequency (for example every 00:05:00 minutes or so). In the field "On Event" type the name of the script you have created previously. Save and you should be good to go!

Step 4.

Create your Object at the Onebrella server. Make sure you have a Onebrella account. Go to the menu "Object" and select "Create Object". Choose for Category "Protocol", for Type "Mikrotik", type your device's IMEI and give it a name. Wait a few seconds to see your device connected.

Created by Onebrella partner in Greece - Harris A. email: harris@vialatm.com