GPS http send to GpsGateServer script

Hello
I manage to setup LtAP and GpsGate Server to communicate and server recive cordinate. Problem is that all work manually when I input all parametars in fetch comman
Format for Server is:
http://IPADDESS:PORT/GpsGate/?$FRCMD,IMEI,_SendMessage,latitude,hemi,longitude,hemi,alt,speed,heading,date,time,valid
So command on MT is:
/ tool fetch mode=http url=“http://192.168.88.85:8008/GpsGate/?cmd=$FRCMD,1234567890,_SendMessage,4450.39978,N,2024.35196,E,97.5,0,07,210718,222518,1” keep-result=no

In this format it work with no problem. So I like to do script to TAKE needed value from MT, and put in in fetch command to automate process

Where is from MT:
IMEI - 1234567890
Latitude - N 44 50’ 39.972"
Longitude - E 20 24’ 35.190"
Altitude - 97.5
Speed - 0,07
Date - 210718
Time - 222512
Valid Fix - 1

I am not good in scripting to make this script :frowning:

So any help is needed

Thank you

Hi,

Have you already been able to make a script that works with GpsGate? I’m interested too and have bought a LtAP LTE + external GPS antenna for testing in one of our vans.
If it’s working fine we’ll use it for tracking our vehicles and also providing WiFi Internet through LTE for the built-in Android tablets & navigation purposes.

And when it’s working great, we’ll suggest it to our customers :smiley:

Yes, but work only if I put manual value on it.
I want to make script that do the jub auto, take “log” and “lat” and “speed”, put value in sitax which is needed to be send to GSPGate.
If I make script and I write this value, after run command I see position on GPS Gate server
/tool fetch mode=http url=“http://192.168.88.85:8008/GpsGate/?cmd=$FRCMD,1234567890,_SendMessage,4450.39,N,2024.35,E,97.5,0,07,210718,222518,1*65” keep-result=no

This script work, but value for log, alt and speed need to be taken direct from ROS and put in script. That part I can’t do, don’t know how. Problem for me is that this value can’t be taken like $[system gps get longitite]

I have just set up a LtAP Mini (LTE) in place of my old TK103B gps tracker.
A friend found this thread when I mentioned I was looking into it, and your post pointed me in the right direction, so thanks!

Using GpsGate’s, and MikroTik’s documentation, I put together two scripts. A script to run on the LtAP, and a PHP script to convert the data.
I have the PHP script on the GpsGate server after adding PHP to IIS.

RouterOS does not play nice with decimal numbers, so converting Lat&Lon on the LtAP became a dead end for me, not for the lack of trying. Even MikroTik’s documentation passes the data on to a PHP script to convert it.

IMO these are not finalised and I have work to do, but they work well enough for now.

Script to run on LtAP (I have it scheduled to run every 15 seconds)

php

:local server “domain_or_ip/gps.php”
:local port “80”

get imei

:global lteimei
/interface lte info lte1 once do={:set $lteimei $(“imei”)}

get gps data

:global datetime
:global lat
:global lon
:global alt
:global spd
:global bear
:global val
/system gps monitor once do={
:set $datetime $(“date-and-time”)
:set $lat $(“latitude”)
:set $lon $(“longitude”)
:set $alt $(“altitude”)
:set $spd $(“speed”)
:set $bear $(“true-bearing”)
:set $val $(“valid”)
}

months array

:local months (“jan”,“feb”,“mar”,“apr”,“may”,“jun”,“jul”,“aug”,“sep”,“oct”,“nov”,“dec”);

convert name of month to number

:local month ([ :find $months ([:pick $datetime 0 3]) -1 ] + 1);
:if ($month < 10) do={:set month (“0” . $month);}

manipulate date time

:local date ([:pick $datetime 4 6] . $month . [:pick $datetime 9 11]);
:local time ([:pick $datetime 12 14] . [:pick $datetime 15 17] . [:pick $datetime 18 20]);

send gps data to php

tool fetch mode=http url=“http://$server” port=$port http-method=post
http-data=(“{
"imei":"” . $lteimei . “",
"lat":"” . $lat . “",
"lon":"” . $lon . “",
"alt":"” . $alt . “",
"spd":"” . $spd . “",
"bear":"” . $bear . “",
"date":"” . $date . “",
"time":"” . $time . “",
"val":"” . $val . “"
}”)
http-content-type=“application/json”
PHP script for data conversion, then passes on to Gpsgate

