crazyradio-webusb

Crates.iocrazyradio-webusb
lib.rscrazyradio-webusb
version0.2.1
sourcesrc
created_at2021-09-24 13:10:15.602288
updated_at2021-09-25 13:06:20.916372
descriptionCrazyradio USB dongle driver for WebUSB
homepage
repositoryhttps://github.com/ataffanel/crazyradio-webusb-rs
max_upload_size
id455847
size29,225
Arnaud Taffanel (ataffanel)

documentation

README

Crazyradio webusb rust driver

Driver to use Crazyradio in Rust using the WebUSB API.

This driver is intended to be used when targetting the web browser with Wasm. It implements the async API of the native Crazyradio crate.

Versioning

This repos follows the version of the crazyradio crate. For example, version 0.2.x of this crate implements the same async API as version 0.2.x of the crazyradio crate.

This allows to 'duck type' this crate and the crazyradio crate, for example this is done in the crazyflie-link crate:

#[cfg(feature = "native")]
pub(crate) use crazyradio;
#[cfg(feature = "webusb")]
pub(crate) use crazyradio_webusb as crazyradio;

Compiling requirement

Webusb is still an unstable API and so the web-sys crate requires a specific unstable build flag to compile it in. This can be done by adding a .cargo/config.toml file to your project with the content:

[build]
rustflags = ["--cfg=web_sys_unstable_apis"]

Limitations

This lib can only open one radio when using the Crazyradio::open_nth_async() function. This is only a UI limitation, not a hard one, see ticket #1 if you are interested in the problem and in helping resolving it.

Running tests

A couple of tests can be run in a web browser using wasm_bindgen_test:

wasm-pack test --chrome

To run, there should be at least one Crazyradio connected and paired on the test url http://localhost:8000. The easiest to achieve that is to open the Crazyradio dongle from a development Crazyflie web client.

Commit count: 8

cargo fmt