Skip to content

Wireshark functionality#6

Merged
evoggy merged 9 commits intomasterfrom
evoggy/wireshark
Feb 10, 2026
Merged

Wireshark functionality#6
evoggy merged 9 commits intomasterfrom
evoggy/wireshark

Conversation

@evoggy
Copy link
Member

@evoggy evoggy commented Feb 4, 2026

Added functionality to sending data to the library and forwarding it to Wireshark.

In order to handle multiple connection to radios and to be able to close the USB radio
once all connections are dropped,  the LinkContext was using Arc<SharedCrazyradio> and Weak<SharedCrazyradio>.

This was not how the SharedCrazyradio was intended to be used, it was internded to be cloned to share the radio,
not access by multiple unmutable references.

This commit makes the SharedCrazyradio type encode this requirement by taking &mut self to most methods.
It also adds a WeakSharedCrazyradio to handle the USB device management.

The Crate version is bumped up since this is a breaking change.
Copy link

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 pull request adds Wireshark packet capture functionality to the Crazyradio driver. It introduces a callback-based mechanism that allows external code to intercept and process all packets sent and received by the radio, which is useful for debugging and protocol analysis.

Changes:

  • Added a new capture module with a global callback mechanism for packet capture
  • Integrated capture calls into send_packet and send_packet_no_ack methods to capture TX packets and ACK payloads
  • Added a radio_index field to identify different radio instances in captures
  • Added a new "wireshark" feature flag to make this functionality optional

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.

File Description
Cargo.toml Adds the "wireshark" feature flag with no dependencies
src/capture.rs New module providing callback registration and packet capture infrastructure using OnceLock and Mutex for thread-safe global state
src/lib.rs Integrates capture calls in packet send methods, adds radio_index field to Crazyradio struct for capture identification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@ataffanel ataffanel left a comment

Choose a reason for hiding this comment

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

Looks good, some documentation and naming comments, but the functionality is simple and sweet, great job!

///
/// This should be called once at initialization to enable packet capture.
/// Subsequent calls will be silently ignored.
pub fn set_callback(callback: CaptureCallback) {
Copy link
Member

Choose a reason for hiding this comment

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

Somewhere there should be some documentation about what is expected of this callback. Since it is called synchronously in-line with the packet handling, it should be as quick as possible to execute.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

src/lib.rs Outdated
//! - **shared_radio** enables [SharedCrazyradio] object that allows to share a radio between threads
//! - **async** enables async function to create a [Crazyradio] object and use the [SharedCrazyradio]
//! - **serde** emables [serde](https://crates.io/crates/serde) serialization/deserialization of the [Channel] struct
//! - **wireshark** enables packet capture to Wireshark
Copy link
Member

Choose a reason for hiding this comment

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

nitpick (?): There is nothing related to wireshark in this change. All there is is a way to capture packets. Maybe the documentation and fonctionality should be called something like "packet_capture" to make it clear that wireshark is not involve at this level.

Copy link
Member Author

Choose a reason for hiding this comment

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

None of the functionality in this crate or the crazyflie-lib-rs crate is strictly connected to Wireshark, it's not until you reach the extcap module (https://github.com/evoggy/wireshark-crazyflie) it's reformatted to fit Wireshark. So I'll rename it all the way and remove any reference to Wireshark.

@evoggy evoggy requested a review from ataffanel February 7, 2026 12:38
@evoggy evoggy merged commit 2d17ddc into master Feb 10, 2026
1 check passed
@evoggy evoggy deleted the evoggy/wireshark branch February 10, 2026 09:33
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.

4 participants