<?php // gpsgate server $server = "127.0.0.1"; $port = "8008"; // Converting DMS ( Degrees / minutes / seconds ) to DMM (NMEA) function DMStoDMM($deg,$min,$sec) { //return $deg+((($min*60)+($sec))/3600) return $deg.($min+(($sec)/60)); } function KMHtoKNOT($spd) { //return (($spd)/1.852) return (($spd)/1.852); } // get input $raw = file_get_contents('php://input'); $data = json_decode($raw); // check input for all data if (!empty($data) && is_object($data) && property_exists($data,'imei') && property_exists($data,'lat') && property_exists($data,'lon') && property_exists($data,'alt') && property_exists($data,'spd') && property_exists($data,'bear') && property_exists($data,'date') && property_exists($data,'time') && property_exists($data,'val')){ // clear variables $imei = $lat = $lon = $alt = $spd = $bear = $date = $time = $val = ''; // set imei $imei = $data->imei; // the below section splits DMS coordinates apart and converts them to DMM (NMEA) format via above function if(preg_match('/^(N|E|W|S)\ (\d+)\ (\d+)\'\ (\d+\.\d+)/',$data->lat,$result)){ $lat = DMStoDMM($result[2], $result[3], $result[4]); $lathem = $result[1]; } // the below section splits DMS coordinates apart and converts them to DMM (NMEA) format via above function if(preg_match('/^(N|E|W|S)\ (\d+)\ (\d+)\'\ (\d+\.\d+)/',$data->lon,$result)){ $lon = DMStoDMM($result[2], $result[3], $result[4]); $lonhem = $result[1]; } // the below section splits Altitude and removes 'm' if(preg_match('/^(\d+)\.(\d+)/',$data->alt,$result)){ $alt = $result[1].".".$result[2]; } // the below section converts Speed to Knots via above function if(preg_match('/^(\d+)\.(\d+)/',$data->spd,$result)){ $spd = $result[1].".".$result[2]; if(!$result[1] == "0"){ $spd = KMHtoKNOT($spd); } else { $spd = "0.00"; } } // the below section splits Bearing and removes 'deg. True' if(preg_match('/^(\d+)\.(\d+)/',$data->bear,$result)){ $bear = $result[1].".".$result[2]; } // set date $date = ($data->date); // set time $time = ($data->time); // the below section converts Valid to 1 (true) or 0 if(($data->val) == "true"){ $val = "1"; } else { $val = "0"; } // return data to source (mikrotik file gps.php), disable if not wanted echo("IMEI: $imei\nLatitude: $lat\nLatitude Hemisphere: $lathem\nLongitude: $lon\nLongitude Hemisphere: $lonhem\nAltitude: $alt (m)\nSpeed: $spd (Knots)\nBearing: $bear (Deg.)\nDate: $date\nTime: $time\nValid: $val\ncURL: http://$server:$port/GpsGate/%3Fcmd=%24FRCMD,$imei,_SendMessage,,$lat,$lathem,$lon,$lonhem,$alt,$spd,$bear,$date,$time,$val\n\n"); $url = "http://$server:$port/GpsGate/%3Fcmd=%24FRCMD,$imei,_SendMessage,,$lat,$lathem,$lon,$lonhem,$alt,$spd,$bear,$date,$time,$val"; $ch = curl_init($url); $result = curl_exec($ch); curl_close($ch); echo("$result"); } ?>

I hope this helps you, if you are still wanting to get it working.

Hey man, thank you, I am not good in scripting BUT I NEED this

First script is on LTAP run avery 15sec, and second (php) is in GPS gate server ?

How you setup GPS gate for this, any screenshot ? :slight_smile:
Did you test it, is it work good ? Can be used on more fore LtAP sending data to same GPS Gate ?

Plese, send me your e-mail, for contact, if you want. I need this feature. JI have few question
my contact: nemke. petrovic @ gmail. com

Especially after releasing hardware with built in GPS like the LTAP it should be apparent that the GPS package needs some attention. Mikrotik needs to devote a couple hours to the GPS package and output the data in a usable format that does not require a middleman server to convert the Mikrotik data to an acceptable format for use with the API world.

You are right. We already have this in our ToDo, and will try to make it, now that LtAP mini exists.

Excellent news Normis! Supports response via email a while back was not that positive at all. Glad to hear its in the ToDo list.

Hi,
The reason I did not go into detail with running the PHP script within GpsGate is that by default, GpsGate uses IIS Express for it’s web server, and adding PHP functionality is not easy.
I use GpsGate with full IIS (OS: Windows Server Standard 1803 (Core)), and adding PHP to IIS is well documented.

You’re best option may be to run a separate web server, something like XAMPP if using Windows, and have the PHP script served there.

In the first script (LtAP), the following (below) must be updated to point to the web server serving the PHP script.

php

:local server “domain_or_ip/gps.php”
:local port “80

In the PHP script, the following (below) must be updated to point to the GpsGate server.
// gpsgate server
$server = “127.0.0.1”;
$port = “8008”;

I am actively using the LtAP in my vehicle, and it is working for me. It is not perfect, but as I said previously, it’s working well enough for now.
I have seen two events where the GPS data has put me half way around the world and back in 30 seconds. I plan to review the data GpsGate has from when this happened and figure out why.

+1000 for that
LtAP is hard to use in any GPS server (GPS Gate or GPSVox), http post format (fetch in MT) is not good “supported” in GPS world. So you are right middleman server of format/sintax modification are needed and that is problem for speed and eficient.

Please simply use the external antenna, if it works good for you. The built in antenna needs improvement, as it currently only works best if LtAP ports are facing up, and there is no LTE modem inside.

External antenna for LtAP GPS works great. I haven’t used external antennas for the LTE yet as it seems to work great with the built in antennas for the current application.

Any news on this?

A nice worked out example to use the unit in a tracking plotter would be nice.
Although I have a bit of understanding of ROS is haven’t got a glue how to use the LtAP mini to track my vehicle.
Don’t even know where to start apart from reading the wiki which leaves me clueless…

RouterOS can already output other coordinate formats. This topic is no longer accurate.

Tried the format=dd in the script but still fails. I believe the script cannot handle negative coordinates. So if you have a Long of -117.1234, the add to the db fails.. then you get good ole Null Island. Any thoughts Normis?

Thumbs up for this one, and bumping this thread as I could sell LtAP mini like sandwiches in Paris. But as long as there nothing stable… I can’t.

Recently we fixed negative coordinates, is the issue still there ?