mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Add event filtering to support ACK tracking
This commit is contained in:
parent
478bcd92c1
commit
6dc87bafbb
9 changed files with 325 additions and 80 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import argparse
|
||||
import random
|
||||
from meshcore import MeshCore
|
||||
from meshcore.events import EventType
|
||||
|
||||
|
|
@ -29,14 +30,23 @@ async def main():
|
|||
|
||||
# Send trace packet
|
||||
print(f"Sending trace packet...")
|
||||
result = await mc.commands.send_trace(path=args.path)
|
||||
# Send trace with a path if provided
|
||||
tag = random.randint(1, 0xFFFFFFFF)
|
||||
result = await mc.commands.send_trace(path=args.path, tag=tag)
|
||||
|
||||
if result:
|
||||
print("Trace packet sent successfully")
|
||||
print("Waiting for trace response...")
|
||||
# Check if the result has a success indicator
|
||||
if result.get("success") == False:
|
||||
print(f"Failed to send trace packet: {result.get('reason', 'unknown error')}")
|
||||
elif result:
|
||||
print(f"Trace packet sent successfully with tag={tag}")
|
||||
print("Waiting for trace response matching our tag...")
|
||||
|
||||
# Wait for a trace response with 15-second timeout
|
||||
event = await mc.wait_for_event(EventType.TRACE_DATA, timeout=15)
|
||||
# Wait for a trace response with our specific tag
|
||||
event = await mc.wait_for_event(
|
||||
EventType.TRACE_DATA,
|
||||
attribute_filters={"tag": tag},
|
||||
timeout=15
|
||||
)
|
||||
|
||||
if event:
|
||||
trace = event.payload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue