Skip to main content

Crate crazyflie_link

Crate crazyflie_link 

Source
Expand description

This Crate implement the Crazyflie radio link connection using Crazyradio. It allows to scan for Crazyflies and to open a safe bidirectional radio connection using a Crazyradio.

The entry point to this Crate is the LinkContext, it keeps track of Crazyradio dongles and provides functions to open a link Connection.

A connection can then be used to send and receive packet with the Crazyflie.

Example:

// Create a link Context
let context = crazyflie_link::LinkContext::new();

// Scan for Crazyflies
let cf_found = context.scan([0xe7; 5]).await?;

if let Some(uri) = cf_found.first() {
    let connection = context.open_link(uri).await?;
    let packet = connection.recv_packet().await?;
    println!("Packet received: {:?}", packet);
}

§Cargo features

  • packet_capture - Enable packet capture via Unix socket (Unix only)

§Packet Capture

When the packet_capture feature is enabled, CRTP packets can be captured and sent to an external application for analysis. Call [capture::init()] at startup to connect to the capture socket.

The capture uses a Unix socket at /tmp/crazyflie-capture.sock. To view packets in Wireshark, use the extcap plugin from https://github.com/evoggy/wireshark-crazyflie.

§Capture Format

Each captured packet is sent with a 41-byte header followed by the CRTP packet data:

OffsetSizeFieldDescription
01link_type1 = Radio, 2 = USB
11direction0 = TX (to Crazyflie), 1 = RX (from CF)
212addressRadio address (5 bytes) or empty for USB
141channelRadio channel (0 for USB)
1516serialRadio/device serial number
318timestampMicroseconds since Unix epoch (LE)
392lengthCRTP packet length (LE)
41NdataCRTP packet (header + payload)

Structs§

Connection
Connection to a Crazyflie
LinkContext
Context for the link connections
Packet
CRTP data packet
SharedCrazyradio
Multi-user threaded Crazyradio

Enums§

ConnectionStatus
Describe the current link connection status
Error