Nothing Special   »   [go: up one dir, main page]

GPRS Vehicle Tracker Protocol - 34

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

GPS&GMS/GPRS Vehicle tracker protocol

GPS/GPRS Tracker Protocol


(V1.21 for NR024)

Noran International technology


CO.,Limited

------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

The protocol is applied for our GPS vehicle tracker products.

It adopts UDP connection to connect Tracker and GPRS_SERVER,there are

2 types:

1. TRACKER transmits to GPRS_SERVER, message format is:Message

head + message body,

GPRS_SERVER transmits to TRACKER,message format is:Message head

+ message body +message end signal

1. Message list

1.1Shake_hand Request

Tracker send to server, server will save the last IP and port of tracker, it will use the IP and Port while
server send command to tracker;
CMD_ShakeHandReq 0x0000
No. Field TYPE Length description
1 packetLen short 2 Length of packet
2 CMD short 2 0x0000
3 sUserID char 11 Device ID
Data sample:
0f 00 00 00 4e 52 30 39 47 30 32 34 38 32 00
Decode the data:
0f 00 nPackLen = 0x000f (15byte)
00 00 nFlag = 0x0000
4e 52 30 39 47 30 32 34 38 32 00 deviceID: (NR09G02482)

1.2Response of Shake hand

Tell the tracker that server has received the shake hand message
No. Field TYPE Length description
1 sMark char 6 Flag of message (\r\n*KW\0)
2 packetLen short 2 Message Length
3 CMD short 2 0x8000
------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

4 cErrorCode char 1 Status=0x00


5 sEnd char 2 message end "\r\n"

1.3 Upload position Message Request

Tracker will upload the position message pre interval second that user set ,the interval will be
change to 10times when engine is off , For example:if the interval is 30s, tracker will upload the
position data pre 30s while engine is on(ACC is ON) , it will upload the position data pre 300s when the
engine is off( ACC is off)

No. Field TYPE Length description


1 packetLen short 2 Message length
2 CMD short 2 0x0008
3 bEnable unsigned char 1 Status:
0bit is locating
1bit Main power
;2,3,4,5bit is NULL;
6bit ACC status ;
7bit poff
4 bAlarm unsigned char 1 Default 0x80
SOS alarm:0x81
overSpeed alarm:0x82
geo_fence alarm :0x83
Main Power cut alarm:0x89
Pin8 alarm: 0x8f
5 nSpeed char 1 Speed
6 nDirection short 2 Direction angle
7 fLongitude float 4 Longitude
8 fLatitude float 4 Latitude
9 nDateTime long 4 Date
10 sUserID char 11 Device ID
11 nIOState char 1 I/O status
12 nOilState char 1 Value of Fuel
Tracker send to server data sample:
22 00 08 00 C3 80 00 77 00 23 E3 C8 42 0A DA 5C 41 CD 85 CA 34 4E 52 30 39 47 30 34 37 39 38 00
00 00
Decode the data one by one byte:
22 00 nPackLen = 0x0022= 34byte
08 00 commandID=0x0008
C3  bEnable
80 nAlarm
00 nSpeed

------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

77 00 nDirection
24 03 58 40 -->Long = 3.37519
65 4B D0 40 -->lat = 6.50920
2E F5 F8 32 -->data and time=2012-11-28 15:20:46 (YYYY-MM-DD HH:MM:SS)
4E 52 30 39 47 30 34 37 39 38 00 deviceID:NR09G04798
00 nIO
00 nOil
Note:
nDateTime has compress to 4BYTE (32bit)
26~31bit Year
22~25bitmonth
17~21bitday
12~16bitHour
6~11bit Minite
0~5bit second

void GetTimestring(long nDateTime, char* sDateTime)


