About server messages...

David9 years ago

Hi Anton,

I'm trying to do my own server program for windows based on your client app.

The idea is add some mysql enhancements, printing and exporting capabilities.

I would prefer use your client app as is - no modify anything.

At this time i can get the TCP data sent by the client. It seems to be ok.

I just discovered when i rerstart your server program, connected clients sends all data collected when your server is down.

I think server program sends TCP message with a confirmation to clients each time client send new location, in order to client app discards this sent data.

Could you tell me what is this message ?

Tnanks in advance,
David

Anton Tananaev9 years ago

If you are talking about Traccar Client protocol, then it's based on HTTP, so the response should be standard HTTP 200 OK status (body can be anything, but it makes sense to have it empty as it's ignored).

Some more info about the protocol format can be found here:

https://www.traccar.org/osmand/

David9 years ago

Thanks Anton,

HTTP 200 OK status works with all kind of devices, or only for response to OsmAnd Traccar client ?

Tracking devices also stores unsent or unconfirmed data ?

David

Anton Tananaev9 years ago

Most GPS trackers don't use HTTP protocol, so HTTP status doesn't make sense for them.

Some devices do store unsent/unconfirmed data.

rameshdigitech9 years ago

Hi Anton,

I am trying to implement a simple tcp server in python which will read the incoming data from your mobile app and simply display it .

Here is my Python code for the server :

#!/usr/bin/env python
import socket
TCP_IP = "192.168.1.102"
TCP_PORT = 32000
BUFFER_SIZE = 283

def tServer():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind((TCP_IP, TCP_PORT))
        print "Listening...."
        s.listen(1)
        conn, addr = s.accept()
        print 'Accepted connection from address:', addr
    except socket.error:
        if s:
            s.close()
        print "Could not open socket: "
        conn.close()
        exit(1)
    try:
        while 1:
            data = conn.recv(BUFFER_SIZE)
            if not data:break
            print "received data:", data
            message = "HTTP/1.1 200 OK"
            try :
                conn.sendall(message)
            except socket.error:
                print 'Send failed'
                exit()
    except KeyboardInterrupt:
        conn.close()
if __name__ == '__main__':
    tServer()

The Problem is in Output i am getting only one data not continuous stream of data in 5 sec interval as set in app. I am able to read only one time from the TCP.

C:\Python27\python.exe C:/TCP_GPS/tcp_server.py
Listening....
Accepted connection from address: ('106.51.36.191', 54500)
received data: GET /?id=409299&timestamp=1455211799&lat=12.97036467&lon=77.69072153&speed=0.0&bearing=0.0&altitude=789.0&batt=15.0 HTTP/1.1
User-Agent: Dalvik/2.1.0 (Linux; U; Android 5.0.2; Mi 4i MIUI/V7.1.1.0.LXIMICK)
Host: 106.51.36.191:32000
Connection: Keep-Alive
Accept-Encoding: gzip

Can you help ?

Anton Tananaev9 years ago

Traccar Client uses HTTP protocol, so it establishes new connection every time.

rameshdigitech9 years ago

Thanks for the hint , i was able to get the data from the client now , Similarly when i read the data from Castel idd-213gl i get some kind of bogus data only for the first time , can you please help me in reading this device in python ?

rameshdigitech9 years ago

Something Like this :

received data: @@...

Anton Tananaev9 years ago

Your device sends binary data, so you need to read it as binary without converting to a string.

pit18 years ago

@rameshdigitech

Can you post your final code? I have the same problem. Thanks for your help