From 1a0203067e073f823f0f7ad1ce5b8ece8b0f7cb2 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 14 Apr 2025 10:48:24 +0200 Subject: [PATCH] ensure contacts before setting up events --- examples/ble_chat.py | 3 +-- examples/tcp_chat.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/ble_chat.py b/examples/ble_chat.py index 2bce138..2779d2b 100755 --- a/examples/ble_chat.py +++ b/examples/ble_chat.py @@ -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.") diff --git a/examples/tcp_chat.py b/examples/tcp_chat.py index 7323aa7..ef273e0 100755 --- a/examples/tcp_chat.py +++ b/examples/tcp_chat.py @@ -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.")