mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
ensure contacts before setting up events
This commit is contained in:
@@ -29,6 +29,7 @@ async def main () :
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
mc = await MeshCore.create_ble(args.addr)
|
mc = await MeshCore.create_ble(args.addr)
|
||||||
|
await mc.ensure_contacts()
|
||||||
|
|
||||||
# Subscribe to private messages
|
# Subscribe to private messages
|
||||||
private_subscription = mc.subscribe(EventType.CONTACT_MSG_RECV, handle_message)
|
private_subscription = mc.subscribe(EventType.CONTACT_MSG_RECV, handle_message)
|
||||||
@@ -38,8 +39,6 @@ async def main () :
|
|||||||
|
|
||||||
await mc.start_auto_message_fetching()
|
await mc.start_auto_message_fetching()
|
||||||
|
|
||||||
await mc.ensure_contacts()
|
|
||||||
|
|
||||||
contact = mc.get_contact_by_name(args.dest)
|
contact = mc.get_contact_by_name(args.dest)
|
||||||
if contact is None:
|
if contact is None:
|
||||||
print(f"Contact '{DEST}' not found in contacts.")
|
print(f"Contact '{DEST}' not found in contacts.")
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ async def main () :
|
|||||||
|
|
||||||
mc = await MeshCore.create_tcp(args.addr, args.port)
|
mc = await MeshCore.create_tcp(args.addr, args.port)
|
||||||
|
|
||||||
|
await mc.ensure_contacts()
|
||||||
|
|
||||||
# Subscribe to private messages
|
# Subscribe to private messages
|
||||||
private_subscription = mc.subscribe(EventType.CONTACT_MSG_RECV, handle_message)
|
private_subscription = mc.subscribe(EventType.CONTACT_MSG_RECV, handle_message)
|
||||||
|
|
||||||
@@ -40,8 +42,6 @@ async def main () :
|
|||||||
|
|
||||||
await mc.start_auto_message_fetching()
|
await mc.start_auto_message_fetching()
|
||||||
|
|
||||||
await mc.ensure_contacts()
|
|
||||||
|
|
||||||
contact = mc.get_contact_by_name(args.dest)
|
contact = mc.get_contact_by_name(args.dest)
|
||||||
if contact is None:
|
if contact is None:
|
||||||
print(f"Contact '{DEST}' not found in contacts.")
|
print(f"Contact '{DEST}' not found in contacts.")
|
||||||
|
|||||||
Reference in New Issue
Block a user