Skip to content

Commit

Permalink
refactor: update acknowledgment callback signatures in DroneComms and…
Browse files Browse the repository at this point in the history
… PacketManager
  • Loading branch information
TylerFlar committed Dec 25, 2024
1 parent 8470688 commit dfe345c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions radio_telemetry_tracker_drone_comms_package/drone_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def __init__(
radio_config: RadioConfig = None,
ack_timeout: float = 2.0,
max_retries: int = 5,
on_ack_callback: Callable[[RadioPacket], None] | None = None,
on_ack_callback: Callable[[int], None] | None = None,
) -> None:
"""Initialize DroneComms instance.
Args:
radio_config: Configuration for radio interface
ack_timeout: Timeout in seconds for acknowledgment packets
max_retries: Maximum number of packet retransmission attempts
on_ack_callback: Optional callback function when acknowledgment is received
on_ack_callback: Optional callback function when acknowledgment times out, receives packet_id
"""
if radio_config is None:
msg = "Radio config is required"
Expand Down
8 changes: 4 additions & 4 deletions radio_telemetry_tracker_drone_comms_package/transceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def __init__(
radio_interface: RadioInterface,
ack_timeout: float = 2.0,
max_retries: int = 5,
on_ack_timeout: Callable[[RadioPacket], None] | None = None,
on_ack_timeout: Callable[[int], None] | None = None,
) -> None:
"""Initialize the PacketManager.
Args:
radio_interface: Interface for radio communication.
ack_timeout: Time in seconds to wait for acknowledgment.
max_retries: Maximum number of retransmission attempts.
on_ack_timeout: Optional callback when packet acknowledgment times out.
on_ack_timeout: Optional callback when packet acknowledgment times out, receives packet_id.
"""
self.radio_interface = radio_interface
self.ack_timeout = ack_timeout
Expand Down Expand Up @@ -121,10 +121,10 @@ def _retry_outstanding_packets(self) -> None:
to_remove.append(pid)

for pid in to_remove:
timed_out_pkt = self.outstanding_acks[pid]["packet"]
self.outstanding_acks[pid]["packet"]
del self.outstanding_acks[pid]
if self.on_ack_timeout:
self.on_ack_timeout(timed_out_pkt)
self.on_ack_timeout(pid)

def _recv_loop(self) -> None:
"""Continuously attempt to receive packets and handle them."""
Expand Down

0 comments on commit dfe345c

Please sign in to comment.