fifieldt / meshtastic-map-backend

Backend for processing data from meshtastic mesh or MQTT
GNU General Public License v3.0
3 stars 1 forks source link

Meshtastic Map Backend

The Meshtastic Map Backend is designed to recieve meshtastic packets from the mesh or an MQTT server, process it, and offer a geoJSON API that can be consumed by mapping front-ends.

Connecting

There are two main modes, Local Mesh and MQTT.

Direct Mesh Connection

If you have a Meshtastic Device connected to your PC, you can use the Meshtastic Serial Interface to receive packets. Start the backend using the --port or --ble arguments to connect to the device.

./backend.py --port /dev/ttyACM0

MQTT

To gather data from an MQTT server instead, specify the standard set of variables for an MQTT connection:

./backend.py --mqtt-host mqtt.meshtastic.org --mqtt-user meshdev --mqtt-pass large4cats --mqtt-topic msh/TW/#

API Endpoints

By default, an HTTP server will run at port 8100, and offer the following endpoints:

Each node listed in /nodes may have the following properties:

Other Features

Limit area

Specify a point with --latitude and --longitude, and set --max-distance to limit the nodes recorded to within that number of kilometers of the point. Set --max-distance 0 to disable the limit.

Exclusive mode

If you only want to map your own nodes, list each node id (one-per-line) in a file and pass that file to the --exclusive parameter.

Debug Map

/map provides a basic leaflet.js map that show nodes and links, primarily for debugging. You can set the center of that map by specifying --latitude and --longitude, in addition to the zoom level (--zoom).

If you want to use an alternative source for the GeoJSON API endpoint, you can specify a URL using --geoJSON. If the app detects it is running as a Railway app, the Railway Public Endpoint will be used instead.

Map Reports Only

By default, when using MQTT, the backend only processes MAP_REPORT_APP packets. If you are using a private MQTT server for your local community, you can disable this limitation by specifying --map-reports-only False.

Show Last Message

Setting the --lastmessage to True will store and display the last message received by each node. This is disabled by default.

Running with Flask

Meshtastic Map Backend can be run with flask, using:

flask --app backend:main run