Tuesday, 9 August 2016

traccar.org deficiencies

serving traccar.org 3.6 web interface over rpi wifi to mobile device is EXCEEDINGLY slow - read 30 seconds to download all resources, parse java etc on iphone4s.
then, the mobile interface is quite clunky.
given this is a race tracker and the web portal is designed for viewing by general public, we want simple decluttered interface minus logon if possible

traccar.org 3.6 web interface:
pros:

  • custom map (for serving our own tiles)
  • easy to change html source for referencing offline cdn/js libraries without recompiling
cons:
  • web interface is slow to load over rpi wifi and iOS
  • mobile interface is poorly fitted to mobile canvas size
  • no 'show track' easily available
  • no 'no logon/auto logon' available


this project using the old traccar.org web interface package seems to be better suited, but isn't ideal either

https://github.com/vitalidze/traccar-web/
pros:

  • auto-logon via http get is possible (we can set a landing page on our rpi captive portal to auto log on as guest and go to mobile site
  • mobile site is very good on mobile device
  • track is shown
  • .war file is just a zip - changing code relatively easy
cons
  • no custom map layer - will need to recompile .war to add custom map source if possible (replace OSM url's probably...?)
  • will need to recompile .war each time to make changes to code..
  • not easy to see where libraries are loaded
  • device icons are static, not direction-based arrows
  • no track shown in mobile layer



Monday, 8 August 2016

Making Traccar.org server work without internet connection

/opt/traccar/web/release.html:
download all external references to cloudflare CDN for css and java libraries to a new folder:

need to clone extjs/6.0.1/classic/theme-neptune/resources into ajaxlocal
sudo mkdir /opt/traccar/web/ajaxlocal
cd //opt/traccar/web/ajaxlocal
sudo wget http://{cdn css or js library to download} 
you will also need to download http://cdnjs.cloudflare.com/ajaz/libjs/extjs/6.0.0/classic/locale/locale-en.js (if this is your chosen language

http://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.1/classic/theme-neptune/resources/theme-neptune-all_1.css
http://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.1/classic/theme-neptune/resources/theme-neptune-all_2.css


theme-neptune-all_1.css
and
theme-neptune-all_2.css
(probably a more elegant way of doing it)
download fontawesome from fontawesome.io version 4.6.3 (or whatever version is called by script - check the debug console of your browser for network resources it tries to load.
extract font-awesome css and font-awesome.min.css into the new /ajaxlocal folder
make a new folder
sudo mkdir /opt/traccar/web/fonts/

extract font-awesome/fonts into /opt/traccar/web/fonts/
cd /opt/traccar/web/fonts
sudo cp /home/pi/Downloads/font-awesome-4.6.3/fonts/* ./


edit /opt/traccar/web/locale.js to point to your ajaxlocal/locale-en.js as downloaded above so the line looks like
Ext.Loader.loadScript('ajaxlocal/locale-' + Locale.languages[Locale.language].code + '.js);

Making Traccar.org server work without internet connection

/opt/traccar/web/release.html:


download all external references to cloudflare CDN for css and java libraries to a new folder:

sudo mkdir /opt/traccar/web/ajaxlocal
cd //opt/traccar/web/ajaxlocal
sudo wget http://cdnjs.cloudflare.com/ajax/libs/ol3/3.17.1/ol.css
sudo wget http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css
sudo wget http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css
sudo wget http://cdnjs.cloudflare.com/ajax/libs/ol3/3.17.1/ol-debug.js

get extjs 6.0.1 GPL, download via signup at:
https://www.sencha.com/legal/gpl/

copy ext-6.0.1-gpl\ext-6.0.1\build\*.* into
/opt/traccar/web/ajaxlocal/

(final structure is /opt/traccar/web/ajaxlocal/build/,,,,


download fontawesome from fontawesome.io version 4.6.3 (or whatever version is called by script - check the debug console of your browser for network resources it tries to load.
extract font-awesome css and font-awesome.min.css into the new /ajaxlocal folder
make a new folder
sudo mkdir /opt/traccar/web/fonts/

extract font-awesome/fonts into /opt/traccar/web/fonts/
cd /opt/traccar/web/fonts
sudo cp /home/pi/Downloads/font-awesome-4.6.3/fonts/* ./


edit /opt/traccar/web/locale.js to point to your ajaxlocal/build/locale-en.js as downloaded above so the line looks like
Ext.Loader.loadScript('ajaxlocal/build/classic/locale/locale-' + Locale.languages[Locale.language].code + '.js);

Thursday, 4 August 2016

Raspberry Pi GPS Tracker with Openstreetmap offline tiles

1) save OSM tiles to raspberry pi using maperitive in mbtiles format
  I needed to use the windows version to download the tiles, then copy to raspberry pi

2) use Tilestache to serve the tiles
my config file is in the previous post. The layer I called "osm" and is used in the map config in Traccar.
I needed to bind the tilestache server to my pi LAN IP for traccar to connect: start tilstache with the command
tilestache-server.py -i 192.168.1.19 -p 8080
adjust as necessary for your ip and port.

3) edit Traccar in TWO places
  run traccar, login as admin, then click

Settings-->Server--> Map Layer: custom map
custom map :http://192.168.1.19:8080/osm/{z}/{x}/{y}.png

change ip and port to suit, and layer name (osm) if needed if you called your tilestache layer something else

you also need to change the USER to use the custom map
Settings-->USERS-->click on your user, click edit (pencil icon)
change map layer to Custom map.

back on the tilestache console you should then see requests being logged for different zooms.







Raspberry Pi Openstreetmap tile server - tilestache config

Tilestache mbtiles example config  file
{
  "cache":
  {
    "name": "Test"
  },
  "layers":
  {
    "osm":
    {
        "provider": {"name": "mbtiles", "tileset": "/home/pi/src/tilestache/tiles/map.mbtiles"}

    }
  }
}

LoRa race tracker - base receiver/display

Raspberry Pi 3 as wifi hotspot with captive portal.

Saving OpenSteetMap tiles for offline serving
Maperitive (http://maperitive.net/) used to download openstreetmap tiles to raspberry pi.
Linux (ubuntu 14.x x64) failed with error when running generate-mbtiles , so used Windows version to generate mbtiles instead.

Serving OSM tiles offline on raspberry pi
Trying out Tilestache to serve the mbtiles locally on the pi, for consumption by tracking app.
tilestache.org (installed via pip)
http://tilestache.org/
config file for tilestache:

GPS Tracking application / user portal
trying Traccar.org in the first instance. Server install for ARM is available. Hopefully will be able to configure it to consume the locally served OSM tiles. Alternatively will try OpenGTS.

Receiving race unit positions
Race unit positions are received by HopeRF RFM98 modem on the same Raspberry pi, and converted into suitable sentences by python script.

LoRa Receiver board for Raspberry pi
hardware: https://store.uputronics.com/
software: Python: base don  https://github.com/mayeranalytics/pySX127x
Python needs to be adapted for uputronics board pinouts - got it working but with a random crash of Pi every now and then when running for the first time.....will post code on git when I get a minute.

Raspberry Pi as Wifi access point and captive portal (redirecting users straight to tracking server web front end)
I have used this method in the past: DHCP+DNS+hostapd server
https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/overview
Captive portal via DNS catchall - probably a better way to do it.






Race tracker for remote locations using LoRa and Raspberry Pi

Bike/Running Race tracking software for remote locations (with no mobile/internet coverage).


Competitor unit:
GPS board
LoRa modem
Power (battery - possibly passthrough from competitor's bike light.
Ant.
Panic button
Enclosure for mounting on bike (waterproof, saddlebag?)

Demo unit uses Adafruit Feather M0 LoRa and GPS featherwing.
Device is given a DeviceID, from this is derived a transmit slot (TDMA) using GPS PPS for synchronisation.
Position, battery level, panic button status are transmitted periodically to receiver/base station

Base Station Unit
Designed to be 12v powered inside e.g. motorhome or support vehicle.
Raspberry Pi 3 set up as wifi hotspot and captive portal.
LoRa radio receives position reports from competitor units.
Traccar or OpenGTS open-source GPS tracker server.
OpenStreetmap tiles are served from offline cache to connected clients.
Spectators can view progress on smartphone/tablet by connecting to wifi hotspot.