Skip to content

Implemented radio broadcast#10

Merged
evoggy merged 4 commits intomainfrom
evoggy/cr-broadcast
Mar 19, 2026
Merged

Implemented radio broadcast#10
evoggy merged 4 commits intomainfrom
evoggy/cr-broadcast

Conversation

@evoggy
Copy link
Copy Markdown
Member

@evoggy evoggy commented Mar 19, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-link and add an explicit crazyradio dependency to support channel handling.
  • Update Cargo.lock to 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.

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)))?;
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>> {
@evoggy evoggy merged commit 43dc1ae into main Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants