SmartAudio

This is a no_std platform-agnostic implementation of the TBS SmartAudio protocol in Rust.
Features
no_std, does not use the standard library or an allocator.
- Platform Agnostic, can be used on any MCU or platform.
- Provides a low-level interface to slice byte stream into valid frames.
- Supports
SmartAudio protocols 1.0, 2.0 and 2.1.
Usage Example
Here is a basic example of how to parse buffer using iterator:
use smartaudio::SmartAudioParser;
fn main() {
let raw: [u8; 72] = [
0xAA, 0x55, 0x01, 0x06, 0x00, 0x00, 0x01, 0x16, 0xE9, 0x4D, 0xAA, 0x55, 0x09, 0x06, 0x01, 0x00, 0x1A, 0x16, 0xE9, 0x0A, 0xAA, 0x55, 0x11, 0x0C, 0x00, 0x00, 0x00, 0x16, 0xE9, 0x0E, 0x03, 0x00, 0x0E, 0x14, 0x1A,
0x01, 0xAA, 0x55, 0x02, 0x03, 0x00, 0x01, 0x0F, 0xAA, 0x55, 0x02, 0x03, 0x0E, 0x01, 0x6D, 0xAA, 0x55, 0x03, 0x03, 0x00, 0x01, 0x4A, 0xAA, 0x55, 0x04, 0x04, 0x16, 0xE9, 0x01, 0xF8, 0xAA, 0x55, 0x05, 0x03, 0x0A, 0x01, 0x4F, ];
println!("Parssing frame from buffer using iterator:");
let mut parser = SmartAudioParser::new();
for frame in parser.iter_responses(&raw[..]) {
println!("{:#?}", frame.unwrap())
}
}
Here is a basic example feeding data stream one byte at time:
use smartaudio::Response;
use smartaudio::SmartAudioParser;
fn main() {
let mut parser = SmartAudioParser::new();
let raw_settings_v20: [u8; 10] = [
0xAA, 0x55, 0x09, 0x06, 0x01, 0x00, 0x1A, 0x16, 0xE9, 0x0A, ];
println!("Parssing raw packet:");
for b in &raw_settings_v20[0..raw_settings_v20.len()] {
let reult = parser.push_byte(*b);
match reult {
Ok(Some(Response::GetSettings(settings))) => {
println!("{:#?}", settings);
println!("\n");
println!("Version: {:?}", settings.version);
println!("Channel: {:?}", settings.channel);
println!("Power Level: {:?}", settings.power_level);
println!("Unlocked: {:?}", settings.unlocked);
}
Err(e) => eprintln!("Error parsing packet: {:?}", e),
_ => (),
}
}
}
Installation
Add smartaudio to your Cargo.toml:
[dependencies]
smartaudio = "*"
Or use the command line:
cargo add smartaudio
License
This project is licensed under the Apache 2.0. See the LICENSE file for details.
Protocol Specification
tbs_smartaudio_rev09.pdf