Observation regarding Topin protocol

Xavier Schreiber6 years ago

Hi,

First, thank you for all your work on the Traccar system, and especially with the decision to continue to keep it open source.
I've just bought some PCBA trackers the ZX303 and ZX612 made by Topin, which seem to be the smallest gps/gprs tracker you can buy and inject in other electronic devices.
The configuration wasn't too difficult and the ZX303 (didn't test the other for now) seems to function correctly with my Traccar Server instance on the port 5023 (GT06) protocol.
The main problem (and the most wanted functionality) is the offline feature which allow the device to collect location even without GPRS connectivity and send them when back online.
This feature is not well documented by Toppin but a screenshot on aliexpress and by this document which mention an item in the protocol with the afformed byte set to 0x11 called (GPS offline positioning data package).

When my tracker sends this offline data to the Traccar decoder, it seems that it continues to send just one location again and again until it finally obtains a GPS fix and switch back to online position (protocol byte set to 0x10) and forget the offline data.

So I try to look at the Traccar log and, in the same time, setup a simple netcat proxy to compare with the behaviour of the Toppin interface (365gps.net).

For privacy reason the bytes for the coordinates has been hidden, and I couldn’t get exactly the same data (time and location).

Traccar beaviour

LOC 7878 15 11 1305100D1631 9A XXXXXXXXXXXXXXXX 00 34A2 000D00 0D0A
ANSWER 7878 05 11 A200D18F 0D0A

365GPS beahaviour

LOC 7878 15 11 130511090108 99 XXXXXXXXXXXXXXXX 00 346B 000000 0D0A
ANSWER 7878 15 11 130511090108 0D0A

So, it seems that the correct answer for the Topin protocol to continue the exchange is to answer with a packet with the same protocol and by repeating the datetime of the GPS coordinates packet.
After this exchange, I can see that the tracker sends the others coordinates to the 365gps.net website.

I will try to test some modification to the GT06 decoder to make Traccar answer correctly to the tracker.

Best regards

Xavier Schreiber5 years ago

Hi,
I've done the testing modification to the GT06ProtocolDecoder.java to cope with the Topin protocol, and that seems to correct this problem.
The device manage to send all the cached position to the Traccar server, which is quite awesome.
I've begun to add some other protocol item (like the 0x98 to valid a change to the update interval when the device received a command trough SMS).

I don't know the GT06 so i don't know if the change i made will be compatible, but since the GT06 protocol use a checksum data when answering to the device, It probably won't work. So my opinion is that a new TopinProcotolDecoder will be needed.

Radu5 years ago

Hi,

I am also testing this device (similar) ZX302 , and I think it would be nice to have a separate decoder.
Also I am wondering if the device does not send voltage or data about battery . Did you have any success in implementing any additional functionality ?

I believe it would be good if we could test the device and then send info to developers.

If I change the settings just for my server (new port and new data it would be lost if not implemented by the developer).

For me most important feature would be to check battery level as this device is a perfect bicycle tracker.

leonairo chantre5 years ago

Hola como están adquirí un dispositivo de esa referencia y nunca lo pude hacer funcionar con traccar me pueden ayudar para saber que debo hacer

Uriel Vazquez5 years ago

@leonairo chantre, deberias de revisar foros anteriores donde te explica la configuracion de tu dispositivo para que locambies al servidor de Traccar, eso si, estan en ingles.

Xavier Schreiber5 years ago

Did you have any success in implementing any additional functionality ?
...
I believe it would be good if we could test the device and then send info to developers.
...
For me most important feature would be to check battery level as this device is a perfect bicycle tracker.

Technically it should be possible, but the main difficulty is that the tracker doesn't send the battery data when sending a GPS grid (packet type 0x10 ).
The battery level is sent within a status packet (type 0x13), and i don't see any way to force a status message when the server get GPS data, to fill this information before writing the location in the database

markac5 years ago

Hi Xavier Schreiber.
You can read battery status from 0x13 message, it is simple.
The most important is, from where you have real ip and port for 356gps.net?
Can you share this values? Topin doesn't provide this information at all (I asked).
With full logs I can analyze functionality, that doesn't work for me now.
I will be very grateful for this information (ip / port) and netcat command :)
Regards.

