Xexun GPS Protocol
Xexun GPS Protocol
Data Types
Data Types Describe
U8 Unsigned single byte integer ( byte , 8 bits )
U16 Unsigned double - byte integer ( byte , 16 bits )
U32 Unsigned four - byte integer ( double byte , 32 bits )
FLOAT Single-precision floating-point number (four bytes, 32 bits)
U8 [n] N byte
BCD [n] 8421 code , n byte
STRING UTF- 8 encoding , if it is data , leave it blank
Message structure
Each message consists of a flag bit + a message header + a message body + a flag bit.
Flags
The first and last flags are both FAAF. The FAAF in the body is converted to FBBF02 , and the FBBF in the
body is converted to FBBF01.
Message Header
No. Start Byte Name Data Types
0 Message ID U16 , the positioning and alarm upload data
1 message ID is 0020 , the server sends the
command message ID is 0021
2 2 Serial Number 0-65535 U16
3 4 IMEI+0 BCD[8]
Protocol Detection
The terminal sends the following data when it connects to the platform for the first time :
FA AF 00 14 00 01 86 27 71 07 54 26 75 20 00 0C FF F5 01 00 09 00 00 00 00 00 00 00 00 00 FA AF
The platform resolves the message ID to 0014 and responds with 02:
FA AF 00 14 00 01 86 27 71 07 54 26 75 20 00 01 FF FD 02 FA AF
Message body
No. Name Type Number
1 Data Type ID U8 1
2 Data length U8 1
When the data content length is 0, there is no
3 * *
DATA field
1
GPS Data Type ID : 00
No. Name Type Number Example
1 Timestamp of successful positioning U32 4 6675360C
2 latitude FLOAT 4 463229B7
3 longitude FLOAT 4 450BA72B
4 altitude FLOAT 4 424F999A
5 Number of satellites U8 1 06
Average signal-to-noise ratio of the four
6 U8 1 23
satellites with the best signals
7 Speed, 10*(km/h) U16 2 0001
8 Angle, 10*(degree) U16 2 0000
Ephemeris synchronization flag, 0 = not
9 U8 1 00
synchronized 1=Synchronized
The number of seconds it takes to successfully
10 U8 1 07
locate
11 Dilution of Precision U16 2 001D
The strongest signal-to-noise ratio of the four
12 U8[4] 4 26242121
satellites
1 is normal, 2 is modified , 4 is differential, 5 is
13 U8 1 01
sub-meter (only available for RTK )
14 Differential delay (only available for RTK ) U8 1 02
Full example:
00206675360C463229B7450BA72B424F999A0623000100000007001D262421210102
2
5 CID U32 4 0A82AB1A
6 RSSI U8 1 twenty three
7 LAT FLOAT 4 463229B7
8 LON FLOAT 4 450BA72B
Example:
02196675360C01CC00000000262E0A82AB1A23463229B7450BA72B
3
Device Status Data Type ID: 06
No. Name Type Number Example
1 4G signal U8 1 1F
2 Battery U8 1 1E
Status( bit 1: motion status (1 motion 0 stationary) , bit 7 :
3 charging status (1 charging 0 not charging ), bit 0 and bit 2-6 : U8 1 03
reserve)
Positioning sequence number (valid when positioning is
4 U8 1 09
triggered)
5 Fuel level (only for car GPS ) U8 1 63
Example: 06051F1E030963
4
parameters, the others are
reserved)
Upper version | Lower 58313432343039313930317C3234303930
2 U8[32] 32
version 373031000000000000000000000000
3 ICCID BCD 10 89860848102490501758
Product model, 4G version ,
4 GPS version character U8 1 41
length
4430342C4137363730452D4C4153435F41
Product model, 4G version , STRIN 31313042303141373637304D365F435553
5 *
GPS version G 5F55435653494D2C4154363535385F5552
414E5553352056352E332E302E30
Example:
206F0158313432343039313930317C323430393037303100000000000000000000000008986084810249
05017584 1 4430342 C 4137363730452 D 4 C 4153435 F 4131313042303141373637304 D 365 F
4355535 F 55435653494 D 2 C 4154363535385 F 5552414 E 5553352056352 E 332 E 302 E 30
The server needs to reply after receiving the data from the terminal
After receiving the data uploaded by the terminal, the server replies 02:
Example: "FAAF0020000486392103347538800001FFFD02FAAF".
5
"lng":"11402.423828","
lat":"2234.444092"}
wifivlcfg={"bssid_list":[" "bssid_list": ["0c:4b:54:3f:29:01","7c:1e:06:82:d5:71"]: List of
0c:4b:54:3f:29:01","7c: nearby Wi-Fi BSSIDs. Can be used to match specific Wi-Fi
WiFi
1e:06:82:d5:71"] , hotspots.
Positioning
"lng":"11402.423828"," "lng": "11402.423828": The longitude of WIFI.
lat":"2234.444092"} "lat": "2234.444092": The latitude of WIFI.
Parameter 1: Alarm ID,
1 "Enter the fence"
The 2 "Exit the fence"
platform alarmid=1,timestamp 3 " Overstaffing alarm "
sends alarm 4 "Gathering alarm"
5 "Speeding alarm"
Parameter 2: The timestamp when the alarm is triggered.
Example:
If you need to send "tk=1,60,1,180,1" to 863921033475388:
FAAF00210001 8639210334753880 00 20 FE47 746b3d312c36302c312c3138302c3100 FAAF
Note: The text “tk=1,60,1,180,1” is converted to string 746b3d312c36302c312c3138302c3100.
6
Example
Positioning and alarm data:
FAAF0020000286392103347538800029FE4700276675360C40C64589CE4217D240A17404D3BF2F550000
8B1D1A2700560064010300782526272301FAAF
Note: FAAF at the beginning and end are flags. 0020 is the uploaded message ID . 0002 is the sequence
number. 8639210334753880 is the IMEI. 0029 is the message body length. FE47 is the checksum of the
entire message .
00276675360C40C64589CE4217D240A17404D3BF2F5500008B1D1A2700560064010300782526272301 is
the body , 00 is the positioning data type, which means the data type is GPS. 27 is the data length.
7
ECC Check Algorithm
java Code:
public static int checksum ( byte [] data , int len ) {
int sum = 0;
for ( intj =0; len > 1; len --)
{ sum +=
data [j++]&0 xff ;
if (( sum & 0x80000000)>0) {
sum = ( sum & 0xffff ) + ( sum >> 16); }
}
if (len == 1) {
sum += data [ data . length -1]&0
xff ; }
while (( sum >> 16)>0) {
sum = ( sum & 0xffff ) + sum >> 16; }
sum =( sum == 0xffff ) ? sum & 0xffff : (~ sum )&0
xffff ; return sum;
}
C Code :
unsigned short sw_tcp_checksum(unsigned char *data,int len) {
unsigned long sum =0; for (;
len >1; len -= 1)
{
sum += * data ++;
if ( sum &0x80000000)
sum =( sum &0 xffff )+( sum >>16); }
if(len=1)
{
unsigned short i = 0;
*( unsigned char *)(&i)=*( unsigned char *) data ;
sum +=i;
}
while ( sum >> 16)
sum=(sum&0xffff)+sum>>16;
return ( sum ==0 xffff )? sum :~ sum ;
}