{
long ndate = 0;
ndate = nDateTime>>26;//year
sDateTime[0] = ndate/10 +'0';
sDateTime[1] = ndate%10 +'0';
sDateTime[2] = '-';
ndate = nDateTime>>22&0x0f;//month
sDateTime[3] = ndate/10 +'0';
sDateTime[4] = ndate%10 +'0';
sDateTime[5] = '-';
ndate = nDateTime>>17&0x1f;//day
sDateTime[6] = ndate/10 +'0';
sDateTime[7] = ndate%10 +'0';
sDateTime[8] = ' ';

ndate = nDateTime>>12&0x1f;//hour
sDateTime[9] = ndate/10 +'0';
sDateTime[10] = ndate%10 +'0';
sDateTime[11] = ':';
ndate = nDateTime>>6&0x3f;//minute
sDateTime[12] = ndate/10 +'0';
sDateTime[13] = ndate%10 +'0';
sDateTime[14] = ':';
ndate = nDateTime&0x3f;//second
sDateTime[15] = ndate/10 +'0';
sDateTime[16] = ndate%10 +'0';
sDateTime[17] = 0;

------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

1.4 Upload the alarm Message Request(TrackerServer)

If the alarm has been trigger, it will upload alarm message to server,
No. Field TYPE Length description
1 packetLen short 2 Message length
2 CMD short 2 0x0003
1 bEnable unsigned char 1 Status:
0bit is locating
1bit Main power
;2,3,4,5bit is NULL;
6bit ACC status ;
7bit poff
2 bAlarm unsigned char 1 Default 0x80
SOS alarm:0x81
overSpeed alarm:0x82
geo_fence alarm :0x83
Main Power cut alarm:0x89
Pin8 alarm: 0x8f
3 nSpeed char 1 Speed
4 nDirection short 2 Direction angle
5 fLongitude double 4 Longitude
6 fLatitude double 4 Latitude
7 nDateTime long 4 Date
8 sUserID char 11 Device ID
9 nIOState char 1 I/Ostatus
10 nOilState char 1 Value of fuel

1.5 Control command by GPRS(servertracker)

Server can sent command to tracker to get the realtime position , and server can send other command to
set the other parameter by this command, you only modify the string of sData
No. Field TYPE Length description
1 sMark char 6 Flag of message (\r\n*KW\0)
2 packetLen short 2 Message Length
3 CMD short 2 0x0002
4 nGisIp int 4 GIS User client IP
5 nPort short 2 GIS User client port

------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

6 sData Char 50 Appendix A

7 sEnd char 2 message end "\r\n"

1.6 Response of control Message(TrackerServer)

CMD_CommandResp 0x8009
No. Field TYPE Length description
1 packetLen short 2 Message Length
2 CMD short 2 0x8009
3 nGisIp int 4 GIS User IP
4 nPort Unsigned int 2 GIS User ID
5 bEnable unsigned char 1 Status 0 is locating ;
1bit main power;
2,3,4,5bit NULL;
6bit ACC status;
7pOff
6 bAlarm unsigned char 1 0x80;
7 nSpeed char 1 Speed
8 nDirection short 2 Direction angle
9 fLongitude float 4 Longitude
10 fLatitude float 4 Latitude
11 nDateTime long 4 Date
12 sUserID char 11 Device ID
13 nIOState char 1 I/O status
14 nOilState char 1 Value of fuel
15 cErrorCode Char 1 >0 is OK,<0 is failed

1.7 Upload image request(TrackerServer)

It will take a photo (JPG file) while server send command to take a photo or turn on the
engine ,tracker will send a message to tell the server much the JPG file is,
No. Field TYPE Length Description
1 packetLen short 2 Message Length
2 CMD short 2 0x0200
3 sUserID char 11 Device ID
4 nDate long 4 date
5 nTime long 4 time
6 nFileLen unsigned short 2 Size of image (jpg file)

------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

1.8 Response of upload image(Servertracker)

No. Field TYPE Length description


1 sMark char 6 Flag of message (\r\n*KW\0)
2 packetLen short 2 Message Length
3 CMD short 2 0x8200
4 cErrorCode char 1 0x00OK, 0x01invalid deviceID
5 sEnd char 2 message end "\r\n"

1.9 Packet of image (TRACKER GPRS_SERVER)

Tracker will upload the JPG file by small packet(506), because the packet is too large to limited by
internet.
No. Field TYPE Length description
1 packetLen short 2 Message Length
2 CMD short 2 0x0200
3 sUserID char 11 Device ID
4 nPage unsigned short 2 Index of jpg file block
5 nPageLen unsigned short 2 block length nPageLen<506, it
means the last block
6 sData char 506 Image data,

1.10 Response of upload image packet

CMD_SendJpgResp 0x8201
No. Field TYPE Le description
ng
th
1 sMark char 6 Flag of message (\r\n*KW\0)
2 packetLen short 2 Message Length
3 CMD short 2 0x8201
4 nPage unsigned 2 Index of jpg file block
short
5 cErrorCode char 1 Status code
6 sEnd char 2 message end "\r\n"

------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

1.11 Tracker upload New Position


request(TrackerServer)

NR024 can be add temperature sensor, so we add a new message for the version
No. Field TYPE Length description
1 packetLen short 2 Message length
2 CMD short 2 0x0032
1 bEnable unsigned char 1 Status:
0bit is locating
1bit Main power
;2,3,4,5bit is NULL;
6bit ACC status ;
7bit poff
2 bAlarm unsigned char 1 Default 0x80
SOS alarm:0x81
overSpeed alarm:0x82
geo_fence alarm :0x83
Main Power cut alarm:0x89
Pin8 alarm: 0x8f
3 nSpeed char 1 Speed
4 nDirection short 2 Direction angle
5 fLongitude float 4 Longitude
6 fLatitude float 4 Latitude
7 nDateTime long 4 Date
8 sUserID char 11 Device ID
9 nIOState char 1 I/Ostatus
10 nOilState char 1 Value of fuel
11 nTempNum ; short 2 tempareture
12 nDistance float 4 Total mileage from engine is on

Position Upload message sample data


28 00 32 00 C3 80 00 26 00 24_03 58 40 65 4B D0 40 2E F5 F8
32 4E 52 30 39 47 30 35 31 30_30 00 00 00 19 00 A9 4A 47 49

Decode one by one byte


28 00 -->packet length=0x0028 = 40byte
32 00 -->commandID = 0x0032
C3 --> GPS FIX or not, Ignition status
80 -->is it alarm message
00 -->speed
26 00 -->angle
------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

24 03 58 40 -->Long = 3.37519
65 4B D0 40 -->lat = 6.50920
2E F5 F8 32 -->data and time=2012-11-28 15:20:46 (YYYY-MM-DD HH:MM:SS)
4E 52 30 39 47 30 35 31 30 30 00 -->device ID:NR09G05100
00 -->IO status
00 -->fuel data
19 00 -->temperature
A9 4A 47 49 -->millege

1.12 Tracker upload RFID card request(TrackerServer)

NR024 can be add temperature sensor, so we add a new message for the version
No. Field TYPE Length description
1 packetLen short 2 Message length
2 CMD short 2 0x0033
1 bEnable unsigned char 1 Status:
0bit is locating
1bit Main power
;2,3,4,5bit is NULL;
6bit ACC status ;
7bit poff
2 bAlarm unsigned char 1 Default 0x80
3 nSpeed char 1 Speed
4 nDirection short 2 Direction angle
5 fLongitude float 4 Longitude
6 fLatitude float 4 Latitude
7 nDateTime long 4 Date
8 sUserID char 11 Device ID
9 nIOState char 1 I/Ostatus
10 nOilState char 1 Value of fuel
11 RFID; Char 11 RFID card number
12 nDistance float 4 Total mileage from engine is on

Sample data:
31 00 33 00 83 80 00 C9 00 A5 36 9B 42EC A8 4E 41 5E 73 AA 34 4E 52 30 39 47 30 34 38 32 32 00 00
00 30 39 30 30 34 38 32 34 30 62 00 00 00 20 41

Decode :
31 00 nPackLen
33 00 nFlag
83 bEnable
80 nAlarm
------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

00 nSpeed
C9 00 nDirection
A5 36 9B 42 //Log
EC A8 4E 41 //lat
5E 73 AA 34 //time
4E 52 30 39 47 30 34 38 32 32 00 //deviceID=NR09G04822
00
00
30 39 30 30 34 38 32 34 30 32 00 //ID card =0900482402
00 00 20 41 //ndistance

1.13 Tracker upload 4 Fuel request(TrackerServer)

NR024 can be add temperature sensor, so we add a new message for the version
No. Field TYPE Length description
1 packetLen short 2 Message length
2 CMD short 2 0x0037
1 bEnable unsigned char 1 Status:
0bit is locating
1bit Main power
;2,3,4,5bit is NULL;
6bit ACC status ;
7bit poff
2 bAlarm unsigned char 1 Default 0x80
SOS alarm:0x81
overSpeed alarm:0x82
geo_fence alarm :0x83
Main Power cut alarm:0x89
Pin8 alarm: 0x8f
3 nSpeed char 1 Speed
4 nDirection short 2 Direction angle
5 fLongitude double 4 Longitude
6 fLatitude double 4 Latitude
7 nDateTime long 4 Date
8 sUserID char 11 Device ID
9 nIOState char 1 I/Ostatus
10 nOilState char 1 Value of fuel
11 nFuel2 short 2 Value of Fuel2(ultra fuel
sensor,unit :mm)
12 nFuel3 short 2 Value of Fuel3
13 nFuel4 short 2 Value of Fuel4
11 nTempNum ; short 2 tempareture
12 nDistance float 4 Total mileage from engine is on
------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

2. Appendix A

String format of field sData in Control command by GPRS(servertracker) 0x0002

2.1. Get tracker position

sData[50] = *KW,DeviceID,000,082309#
Sample Date: *KW,NR09G00001,000,082309#
It is to get realtime position of NR09G00001

Server send to tracker to get the postion of the tracker


No. Field Sample data
1 sMark \r\n*KW
2 packetLen 0x0044 =68
3 Command ID 0x0002
4 nGisIp 0
5 nPort 0
6 sData[50] *KW,NR09G00001,001,08
2309#
7 sEnd[2] \r\n”

2.2. Modify device password:

sData[50] = * KW, DeviceID,001, HHMMSS, ******,$$$$$$ #


------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

******is old password(default is 000000),$$$$$$ is new password

For example :*KW,NR09G00001,001,080756,000000,123456#


Change the password of tracker from 000000 to 123456

2.3. Real-time respond

sData[50] =*KW, 000,002, HHMMSS, interval #


interval =0 is stop ,interval=[30 ~ 65535 second]

2.4. Telphone set:

sData[50] =* KW, DeviceID,003, HHMMSS,P,TelNumber#


P=[1,3]
P=1 is telephone number for SOS
If the telNumber is 000, it cancel the telephone number
For example: *KW,NR09G00001,003,080765,1,13900000001#
Set the SOS telephone number is 13900000001
Cancel the SOS telephone number: *KW,NR09G00001,003,080765,1,000#

2.5. Control the engine :

sData[50] =* KW, DeviceID,007, HHMMSS,X#


(X=0:close,X=1:open)
For example :Cut off the engine by GPRS :
*KW,NR09G00001,007,080756,0#

2.6. Set Over speed Alarm :

sData[50] =* KW, DeviceID,005, HHMMSS ,XX#


XX is the speed
=00is close the over speed alarm function
=[01<XX<200] (10Km/H)
For example:*KW,NR09G00001,005,080765,80#
Set the vehicle speed limited 80KM/H

2.7. e-Fence Setting:

sData[50] =* KW, DeviceID,006, HHMMSS ,XX#


XX = [00,50] (unit :100m)
=00 is close e_Fence function
------------------------------------------------------------------------------------------------------------------------------------------
GPS&GMS/GPRS Vehicle tracker protocol

=01 100m
=02 200m
=03 300m
=04 400m
=05 500m
Example: Set Distance (1100)M:
*KW,NR09G00001,006,080765,11#

2.8. Restart device:

sData[50] =* KW, DeviceID,099,080756,RESETSYSTEM#


restart the NR09G00001 by GPRS :* KW, DeviceID,099,080756,RESETSYSTEM#

2.9. take a photo

sData[50] = *KW,Device ID,015,080756#


sample data:*KW,NR09G00001,015,080756#
tracker receive the command ,it will power on the camera and take photo, upload a JPG file to
server,server will save the data as a binary file and extend file name is *.jpg

2.1. Set Server IP and Port:

sData[50] =*KW,Device ID,010,080756,IP,Port#


sample data: *KW,NR09B00001,010,080756,121.37.58.10,6900#
the tracker receive the message ,It will send the data to server 121.37.58.10, Port:6900

------------------------------------------------------------------------------------------------------------------------------------------

You might also like