Skip to main content

skydroid_protocol/
lib.rs

1//! # skydroid-fpv
2//!
3//! A **`no_std`**, **allocation-free** Rust implementation of the Skydroid
4//! camera FPV control protocol (reverse-engineered from the Android app,
5//! see `PROTOCOL.md`).
6//!
7//! The crate builds packets to **send** ([`packet`], [`command`]) and parses
8//! frames you **receive** ([`framing`]), with **no heap allocation**: all
9//! output is written into caller-provided buffers. It works on bare-metal
10//! embedded targets and normal OS projects alike.
11//!
12//! # Features
13//! * `default = []` — pure `no_std`, no `alloc`, no `std`.
14//! * `std` — enables the optional OS socket transport ([`transport`]).
15//! * `transport` — implies `std`; enables the [`transport`] module.
16//!
17//! # Quick start (send a command)
18//! ```
19//! use skydroid_protocol::packet::build_command;
20//! use skydroid_protocol::command::Capture;
21//!
22//! let mut out = [0u8; 32];
23//! let n = build_command(&Capture::TakePicture, &mut out).unwrap();
24//! let wire = &out[..n]; // bytes ready for the socket
25//! assert_eq!(&wire[..12], b"#TPUD2wCAP01");
26//! ```
27
28#![cfg_attr(not(feature = "std"), no_std)]
29#![forbid(unsafe_code)]
30
31pub mod at;
32pub mod command;
33pub mod framing;
34pub mod hex;
35pub mod packet;
36
37#[cfg(feature = "transport")]
38pub mod transport;
39
40/// Maximum length of an assembled `#tp` frame payload (from the app's
41/// `ARLINK_USR_DATA_MAX_LEN` = 16384).
42pub const MAX_PACKET_LEN: usize = 16384;