meshcore_py/examples/serial_msg.py

19 lines
376 B
Python
Raw Normal View History

2025-03-29 12:32:10 +01:00
#!/usr/bin/python
import asyncio
from meshcore import MeshCore
2025-03-30 08:36:39 +02:00
PORT = "/dev/ttyUSB0"
BAUDRATE = 115200
DEST = "mchome"
MSG = "hello from serial"
2025-03-29 12:32:10 +01:00
async def main () :
2025-04-08 22:56:16 -07:00
mc = await MeshCore.create_serial(PORT, BAUDRATE)
2025-03-29 12:32:10 +01:00
await mc.ensure_contacts()
2025-04-08 22:56:16 -07:00
await mc.commands.send_msg(bytes.fromhex(mc.get_contact_by_name(DEST)["public_key"])[0:6], MSG)
2025-03-29 12:32:10 +01:00
asyncio.run(main())
2025-04-08 22:56:16 -07:00