2 releases
Uses new Rust 2024
| 0.1.1 | Sep 11, 2025 |
|---|---|
| 0.1.0 | Sep 11, 2025 |
#614 in Hardware support
27 downloads per month
Used in patlite-beacon-serv
39KB
838 lines
Rust PATLITE Beacon
A Rust library and CLI tool for controlling USB PATLITE beacon devices.
Features
- Control LED color (off, red, green, yellow, blue, purple, lightblue, white)
- Set LED patterns (solid, pattern1-6)
- Control buzzer patterns (continuous, sweep, intermittent, weak/strong attention, shining star, london bridge)
- Set buzzer volume (0-10)
- Read touch sensor state
- Scan for connected beacon devices
Installation
cargo build --release
USB Device Permissions
Linux
On Linux, you need to set up udev rules to access the USB beacon without root privileges:
-
Copy the provided udev rules file to your system:
sudo cp udev/99-patlite-beacon.rules /etc/udev/rules.d/ -
Reload the udev rules:
sudo udevadm control --reload-rules sudo udevadm trigger -
Disconnect and reconnect your USB beacon device.
After these steps, you should be able to run the beacon commands without sudo.
macOS
On macOS, you need to run the beacon commands with root privileges:
sudo cargo run -- --color red
Or if using the compiled binary:
sudo ./target/release/rust-beacon --color red
Usage
Quick Start
Set LED to red:
cargo run -- --color red
Commands
Scan for devices
cargo run -- scan
Set LED color and pattern
cargo run -- light red on
cargo run -- light blue pattern1
Control buzzer
cargo run -- buzzer sweep 3 # Play sweep sound 3 times
cargo run -- buzzer on 0 # Continuous buzzer
Set buzzer volume
cargo run -- volume 5
Advanced buzzer control (pattern, count, volume)
cargo run -- buzzer-ex shining-star 2 7
Read touch sensor
cargo run -- touch-sensor
Reset device (turn off LED and buzzer)
cargo run -- reset
Connection display settings
cargo run -- setting on
cargo run -- setting off
Shorthand Options
You can also use shorthand options:
cargo run -- --color red --pattern pattern1
cargo run -- --buzzer sweep --count 3 --volume 5
Library Usage
use rust_patlite_beacon::{Beacon, LedColor, LedPattern};
fn main() -> anyhow::Result<()> {
let beacon = Beacon::open()?;
beacon.set_light(LedColor::Red, LedPattern::On)?;
Ok(())
}
Dependencies
~4.5–6MB
~106K SLoC