Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- pip install meshtastic pypubsub
- """
- import meshtastic
- import meshtastic.serial_interface
- from pubsub import pub
- from datetime import datetime
- import time
- from time import gmtime, strftime
- TOPIC_RX ="meshtastic.receive"
- TOPIC_CONNECT="meshtastic.connection.established"
- def onConnect(interface, topic=pub.AUTO_TOPIC):
- """ on connect"""
- interface.sendText("Running " + getHeure())
- def onReceive(packet, interface):
- """ RX Meshtastic """
- print(f"DEBUG RX : {packet}")
- def onSend(interface,message, topic=pub.AUTO_TOPIC):
- """ TX Meshtastic """
- interface.sendText(message)
- def findInterface():
- """Recherche tty Meshtastic .. ou par défaut ttyUSB"""
- return meshtastic.serial_interface.SerialInterface()
- def subscriptions():
- """ subscribe Meshtastic topics"""
- pub.subscribe(onReceive, TOPIC_RX)
- pub.subscribe(onConnect, TOPIC_CONNECT)
- def getHeure():
- return strftime("%Y-%m-%d %H:%M:%S", gmtime())
- interface = findInterface()#Get interface /dev/ttyUSB0
- subscriptions() #Subscribe TOPICs
- # Main loop
- while True:
- onSend(interface,"Debug Live Mesh" +getHeure())
- time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement