How to build a MeshCore tracker node
MeshCore has no Tracker role like Meshtastic, which lets a node broadcast its location periodically. MeshCore has the ability to request telemetry data from a node, but I wanted something that would let me keep an eye on my dog's location in realtime. I also wanted to use MeshCore if at all possible because I have a handful of radios and it's more convenient for me to have them all running the same firmware. This meant I needed to modify the MeshCore firmware myself in order to make a node that broadcasts its GPS coordinates every few seconds. I implemented the simplest thing that could possibly work.
With the code below you can build your own Tracker node that runs on MeshCore.
Clone MeshCore from github.
In the MeshCore source find MyMesh.cpp.
At the top of the file declare two variables for holding GPS coordinates.
double previousLat = 0; double previousLong = 0;
Locate the function void MyMesh::loop() {
Add this conditional.
if (millisHasNowPassed(advertTime)) {
if(previousLat != sensors.node_lat ||
previousLong != sensors.node_lon) {
// position has changed
advert();
}
previousLat = sensors.node_lat;
previousLong = sensors.node_lon;
advertTime = futureMillis(10000); // 10 seconds
}
That's it. As loop() continues to be called by the MeshCore firmware this code checks to see if the GPS coordinates have changed. If so, send an advert.
On your MeshCore companion node and the tracker node set them to repeater mode and choose a frequency like 918Mhz. Make sure the tracker is set to use its GPS and share location in adverts.