(filling in details in spare moments today ) …
In case it’s useful, below is the Meshtastic-Python script I used on my ‘base station’ (a laptop with a Heltec Meshtastic widget plugged into a USB port) to listen for messages and reply to them, adding the SNR. I also added ‘hopLimit’, because at the time I thought it was a measure of the number of hops (not, as I now realize should have been obvious, a limit on the number of hops).
import meshtastic
import time
from pubsub import pub
def onReceive(packet): # called when a packet arrives
print(f"Received: {packet}")
if packet['decoded']['data'] is not None:
msg = packet['decoded']['data']['text']
rxSnr = packet['rxSnr']
hopLimit = packet['hopLimit']
print(f"message: {msg}")
reply="got msg \'{}\' with rxSnr: {} and hopLimit: {}".format(msg,rxSnr,hopLimit)
print("Sending reply: ",reply)
interface.sendText(reply)
def onConnection(): # called when we (re)connect to the radio
# defaults to broadcast, specify a destination ID if you wish
interface.sendText("hello mesh")
pub.subscribe(onReceive, "meshtastic.receive")
pub.subscribe(onConnection, "meshtastic.connection.established")
interface = meshtastic.StreamInterface()
When I then went out into the kayak and sent off messages using an Android phone + another Heltec Meshtastic widget, the above script contributed to a ‘dialogue’ like this:
How fun is that?! Was very easy to do using out-of-the-box Meshtastic-Python functionality, with the demo scripts provided kindly provided the repo.
Question (no rush, just posting it in case someone happens to know ): is “number of hops this message took to reach me” is something one can access via the Meshtastic-python API?