A Rust library for controlling LED devices via Bluetooth Low Energy, created as an alternative to the official Duoco Stripx Android app.
This library was created by reverse engineering the official Duoco Stripx Android app to understand the Bluetooth Low Energy communication protocol used to control compatible LED devices. The Duoco Stripx app is the official Android application for controlling these LED devices, and this Rust library provides an alternative way to achieve the same functionality programmatically.
- 🔍 Device Discovery: Automatically discover nearby LED devices
- 🔗 Bluetooth Connection: Connect to devices via BLE
- 🎨 Color Control: Set custom RGB colors or use preset colors
- 🌈 Lighting Modes: Support for various lighting effects and modes
- 💡 Brightness Control: Adjust device brightness
- ⚡ Async Support: Built with tokio for async/await support
The following features are planned for future implementation:
- ⏰ Timing Functionality: Schedule when to automatically turn the device on/off
- 🎵 Music Sync: Light up the device synchronized with music/audio input
Add this to your Cargo.toml:
[dependencies]
rs-duoco-stripx = "0.1.0"
tokio = { version = "1.0", features = ["full"] }use rs_duoco_stripx::{Device, Color, ColorMode, Command};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize the device service
let mut device = Device::new().await?;
// Discover nearby devices
device.update_devices().await?;
let devices = device.get_devices().await;
if let Some(peripheral) = devices.first() {
// Connect to the first available device
device.connect(peripheral.address()).await?;
// Turn on the light
device.send_command(Command::LightOn).await?;
// Set a custom color
device.send_command(Command::ChangeColor(Color::Hex(255, 0, 0))).await?;
// Change to a preset color mode
device.send_command(Command::ChangeColorMode(ColorMode::AutoPlay)).await?;
}
Ok(())
}use rs_duoco_stripx::{Device, Color, Command};
// Set custom RGB color
device.send_command(Command::ChangeColor(Color::Hex(255, 100, 50))).await?;
// Use preset colors
device.send_command(Command::ChangeColor(Color::Preset(PresetColor::Blue))).await?;use rs_duoco_stripx::{Device, Command, LightMode};
// Set brightness to 75% in RGB mode
device.send_command(Command::ChangeBrightness(75, LightMode::MultipleRGBValue)).await?;use rs_duoco_stripx::{Device, ColorMode, Command};
// Set various lighting effects
device.send_command(Command::ChangeColorMode(ColorMode::SevenColorJump)).await?;
device.send_command(Command::ChangeColorMode(ColorMode::RgbWave)).await?;
device.send_command(Command::ChangeColorMode(ColorMode::AutoPlay)).await?;Device: Main service for device management and communicationColor: Color representation (Hex, Int, or Preset)ColorMode: Various lighting effects and modesCommand: Commands to send to the deviceLightMode: Brightness control modes
Device::new(): Create a new device servicedevice.update_devices(): Scan for nearby devicesdevice.get_devices(): Get list of discovered devicesdevice.connect(address): Connect to a specific devicedevice.disconnect(): Disconnect from current device
Command::LightOn: Turn on the deviceCommand::LightOff: Turn off the deviceCommand::ChangeColor(color): Set device colorCommand::ChangeBrightness(level, mode): Set brightnessCommand::ChangeColorMode(mode): Set lighting mode
- Rust 1.70+
- Bluetooth Low Energy adapter
- Compatible LED device (originally controlled by Duoco Stripx Android app)
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.