Conversation
ataffanel
approved these changes
Mar 19, 2026
There was a problem hiding this comment.
Pull request overview
This PR adds a new Python-exposed Rust binding for sending raw “no-ack” radio packets (broadcast-style) via a selected radio dongle/channel, enabling P2P-style communication workflows.
Changes:
- Add
LinkContext.send_radio_broadcast(...)async Python method backed by a Crazyradio no-ack send. - Bump
crazyflie-linkand add an explicitcrazyradiodependency to support channel handling. - Update
Cargo.lockto reflect dependency changes.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
rust/src/link_context.rs |
Adds the new async send_radio_broadcast Python API and its input validation / error mapping. |
rust/Cargo.toml |
Updates Rust dependencies (crazyflie-link bump, adds crazyradio). |
rust/Cargo.lock |
Lockfile updates for the dependency version changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rust/src/link_context.rs
Outdated
Comment on lines
+97
to
+105
| fn send_radio_broadcast<'py>(&self, py: Python<'py>, radio_nth: usize, channel: u8, address: Vec<u8>, data: Vec<u8>) -> PyResult<Bound<'py, PyAny>> { | ||
| if address.len() != 5 { | ||
| return Err(PyRuntimeError::new_err("Address must be exactly 5 bytes")); | ||
| } | ||
| let mut addr_array = [0u8; 5]; | ||
| addr_array.copy_from_slice(&address); | ||
|
|
||
| let ch = crazyradio::Channel::from_number(channel) | ||
| .map_err(|e| PyRuntimeError::new_err(format!("Invalid channel: {:?}", e)))?; |
rust/src/link_context.rs
Outdated
| addr_array.copy_from_slice(&address); | ||
|
|
||
| let ch = crazyradio::Channel::from_number(channel) | ||
| .map_err(|e| PyRuntimeError::new_err(format!("Invalid channel: {:?}", e)))?; |
Comment on lines
+87
to
+113
| /// Send a radio broadcast packet (no acknowledgement) on a specific radio and channel | ||
| /// | ||
| /// This sends a raw packet without expecting an ack, useful for P2P communication. | ||
| /// | ||
| /// # Arguments | ||
| /// * `radio_nth` - Radio dongle index (usually 0) | ||
| /// * `channel` - Radio channel number (0-125) | ||
| /// * `address` - 5-byte destination address | ||
| /// * `data` - Packet payload bytes | ||
| #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] | ||
| fn send_radio_broadcast<'py>(&self, py: Python<'py>, radio_nth: usize, channel: u8, address: Vec<u8>, data: Vec<u8>) -> PyResult<Bound<'py, PyAny>> { | ||
| if address.len() != 5 { | ||
| return Err(PyRuntimeError::new_err("Address must be exactly 5 bytes")); | ||
| } | ||
| let mut addr_array = [0u8; 5]; | ||
| addr_array.copy_from_slice(&address); | ||
|
|
||
| let ch = crazyradio::Channel::from_number(channel) | ||
| .map_err(|e| PyRuntimeError::new_err(format!("Invalid channel: {:?}", e)))?; | ||
|
|
||
| let inner = self.inner.clone(); | ||
| pyo3_async_runtimes::tokio::future_into_py(py, async move { | ||
| let mut radio = inner.get_radio(radio_nth).await | ||
| .map_err(|e| PyRuntimeError::new_err(format!("Failed to get radio: {:?}", e)))?; | ||
| radio.send_packet_no_ack_async(ch, addr_array, data).await | ||
| .map_err(|e| PyRuntimeError::new_err(format!("Broadcast failed: {:?}", e)))?; | ||
| Ok(()) |
Comment on lines
+87
to
+97
| /// Send a radio broadcast packet (no acknowledgement) on a specific radio and channel | ||
| /// | ||
| /// This sends a raw packet without expecting an ack, useful for P2P communication. | ||
| /// | ||
| /// # Arguments | ||
| /// * `radio_nth` - Radio dongle index (usually 0) | ||
| /// * `channel` - Radio channel number (0-125) | ||
| /// * `address` - 5-byte destination address | ||
| /// * `data` - Packet payload bytes | ||
| #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] | ||
| fn send_radio_broadcast<'py>(&self, py: Python<'py>, radio_nth: usize, channel: u8, address: Vec<u8>, data: Vec<u8>) -> PyResult<Bound<'py, PyAny>> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.