Monday 22 August 2016

traccar-web with custom offline maps

(incomplete)
traccar-web interface to traccar.org
* allows URL sign-on and better mobile interface

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

quick and dirty method - replace opensteetmap tile url with local tilestache server tiles

get file-roller (archive manager):

sudo apt-get install gnome-common
sudo apt-get install yelp

git clone 
https://wiki.gnome.org/Apps/FileRoller
./auto


install traccar.org and traccar-web as per their respective installers - confirm working.


On linux system you can open /opt/traccar/traccar-web.war with archive manager, edit files then re-pack quite easily. https://wiki.gnome.org/Apps/FileRoller (installed default in ubuntu 12.0.4 

We are concentrating on the mobile interface
traccar-web.war/m/index.html:
change any references to CDN cloudflare css or js libraries to point to "js/{name of js" or "css/{name..." as required.
then download and add the css or js file to the traccar-web.war/js/ or /css within the archive and re-pack the grml file

...



Thursday 11 August 2016

raspberry pi lora hoperf python code

clone
https://github.com/mayeranalytics/pySX127x
sudo apt-get install python-dev

wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz
tar xfvz  spidev-3.1.tar.gz
cd spidev-3.1
sudo python setup.py install
sudo pip install Adafruit
sudo pip install httplib2

edit files to account for Uputronics Hoperf board#############
pySX127x/SX127x/board_config.py:
line 33 onwards
change pins for the HAB pi board on CE1:
class BOARD:
  # Note that the BCOM numbering for the GPIOs is used.   
    DIO0 = 16   # RaspPi GPIO 16 = wpi 27 = phys 36 (input)#dio0 on habboard
  #  DIO1 = 12   # RaspPi GPIO 12 = wpi 26 = phys 16 (input)DIO5 on habboard
   # DIO2 = 24   # RaspPi GPIO 24 = wpi 5 = phys 18 (input)#notused
   # DIO3 = 25   # RaspPi GPIO 25 = wpi 6 = phys 22 (input)#notused
    LED  = 13   # RaspPi GPIO 23 = wpi 1 = phys 33 ( make output on ‘internet’ LED)
#################
line 74, in def SpiDev(): and change to
BOARD.spi.open (0,1) #for HOPE module at bus CE1
###################
pySX127x/SX127x/LoRaArgumentParser.py
line 41 onwards
change the default= items in the __init__ self section to the required frequency, spreading factor,bandwidth etc that you are using. Setting them here for 433MHz board means constructing a LoRa object without all the parameters will at least work without defaulting to 868mhz. I have mine set at 434.4mhz
#####################
pySX127x/SX127x/LoRa.py
Line 84 change calibration freq to 433mhz
Line 815 change freq to 433mhz
This just allows the self-test facility to work at 433mhz without supplying further parameters
remove any initialisations for DIO2 onwards
################
you can now run pySX127x/test_lora.py, to see if it works. Do a ‘gpio readall’( part of wiringpi) beforehand, which seems to un-stick it – I guess some wiring pi is not being initialised completely….
#################
I have a blind receiver running continuously, so I just modify the file pySX127x/rx_cont.py:
Line 44: in function
   def on_rx_done(self):
this is where I add my code – and is triggered on each
successful packet reception:IO

installing tilestache on raspberry pi 3

from clean raspbian jessie install
open terminal
sudo pip install tilestache

you may get a warning  re compilation terminated, but read it carefully - this is just for C extension speedups which are not compulsory

make directory to serve tiles from and store tilestache

mkdir /home/pi/src/tilestache
create config file as shown in previous posts
sudo nano tilestache.cfg

change hostname of pi:
start tilestache: (assuming your pi is set for hostname pitracker.local)
tilestache-server.py -c /home/pi/src/tilestache/tilestache.cfg -i pitracker.local -p 8080

Installing traccar.org on raspberry pi 3

from fresh raspbian distribution image
in a terminal

1. expand filesystem and refresh raspbian
raspi-config
follow instructions to expand filesystem to fill SD card
sudo apt-get update
sudo apt-get upgrade
1.a optional - I operate via RDP gui: sudo apt-get install xrdp

2. download traccar.org Linux ARM
currently this version:
https://github.com/tananaev/traccar/releases/download/v3.6/traccar-linux-arm-3.6.zip
extract to e.g. /home/pi/downloads
sudo /home/pi/Downloads/traccar.run

sudo /opt/traccar/bin/traccar start


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.