ensure contacts before setting up events

This commit is contained in:
Florent 2025-04-14 10:48:24 +02:00
parent 2b32564ad2
commit 1a0203067e
2 changed files with 3 additions and 4 deletions

View file

@ -29,6 +29,7 @@ async def main () :
args = parser.parse_args()
mc = await MeshCore.create_ble(args.addr)
await mc.ensure_contacts()
# Subscribe to private messages
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.ensure_contacts()
contact = mc.get_contact_by_name(args.dest)
if contact is None:
print(f"Contact '{DEST}' not found in contacts.")

View file

@ -32,6 +32,8 @@ async def main () :
mc = await MeshCore.create_tcp(args.addr, args.port)
await mc.ensure_contacts()
# Subscribe to private messages
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.ensure_contacts()
contact = mc.get_contact_by_name(args.dest)
if contact is None:
print(f"Contact '{DEST}' not found in contacts.")