-
Notifications
You must be signed in to change notification settings - Fork 3
GPS Mapper Service
The GPS Mapper Service allows your transducer to show up on the OpenChirp public map. You can add the GPS Mapping service to any device and it will monitor the latitude
, longitude
and/or gps
transducers for your device and update its position accordingly. You can click anywhere on the map to pull up a GPS coordinate.
- Go to your device and click on the Services tab
- Click Link Service and scroll down to GPS Mapper
- The configuration will ask you for the Marker Type. This is used to set the color and layer for your device. Currently we only support the name
gateway
or strings withgw
included for gateway devices or any other name for a transducer. You can also leave the field blank, but the name you enter will be the prefix to your transducer's name in the popup on the map. - Now click on the Transducer tab and add a
latitude
andlongitude
transducers. The units don't matter, but we often usegps
. Make sure to select Actuable if you want to use a command to manually set the location. You can use latitude / longitude OR gps. If you use both, the last one updated will be reflected on the map.
- Click on the Command tab and add a command that sets a value for your latitude and longitude. Press the Run command and wait a few seconds to refresh the map
- Thats it!
Other notes:
- Removing the service will remove your device from the map. Feel free to add and remove as often as you like.
- You can also create a transducer called
gps
and put coordinates in as lat,lon. For example40.44,-79.94
, would be a valid GPS coordinate - We filter out coordinates with 0 in the lat or lon
- Some devices like gateways will automatically publish latitude and longitude values, so its easy to place them on the map by adding the service
The GPS Mapper Service is built using the OpenChirp golang framework. The service subscribes to the latitude, longitude and gps transducers of any device added and generates a static website that uses Leaflet's map interface. Every 10 seconds (defined by static-update-rate parameter) it generates a file called "oc-geojson.js" that is read by our "index.html" file within the leaflet project. The framework keeps a local copy of all coordinates and names in a file called "gpsDB.dat" that is loaded upon restart and updated every time a static map is generated.
The framework also serves dynamic content:
- http://openchirp.io:9000/map/owner/OWNER_ID
- http://openchirp.io:9000/map/device/DEVICE_ID
- http://openchirp.io:9000/map/public/all
When configuring the service make sure to add a Device configuration for "Marker Type" which is used internal to decide about the marker color or layer.
There are a few modifications that need to be made with the standard leaflet install:
- Place our "index.html" file in the root of the leaflet directory
- Point the service towards the same directory with the "geojson-path" parameter to generate the dynamic json file that "index.html" reads
- Copy the images/marker-icon-red.png file into the leaflet image directory
- "header.txt" and "footer.txt" are used as the head and tail of the dynamic web page. They are loaded into memory at startup
Building in your go source dir:
> go get ../.
> go build
For usage information see:
NAME:
gpsMapper-service
USAGE:
gpsMapper [global options] command [command options] [arguments...]
VERSION:
1.0
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--framework-server value OpenChirp framework server's URI (default: "http://localhost:7000") [$FRAMEWORK_SERVER]
--mqtt-server value MQTT server's URI (e.g. scheme://host:port where scheme is tcp or tls) (default: "tls://localhost:1883") [$MQTT_SERVER]
--service-id value OpenChirp service id [$SERVICE_ID]
--service-token value OpenChirp service token [$SERVICE_TOKEN]
--log-level value debug=5, info=4, warning=3, error=2, fatal=1, panic=0 (default: 4) [$LOG_LEVEL]
--geojson-path value Path to geojson file for leaflet (default: "oc-geojason.js") [$GEOJSON_PATH]
--http-port value Port for serving dynamic content (default: 9000) [$HTTP_PORT]
--static-update-rate value Interval in seconds for static content update (default: 30) [$STATIC_UPDATE_RATE]
--help, -h show help
--version, -v print the version
COPYRIGHT:
See https://github.com/openchirp/example-service for copyright information
Example environmental variables (actual service id and token *'d out):
export FRAMEWORK_SERVER="http://openchirp.andrew.cmu.edu:7000"
export MQTT_SERVER="tls://openchirp.andrew.cmu.edu:1883"
export SERVICE_ID="5a43c0ffa099b429528*****"
export SERVICE_TOKEN="bjgfU1dPytBB8jQRXHT5l0Nrxy*****"
export GEOJSON_PATH="./leaflet/oc-geojson.js"
export HTTP_PORT="9000"
export STATIC_UPDATE_RATE="10"
OpenChirp is a research project started by the WiseLab at Carnegie Mellon University.
- Simple Device Tutorial
- PubSub Overview
- Time Series Data
- Device Tutorial
- Generate User Token Tutorial
- LoRaWAN Specific
-
Services
- Byte Translator
- Easybits
- Time Series Storage
- Event Trigger
- LoRaWAN Gateway
- GPS Mapper
- Custom Service
- Openchirp Packages
- REST API