Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.1.2 #10

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "radio-telemetry-tracker-drone-comms-package"
version = "0.1.1"
version = "0.1.2"
description = ""
authors = ["Tyler Flar <[email protected]>"]
license = "Other"
Expand Down
2 changes: 1 addition & 1 deletion radio_telemetry_tracker_drone_comms_package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Package initialization for the Radio Telemetry Tracker Drone Comms Package.
"""

__version__ = "0.1.1"
__version__ = "0.1.2"

from radio_telemetry_tracker_drone_comms_package.data_models import (
ConfigRequestData,
Expand Down
3 changes: 3 additions & 0 deletions radio_telemetry_tracker_drone_comms_package/drone_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
ack_timeout: float = 2.0,
max_retries: int = 5,
on_ack_callback: Callable[[int], None] | None = None,
on_ack_success: Callable[[int], None] | None = None,
) -> None:
"""Initialize DroneComms instance.

Expand All @@ -77,6 +78,7 @@ def __init__(
ack_timeout: Timeout in seconds for acknowledgment packets
max_retries: Maximum number of packet retransmission attempts
on_ack_callback: Optional callback function when acknowledgment times out, receives packet_id
on_ack_success: Optional callback function when acknowledgment is received, receives packet_id
"""
if radio_config is None:
msg = "Radio config is required"
Expand Down Expand Up @@ -107,6 +109,7 @@ def __init__(
ack_timeout=ack_timeout,
max_retries=max_retries,
on_ack_timeout=on_ack_callback,
on_ack_success=on_ack_success,
)

# Each entry: "proto_field_name": (extractor_function, handler_function)
Expand Down
5 changes: 5 additions & 0 deletions radio_telemetry_tracker_drone_comms_package/transceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
ack_timeout: float = 2.0,
max_retries: int = 5,
on_ack_timeout: Callable[[int], None] | None = None,
on_ack_success: Callable[[int], None] | None = None,
) -> None:
"""Initialize the PacketManager.

Expand All @@ -38,11 +39,13 @@ def __init__(
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, receives packet_id.
on_ack_success: Optional callback when packet acknowledgment is received, receives packet_id.
"""
self.radio_interface = radio_interface
self.ack_timeout = ack_timeout
self.max_retries = max_retries
self.on_ack_timeout = on_ack_timeout
self.on_ack_success = on_ack_success

self.send_queue: queue.PriorityQueue[tuple[int, float, RadioPacket]] = queue.PriorityQueue()
# Maps packet_id -> { "packet": RadioPacket, "send_time": float, "retries": int }
Expand Down Expand Up @@ -140,6 +143,8 @@ def _handle_incoming_packet(self, packet: RadioPacket) -> None:
ack_id = packet.ack_pkt.ack_id
if ack_id in self.outstanding_acks:
del self.outstanding_acks[ack_id]
if self.on_ack_success:
self.on_ack_success(ack_id)
return

base = self._get_base(packet)
Expand Down
Loading