Xavier Schreiber5 years ago

The 365gps.net server got the IP 120.76.241.191 (simple ping command on the domain)
To get the port was a little more tricky, I did a nmap command on the server and found a bunch of open ports, so i try each one and found that the 8002 is correctly answering to Topin protocol.

To get a netcat proxy working you can use the following commands on your server

mkfifo reply
ncat -kl 8765 < reply | ncat 365gps.net 8002 -x session.txt > reply

Then you can configure your tracker with your server IP and the port 8765.
The session.txt file will contains all the commands and answer, sadly without any clue regarding who is sending the data, so it can be somewhat complicated to understand the protocol.

The problem with reading the battery data from a 0x13 message is that regarding Traccar inner functioning, I can't find a way to implement it cleanly (in all example for other protocol, it seems that the battery data is just read from a position message and inserted simultaneously in database, for toppin you need to insert the data in a old location)

markac5 years ago

Thanks.
I check this soon!
Now, the most important problem is, why SPEED is not enabled by default and is not available in G03?
I ask TOPIN to enable this (switch from Personal to Vehicle mode), and then I have speed on they application
and my server (sometimes, because now I don't at all). They switch some flag in device to enable speed, but I don't know which?
I enabled all flags in synchronization message (byte 6) without success.
This device has even altitude (not documented at all). I suppose, we can enable step counter and other, but with standard documentation, we can only guessing...
I don't know traccar code very well and database structure, but after receive status message, you can just update position rows in table and fill empty values with last status, for example:

UPDATE logs SET battery = ? WHERE battery = NULL;

Each time you receive status, you update only position rows witch empty battery status.
But we have reading problem with empty values :) We must use last non zero value...

markac5 years ago

I have proxy server written in Node and remote port 8002 returns timeout :(

Error: connect ETIMEDOUT 120.76.241.191:8002
    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1099:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '120.76.241.191',
  port: 8002
Xavier Schreiber5 years ago

It seems they close the 8002 port, but the 8005 seems to answer correctly

nmap -p 1-30000 365gps.net

Starting Nmap 7.40 ( https://nmap.org ) at 2019-09-05 21:12 CEST
Nmap scan report for 365gps.net (120.76.241.191)
Host is up (0.22s latency).
Not shown: 29994 filtered ports
PORT     STATE SERVICE
80/tcp   open  
1474/tcp open  
2108/tcp open  
3306/tcp open  
7001/tcp open 
8005/tcp open  

i tried to send a login packet

echo '78780d010357339075405974490d0a'  | xxd -r -p | netcat  365gps.net 8005  -o result
cat result
> 00000000 78 78 0d 01 03 57 33 90 75 40 59 74 49 0d 0a    # xx...W3.u@YtI..
< 00000000 78 78 01 01 0d 0a                               # xx....

It think we're good

Concerning the speed indicator, i never change anything on my trackers and i always got the speed info.

The problem with your solution is that the battery data don't always come immediately after a position message so it could be a inexact time stamp especially for slow update setting, the best solution would be for the server to ask a battery status after every position

markac5 years ago

Now it works, thanks!
In my device, SPEED byte had always 0 value, so I contacted with the seller and he answered:

Tell the imei number, I will add speed function to your imei.

So... They can enable this. How? I don't know.
After he enabled SPEED we must switch device to original server once.
After, we can back to our server and SPEED is available.
I analyze log now and I see undocumented message 0xEF (a lot).

stephane bhiri5 years ago

Hello Xavier,

Well done with finding the datetime answer from server for getting the cache GPS data from the ZX302.
Are you ok to share your modifications of the GT06ProtocolDecoder.java ?

This should definitely be available as an official Traccar Topin protocol.

Thank you for the impressive work.

Stephane

stephane bhiri5 years ago

Oh, just found out it was realized last month. with cell and wifi data ö

https://github.com/traccar/traccar/blob/master/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java

robertr45 years ago

Hi,
When i've asked Topin to provide their tracking server details, they've told me to send SMS like this to the device: domain#www.baidu.com#1001#
Maybe it will help you to do the Reverse Engineering on that.