Skip to content

rdkls/gps-tracker-server

Repository files navigation

GPS Tracker Server

Manage and display locations of GPS tracking devices

Screenshot

This was from my demo system just before decomissioning, with live data from my actual device. Screenshot of GPS Thingo

Why

My motorcycle was stolen, and I really wished I had a way to track it down.

I knew it had an OBDII port (like most cars, not so many bikes), which I had previously used to flash the ECU and log engine data, and thought, wouldn't it be cool if it was fitted with a GPS tracker which just plugged into that (i.e. no cutting/soldering required).

I found just such devices (specifically the Coban GPS306) available on eBay for USD$60 and bought one.

By default the devices come configured to use www.gpstrackerxy.com. That system is hosted by some unknown-to-me company in China, plus you only get 30 days free access.

The other open source solutions out there looked ugly, heavy, or clunky. So I made my own.

So the primary use case is: "as myself, I want to find where my bike is, so that I can get it the hell back" =)

Current Status

Currently the device gateway handles device initialization, heartbeat, and location request/response.

Now I have the basics working (location request/report/view on map), I've stopped active development. The main reason for this is that I can't see they system being widely useful to myself or others (I now keep my bike locked in the garage). Still, it was a fun thing to do.

Currently only works for the Coban GPS306, since that's what I bought.
HOWEVER - the system /is/ architected to make additional device support easy to add.

For anyone interested, the other things I thought would be cool to do are on the Trello board

Overview

GPS Tracker Device <--> Device Gateway <--> MongoDB <--> REST API <--> Web Frontend

Devices

These devices use GPRS (so you need a SIM with some credit) to talk over the net to an admin server (which I call "device gateway") via TCP or UDP.
The protocols are pretty simple strings containing commands (e.g. send me your location) and responses (e.g. my location is lat.x long.y)

You configure them by sending an SMS
e.g. to tell my device to use my home gateway, I sent it an SMS containing "adminip8888 59.167.194.249 9000" (9000 is the port)
After that, it's talking to my device gateway.

Device Gateway

TCP socket server using gevent, mongoengine for ODM/ORM

The gateway can send commands to the devices (mongodb used to store these, as well as all other data)

REST API

Then there's a REST API (python flask, mongoengine for ORM/ODM) talking to the DB

I did initially try eve-mongoengine and flask-mongorest. Though they were great to quickly get basics up, I found them too restrictive (plus, from past experience I know the latter has some serious bugs and is horribly unmaintained).
Plus - for Version Zero I only needed a few endpoints quickly knocked up, hence DIY!

Web Frontend

Angular, Bootstrap, Jade, Sass, Bower, Gulp
TBH web's not my strong point, but with these excellent tools I managed!

Server Setup

This is very shorthand and assumes you're familiar with the stuff in use.

Using virtualenv recommended = no system-wide packages

  • mkdir venv && virtualenv venv/gps
  • . venv/gps/bin/activate
  • pip install -r requirements.txt

Running the Device Gateway

Nothing fancy yet!

  • . venv/gps/bin/activate
  • ./device_gateway.py Should now be listening on port 9000

Trying the Device Gateway

In another tab: cat sample-reqs/tkip102-1.txt | nc localhost 9000

Running Tests

With virtualenv activated, from repo root just run 'nosetests'

Links

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published