GpsGate Server Protocol
GpsGate Server Protocol
GpsGate Server Protocol
Introduction
This document describes communication between a GPS tracker client and server. The main purpose is position
updates, status messaging, track reports and configuration. Software and hardware developers are encouraged to
use this protocol to integrate with GpsGate.com and GpsGate Server.
Communication can be made over TCP/IP, UDP and HTTP. Full functionality is achieved over TCP/IP.
The protocol can be used with GpsGate Server and GpsGate.com. The address to GpsGate.com is
online.gpsgate.com port 30175 (port 80 for HTTP).
All sentences should always be followed by a NMEA checksum and carriage return + line feed “\r\n”. See
Appendix 1 for an example algorithm to calculate the checksum.
GpsGate Server also supports JSON & XML/SOAP based web services which aren't covered in this document.
Please read more here:
http://gpsgate.com/index.php?id=47
Sample sentence:
$FRLIN,,user1,8IVHF*7A
Sample sentence:
$FRLIN,IMEI,1234123412341234,*7A
You need to create a device in the GpsGate Web interface for a specific user. This will connect a user to an IMEI
number.
Error message
Error message. Will be returned from server on failed login. The server can also simply close the connection if
some kind of error or time-out condition occur.
Syntax:
$FRERR,err_code,err_message*XX
Sample sentence:
$FRERR,AuthError,You have provided wrong username or password*18
username The username in the buddy list to receive position data from. Or "_buddies" to get data from
all the users buddies.
Username can be either one user or the buddy list. Depending on the value of “username” the following actions
are taken:
One user: An GPRMC sentence is sent right away from server with latest known position, and the UTC time
when that position was reported.
"_buddies": An FRPOS sentence is sent right away from server for each user with known position with latest
known position, and the UTC time when that position was reported.
Notes:
Data is not sent back to the client faster than the interval specified.
Data is not sent if the position hasn't been updated.
If there is any error, the socket is closed.
datatype Can be "ALL" or "NMEA". If ALL, then all data will be passed through unfiltered. If NMEA
only $GPRMC data is accepted.
Sample sentence:
$FRWDT,NMEA*78
02 <N|S> Hemisphere N or S
04 <E|W> Hemisphere E or W
08 DDMMYY date
Sample sentence:
$FRPOS,6311.64120,N,01438.02740,E,0.0,0.000,0.0,270707,154403.000,Johan*18
09 DDMMYY Date
Sample sentence:
$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A
Note: If the checksum is wrong, there will be no response at all from the server.
Client Server
FRLIN
FRSES
FRRDT
GPRMC
GPRMC
...
Client Server
$FRLIN,,user1,8IVHF*7A
$FRSES,1221568*46
$FRRDT,johan,10.0*2B
$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A
New GPRMC sentences will be sent from server when user "johan" updates his position, but not more often than
every 10 seconds as specified in the second field of FRRDT. In this example user “user1” receives data from
user “johan”. You can also read data from the same user that logs in.
Client Server
FRLIN
FRSES
FRRDT
FRPOS
FRPOS
...
Client Server
$FRLIN,,user1,8IVHF*7A
$FRSES,1221640*4F
$FRRDT,_buddies,10.0*7E
$FRPOS,6311.64120,N,01438.02740,E,0.0,0.000,0.0,270707,154403.000,Johan*18
$FRPOS,5920.71451,N,01803.28481,E,0.0,0.000,0.0,020707,222402.000,user1*50
New FRPOS sentences will be sent from server as users in your buddy list update their positions, but not more
often than every 10 seconds as specified in the second field of FRRDT.
Client Server
FRLIN
FRSES
FRWDT
GPRMC
GPRMC
...
Client Server
$FRLIN,,user1,8IVHF*7A
$FRSES,1221640*4F
$FRWDT,NMEA*78
$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A
$GPRMC,154423.000,A,6311.64143,N,01438.02743,E,0.000,0.0,270707,,*0C
...
Client Server
$FRLIN,IMEI,1234123412341234,*7B
$FRSES,1221640*4F
$FRWDT,NMEA*78
$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A
$GPRMC,154423.000,A,6311.64143,N,01438.02743,E,0.000,0.0,270707,,*0C
...
Client
FRLIN
GPRMC
Client
$FRLIN,,user1,8IVHF*7A
$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A
Client
$FRLIN,IMEI,1234123412341234,*7B
$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A
or using IMEI
longitude=34.2333&latitude=23.2222&altitude=34.0&speed=30.3&heading=234.5&d
ate=20070529&time=123445.234&imei=123456789012345
pw The password specified with a simple encryption. The encryption/decryption algorithm can be
found in Appendix 2
$FRVER,major,minor,name_and_version*XX
name_and_version Name of peer sending this message. E.g. "TestClient 1.0". This should always be a
name followed by a version number.
Note! Here you should have the real name of your client plus the version number.
Example:
Client Server
$FRLIN,,user1,8IVHF*7A
$FRSES,1221640*4F
$FRVER,1,1,TestClient 1.0*79
$FRVER,1,1,GpsGate Server 1.1.0.360*04
Command structure
This structure is used when sending messages to execute commands. Messages can be sent from server to client
and client to server. Several commands can be executed between client and server in one session.
Command Sentences
Syntax:
$FRCMD,username,command,Nmea,size*XX
Syntax:
$FRCMD,username,command,Inline,param1,param2,...,paramN*XX
Inline indicates that the rest of the fields in the sentence are arguments to the command.
Example:
$FRCMD,,_getupdaterules,Inline*1E
Return values
A return value is sent as a reply to an executed command.
Syntax:
$FRRET,username,command,Nmea,size*XX
username User which executed the original FRCMD to which this is an answer.
Example:
$FRRET,Johan,_getupdaterules,Nmea,4*43
$FRVAL,DistanceFilter,500.0*67
$FRVAL,TimeFilter,60.0*42
$FRVAL,DirectionFilter,40.0*30
$FRVAL,DirectionThreshold,10.0*42
or
Syntax:
$FRCMD,username,command,Inline,param1,param2,...,paramN*XX
Inline indicates that the rest of the fields in the sentence are arguments to the command.
Command Variables
Sentence which holds a variable. Is typically used in combination with FRCMD and FRRET
Syntax:
$FRVAL,name,value*XX
Example:
$FRVAL,DistanceFilter,500.0*67
Error handling
If a command for some reason cannot be executed FRERR is returned and not FRRET. The reason can be that
the there is some kind of execution error, the command is not supported, or there is a protocol error. When
FRERR is returned the client should assume no data has been affected on the server. The protocol is transaction
based.
In all cases expect when there is a protocol or connection error the exchange of commands can continue between
the server and the client.
Interrupted commands
If several FRCMD is sent without the previous one being finished, the peer executing the command should roll
back the current command and start executing the new command. Example: If two FRCMD is received in a row,
the last FRCMD should be executed.
Commands
A client or server supporting GpsGate Server Protocol v1.1 shall support the framework of sending commands
using FRCMD + FRRET as described above. But it does not need to support any specific commands.
If a peer tries to execute a command that isn't supported FRERR with err_code “NotSupported” should be
returned.
Below are some commands supported by GpsGate Server listed.
_getupdaterules
GpsGate Server v1.1 build 360 and later.
The command “_getupdaterules” is used by a client to ask server for recommended intervals to send position
updates to the server.
The values typically include distance interval, time interval, speed and direction changes.
The rules should be OR:ed by the client. Rules not understood should simply be ignored.
Sample communication:
Client Server
$FRCMD,,_getupdaterules,Inline*1E
$FRRET,Johan,_getupdaterules,Nmea,4*43
NOTE!
1. The number of sentences following FRRET can be 0 to many.
2. The 4th field "4" in FRRET determines that there are 4 sentences following FRRET.
3. The answer may contain zero or many FRVAL sentences, and zero or many other sentences.
DistanceFilter Distance in meters before a new position update should be sent to server.
SpeedFilter Change in speed in meters per second, before a new position update should sent
to server by client.
DirectionFilter Change of heading in degrees, before a new position update should be sent.
Notes:
The rules should be "OR:ed".
Rules that are inactivated will not be sent back to the client.
Rules that are not understood by the client should simply be ignored.
The rules are recommendations from the server, so the server will also be able to handle position updates not
following the rules.
More rules will be added in coming versions.
Example that demonstrates how a client logs into a server, ask for recommended update rules and then starts
sending position updates to server according to rules.
Client Server
$FRLIN,,user1,8IVHF*7A
$FRSES,1221640*4F
$FRVER,1,1,TestClient 1.0*79
$FRVER,1,1,GpsGate Server 1.1.0.360*04
$FRCMD,,_getupdaterules,Inline*1E
$FRRET,User1,_getupdaterules,Nmea,2*07
$FRVAL,DistanceFilter,500.0*67
$FRVAL,TimeFilter,60.0*42
_SendPosition
GpsGate Server 1.2 build 410 or later
The command “_SendPosition” is used to send a position update for the logged in user. You can control which
track to save the position to, or if the position should not be saved to any track at all. The users current position
will be updated, and the position information will be routed to other users that listens using FRRDT.
Syntax:
$FRCMD,username,_SendPosition,Nmea,1,track_recorder_id*XX
$FRPOS...
username The logged in user. This field can be empty.
Nmea Indicates we have an NMEA sentence following the FRCMD sentence. Should
be “Nmea”
XX NMEA checksum
Sample communication:
In this sample the client has logged in as “User1”. The current position is updated for the user, and the default
track – the “life track” - is updated.
Client Server
$FRCMD,,_SendPosition,Nmea,1*12
$FRPOS,0200.00000,N,00100.00000,E,
0.0,5.832,4.0,121107,142600.000,*5
D
$FRRET,User1,_SendPosition,Inline*08
_CreateTrackRecorder
GpsGate Server 1.2 build 383 or later
track_name Name of track recorder. Tracks created by this track recorder will get this
name.
Sample communication:
This sample creates a new track recorder named “TestTrack” for the logged in user. The server returns the track
recorder id “2”.
Client Server
$FRCMD,,_CreateTrackRecorder,Inlin
e,TestTrack*00
$FRRET,User1,_CreateTrackRecorder,Inlin
e,2*42
_SaveTrackData
GpsGate Server 1.2 build 383 or later
Nmea Indicates we have an NMEA sentence following the FRCMD sentence. Should
be “Nmea”
position_count Number of FRPOS sentences following the FRCMD sentence. Each FRPOS
sentence represents one position to be saved into the server track recorder. Do
not send more than twenty (20) FRPOS sentences at a time.
The server may or may not refuse larger transactions.
XX NMEA checksum
Sample communication:
This sample saves two positions for the logged in user to a track recorder created by
“_CreateTrackRecorder” (see above). The user name in FRPOS can be left out to save bandwidth.
Client Server
$FRCMD,,_SaveTrackData,Nmea,2,2*54
$FRPOS,0100.00000,N,00100.00000,E,
0.0,1.944,0.0,011206,120000.000,*5
C
$FRPOS,0200.00000,N,00200.00000,E,
0.0,3.888,0.0,011206,120002.000,Us
er1*5D
$FRRET,User1,_SaveTrackData,Inline*53
// buf is a char[] array which contains the NMEA sentence without trailing
checksum.
// E.g. "$FRLIN,,user1,8IVHF" and "*7A" will be added
int checksum = 0;
int inx;
buf[buf_inx++] = '*';
buf[buf_inx++] = NIBBLE2HEX((checksum >> 4) & 0xf);
buf[buf_inx++] = NIBBLE2HEX(checksum & 0xf);
if (strToInvert != null)
{
builder = new StringBuilder();