Created
October 5, 2022 04:02
-
-
Save joshcarter/7908328a5e2dfb1c2d57584f4f42d7fd to your computer and use it in GitHub Desktop.
Meshtastic Python API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
import meshtastic | |
import meshtastic.serial_interface | |
from pubsub import pub | |
def on_receive(packet, interface): | |
print(f'received: {packet}') | |
def on_connection(interface, topic=pub.AUTO_TOPIC): | |
interface.sendText('hello mesh') | |
def run(): | |
pub.subscribe(on_receive, 'meshtastic.receive') | |
pub.subscribe(on_connection, 'meshtastic.connection.established') | |
interface = meshtastic.serial_interface.SerialInterface('/dev/cu.usbmodem54750409071') | |
num = 1 | |
while True: | |
sleep(1) | |
interface.sendText(f'mac: {num}') | |
num += 1 | |
if __name__ == '__main__': | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment