Android client sending, but position is not updated.

eiten7 years ago

Hi everyone,

I'm using some Raspberry Clients which work like a charm. I also use a Android Client (Galaxy S7, Android 7.0) which does not work. The server log looks as like this:

2017-03-28 13:39:35  INFO: [5C41F6C3] connected
2017-03-28 13:39:35 DEBUG: [5C41F6C3: 5050 < 46.140.140.140] HEX: 474554202f3f69643d3638393831382674696d657374616d703d31343930363937343630266c61743d34372e2a2a2a2a2a2a2a266c6f6e3d392e2a2a2a2a2a2a2a2673706565643d302e302662656172696e673d302e3026616c7469747564653d302e3026626174743d39372e3020485454502f312e31a557365722d4167656e743a2044616c76696b2f322e312e3020284c696e75783b20553b20416e64726f696420372e303b20534d2d4739333046204275696c642f4e524439304d29a486f73743a2031302e3132302e3132302e353a35303535a436f6e6e656374696f6e3a204b6565702d416c697665a4163636570742d456e636f64696e673a20677a6970a
2017-03-28 13:39:50  INFO: [5C41F6C3] disconnected

Which translates to

GET /?id=689818&timestamp=1490697460&lat=47.*******&lon=9.*******&speed=0.0&bearing=0.0&altitude=0.0&batt=97.0 HTTP/1.1
User-Agent: Dalvik/2.1.0 (Linux; U; Android 7.0; SM-G930F Build/NRD90M)
Host: 10.120.120.5:5055
Connection: Keep-Alive
Accept-Encoding: gzip

(stars entered for my privacy :))

Anybody knows what's going wrong here?

Regards, Edi

Anton Tananaev7 years ago

Why is the port 5050?

eiten7 years ago

In fact, that's a good question, I did not see this! Thanks for pointing out, now I got somewhere to investigate further!

eiten7 years ago

Ok, this is solved. It was a problem of the router. A firmware update fixed this issue. I first defined forward 5050 -> 5050, then corrected it to 5055 -> 5055, but the router made 5055 -> 5050 out of this.
Thanks a lot!

allin7 years ago

Hello Etien
Could you tell me with what to send data to the server through your raspberry
You're using openwrt or linux in general as a client?
Thanks so much
All ..

eiten7 years ago

Hi allin,

I'm using Raspbian Jessie Lite on the rovers. The server is running on a debian server. Router forwards ports 5055 and 8082 (but second is not important for tracking). I am using the following script on the Raspberrys. It's simple, but it works. I need to add smart beaconing and error handling soon. Tell me when you are interested in newer versions, then I might set up a git.
NB: Remember to block all your outgoing ports on your raspberry for the mobile connection except ports 53 and 5055 if you don't have a flat rate.

#!/usr/bin/env python

###
# Simple GPS Tracker for raspberry pi
# Written by Eduard Iten, March 2017
# GPL 2.0
###

from gps3 import gps3
import dateutil.parser
import calendar
from datetime import datetime, date
import time
import urllib2

### Configuration variables
id="test"                         # id of the tracker
url="http://my.dynamic.dns:5055"  # destination host ip or name
interval=30                       # sending interval in seconds
### Configuration end

gps_socket = gps3.GPSDSocket()
data_stream = gps3.DataStream()

gps_socket.connect()
gps_socket.watch()

for new_data in gps_socket:
  if new_data:
    data_stream.unpack(new_data)
    mode = 0
    utctime = 0
    lat = 0
    lon = 0
    speed = 0
    track = 0
    alt = 0
    hdop = 0
    last=0

    if isinstance(data_stream.TPV['mode'], int):
        mode = data_stream.TPV['mode']

    # Only process if we got a 3D fix. For 2D fix, change to 2
    if mode >= 3:
      if not data_stream.TPV['time'] == 'n/a':
        utctime = calendar.timegm(dateutil.parser.parse(data_stream.TPV['time']).timetuple())
      if not data_stream.TPV['lat'] == 'n/a':
        lat = data_stream.TPV['lat']
      if not data_stream.TPV['lon'] == 'n/a':
        lon = data_stream.TPV['lon']
      if not data_stream.TPV['speed'] == 'n/a':
        speed = data_stream.TPV['speed']
      if not data_stream.TPV['track'] == 'n/a':
        track = data_stream.TPV['track']
      if not data_stream.TPV['alt'] == 'n/a':
        track = data_stream.TPV['alt']
      if not data_stream.SKY['hdop'] == 'n/a':
        hdop = data_stream.SKY['hdop']

      if (last + interval) < time.time():
        query = "/?id={0}&lat={1}&lon={2}&timestamp={3:.0f}&hdop={4}&altitude={5}&speed={6}&heading={7}".format (
          id,
          lat,
          lon,
          utctime,
          hdop,
          alt,
          speed,
          track
        )
        print urllib2.urlopen(url+query).read()
        last = time.time()