Struct crazyradio::Crazyradio[][src]

pub struct Crazyradio { /* fields omitted */ }
Expand description

Represents a Crazyradio

Holds the USB connection to a Crazyradio dongle. The connection is closed when this object goes out of scope.Crazyradio

Usage example:

use crazyradio::{Crazyradio, Error, Channel};

fn main() -> Result<(), Error> {
    let mut cr = Crazyradio::open_first()?;   // Open the first detected dongle

    // Set the radio channel
    cr.set_channel(Channel::from_number(42).unwrap());

    // Send a `null` packet
    let mut ack_data = [0u8; 32];
    let ack = cr.send_packet(&[0xff], &mut ack_data)?;

    println!("Ack received: {}, length: {}, data: {:?}", ack.received,
                                                         ack.length,
                                                         &ack_data[..ack.length]);

    Ok(())
}

Implementations

Open the first Crazyradio detected and returns a Crazyradio object.

The dongle is reset to boot values before being returned

Open the nth Crazyradio detected and returns a Crazyradio object.

Radios are ordered appearance in the USB device list. This order is platform-specific.

The dongle is reset to boot values before being returned

Open a Crazyradio by specifying its serial number

Example:

use crazyradio::Crazyradio;
let mut cr = Crazyradio::open_by_serial("FD61E54B7A")?;

Return an ordered list of serial numbers of connected Crazyradios

The order of the list is the same as accepted by the open_nth() function.

Return the serial number of this radio

Reset dongle parameters to boot values.

This function is called by Crazyradio::open_*.

Enable or disable caching of settings

If enabled, setting the radio channel, address or datarate will be ignored if the settings is the same as the one already set in the dongle

This is enabled by default and is a useful functionality to efficiently implement communication to multiple device as changing these settings require USB communication and is quite slow.

Set the radio channel.

Set the datarate.

Set the radio address.

Set the transmit power.

Set time to wait for the ack packet.

Set time to wait for the ack packet by specifying the max byte-length of the ack payload.

Set the number of time the radio will retry to send the packet if an ack packet is not received in time.

Set if the radio waits for an ack packet.

Should be disabled when sending broadcast packets.

Sends a packet to a range of channel and returns a list of channel that acked

Used to activally scann for receives on channels. This function sends

Launch the bootloader.

Consumes the Crazyradio since it is not usable after that (it is in bootlaoder mode …).

Set the radio in continious carrier mode.

In continious carrier mode, the radio will transmit a continious sine wave at the setup channel frequency using the setup transmit power.

Send a data packet and receive an ack packet.

Arguments

  • data: Up to 32 bytes of data to be send.
  • ack_data: Buffer to hold the data received from the ack packet payload. The ack payload can be up to 32 bytes, if this buffer length is lower than 32 bytes the ack data might be truncated. The length of the ack payload is returned in Ack::length.

Async implementations

Async version of open/getserial functions.

Implemented by launching a thread, calling the sync function and passing the result back though a channel. This is not the most efficient implementation but it keeps the lib executor-independent and these functions are only one-time-call in most programs.

This is supported on crate feature async only.

Async vesion of Crazyradio::open_first()

This is supported on crate feature async only.

Async vesion of Crazyradio::open_nth()

This is supported on crate feature async only.
This is supported on crate feature async only.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.