meshcore_py/examples/ble_t1000_msg.py

25 lines
542 B
Python
Raw Permalink Normal View History

2025-03-29 12:32:10 +01:00
#!/usr/bin/python
import asyncio
from meshcore import MeshCore
2025-03-30 08:42:52 +02:00
from meshcore import BLEConnection
2025-03-29 12:32:10 +01:00
2025-03-30 08:42:52 +02:00
ADDRESS = "t1000" # node ble adress or name
DEST = "mchome"
2025-03-29 12:32:10 +01:00
MSG = "Hello World"
async def main () :
2025-03-30 08:42:52 +02:00
con = BLEConnection(ADDRESS)
2025-03-29 12:32:10 +01:00
await con.connect()
mc = MeshCore(con)
await mc.connect()
await mc.ensure_contacts()
contact = mc.get_contact_by_name(DEST)
if contact is None:
print(f"Contact '{DEST}' not found in contacts.")
return
await mc.commands.send_msg(contact,MSG)
2025-03-29 12:32:10 +01:00
asyncio.run(main())