rust-patlite-beacon

Crates.iorust-patlite-beacon
lib.rsrust-patlite-beacon
version0.1.1
created_at2025-09-11 00:57:47.494776+00
updated_at2025-09-11 21:55:15.695287+00
descriptionA Rust library and CLI tool for controlling USB PATLITE beacon devices
homepagehttps://github.com/benburkhart1/rust-patlite-beacon
repositoryhttps://github.com/benburkhart1/rust-patlite-beacon
max_upload_size
id1833194
size64,638
Ben B (benburkhart1)

documentation

https://docs.rs/rust-patlite-beacon

README

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:

  1. Copy the provided udev rules file to your system:

    sudo cp udev/99-patlite-beacon.rules /etc/udev/rules.d/
    
  2. Reload the udev rules:

    sudo udevadm control --reload-rules
    sudo udevadm trigger
    
  3. 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(())
}
Commit count: 8

cargo fmt