Skip to content

Instantly share code, notes, and snippets.

@kareiva
Created September 28, 2020 10:57
Show Gist options
  • Save kareiva/8700d4ca9539c5eec1ff45e9c2f39ede to your computer and use it in GitHub Desktop.
Save kareiva/8700d4ca9539c5eec1ff45e9c2f39ede to your computer and use it in GitHub Desktop.
import meshtastic
from pubsub import pub
def onReceive(packet):
print(f"Received: {packet}")
if ( packet['hopLimit'] > 0 and "decoded" in packet and
packet['decoded']['data']['typ'] == 'CLEAR_TEXT' ):
interface.sendText(
'SNR ' + str(packet['rxSnr']) + ': ' + packet['decoded']['data']['text'])
print(f"Sent beacon")
pub.subscribe(onReceive, "meshtastic.receive")
interface = meshtastic.StreamInterface("/dev/ttyUSB1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment