mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
Fix example
This commit is contained in:
@@ -3,16 +3,18 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from meshcore import MeshCore
|
from meshcore import MeshCore
|
||||||
|
|
||||||
PORT = "/dev/ttyUSB0"
|
PORT = "/dev/tty.usbserial-583A0069501"
|
||||||
BAUDRATE = 115200
|
BAUDRATE = 115200
|
||||||
DEST = "mchome"
|
DEST = "🦄"
|
||||||
MSG = "hello from serial"
|
MSG = "hello from serial"
|
||||||
|
|
||||||
async def main () :
|
async def main () :
|
||||||
mc = await MeshCore.create_serial(PORT, BAUDRATE)
|
mc = await MeshCore.create_serial(PORT, BAUDRATE)
|
||||||
|
|
||||||
await mc.ensure_contacts()
|
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())
|
asyncio.run(main())
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ class MeshCore:
|
|||||||
if not self._contacts:
|
if not self._contacts:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for contact_id, contact in self._contacts.items():
|
for _, contact in self._contacts.items():
|
||||||
if contact.get("adv_name", "").lower() == name.lower():
|
if contact.get("adv_name", "").lower() == name.lower():
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user