2025-03-29 12:32:10 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
from meshcore import MeshCore
|
|
|
|
|
|
2025-04-12 13:53:37 -07:00
|
|
|
PORT = "/dev/tty.usbserial-583A0069501"
|
2025-03-30 08:36:39 +02:00
|
|
|
BAUDRATE = 115200
|
2025-04-12 13:53:37 -07:00
|
|
|
DEST = "🦄"
|
2025-03-30 08:36:39 +02:00
|
|
|
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-12 13:53:37 -07:00
|
|
|
contact = mc.get_contact_by_name(DEST)
|
2025-04-12 13:53:37 -07:00
|
|
|
if not contact:
|
|
|
|
|
print(f"Contact {DEST} not found")
|
|
|
|
|
return
|
2025-04-12 13:53:37 -07:00
|
|
|
await mc.commands.send_msg(bytes.fromhex(contact["public_key"])[0:6], MSG)
|
|
|
|
|
print ("Message sent ... awaiting")
|
2025-03-29 12:32:10 +01:00
|
|
|
|
|
|
|
|
asyncio.run(main())
|
2025-04-08 22:56:16 -07:00
|
|
|
|