Using the irbt library
The irbt crate is the library behind the CLI: port
discovery, framing and a typed client for every command. Add the registry
(see Installing the CLI), then:
cargo add irbt --registry selu
Example
use std::time::Duration;
use irbt::{Device, HidKey, Notification};
fn main() -> Result<(), irbt::Error> {
let device = Device::open(None)?; // auto-detect the bridge
let info = device.info()?;
println!("firmware {} (protocol v{})", info.firmware_version, info.protocol_version);
device.set_mapping(0x00FF_02FD, HidKey::Home)?;
for mapping in device.keymap()? {
println!("0x{:08X} -> {}", mapping.ir, mapping.key);
}
// Stream received IR codes.
device.set_monitor(true)?;
while let Some(notification) = device.next_notification(Duration::from_secs(30))? {
if let Notification::Event(event) = notification {
println!("{event:?}");
}
}
Ok(())
}
Device::opentakes a port path, orNoneto pick the only connected bridge.find_portslists them.- Each method sends one command and waits for its reply.
set_timeoutchanges how long it waits. - Events, log lines and unframed output (bootloader text, panic dumps) arrive
as
Notifications throughnext_notification. Device::from_ioruns the client over any reader/writer pair, e.g. in tests.
The protocol types are re-exported from irbt-proto
as irbt::proto.