mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Fix example
This commit is contained in:
parent
7b28029ae0
commit
b700ae75e9
2 changed files with 6 additions and 4 deletions
|
|
@ -3,16 +3,18 @@
|
|||
import asyncio
|
||||
from meshcore import MeshCore
|
||||
|
||||
PORT = "/dev/ttyUSB0"
|
||||
PORT = "/dev/tty.usbserial-583A0069501"
|
||||
BAUDRATE = 115200
|
||||
DEST = "mchome"
|
||||
DEST = "🦄"
|
||||
MSG = "hello from serial"
|
||||
|
||||
async def main () :
|
||||
mc = await MeshCore.create_serial(PORT, BAUDRATE)
|
||||
|
||||
await mc.ensure_contacts()
|
||||
await mc.commands.send_msg(bytes.fromhex(mc.get_contact_by_name(DEST)["public_key"])[0:6], MSG)
|
||||
contact = mc.get_contact_by_name(DEST)
|
||||
await mc.commands.send_msg(bytes.fromhex(contact["public_key"])[0:6], MSG)
|
||||
print ("Message sent ... awaiting")
|
||||
|
||||
asyncio.run(main())
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ class MeshCore:
|
|||
if not self._contacts:
|
||||
return None
|
||||
|
||||
for contact_id, contact in self._contacts.items():
|
||||
for _, contact in self._contacts.items():
|
||||
if contact.get("adv_name", "").lower() == name.lower():
|
||||
return contact
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue