Skip to content

AzraelSec/rs-duoco-stripx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rs-duoco-stripx

Crates.io Documentation License: MIT

A Rust library for controlling LED devices via Bluetooth Low Energy, created as an alternative to the official Duoco Stripx Android app.

About

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.

Features

  • 🔍 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

TODO

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

Installation

Add this to your Cargo.toml:

[dependencies]
rs-duoco-stripx = "0.1.0"
tokio = { version = "1.0", features = ["full"] }

Quick Start

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(())
}

Examples

Basic Color Control

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?;

Brightness Control

use rs_duoco_stripx::{Device, Command, LightMode};

// Set brightness to 75% in RGB mode
device.send_command(Command::ChangeBrightness(75, LightMode::MultipleRGBValue)).await?;

Lighting Modes

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?;

API Reference

Main Types

  • Device: Main service for device management and communication
  • Color: Color representation (Hex, Int, or Preset)
  • ColorMode: Various lighting effects and modes
  • Command: Commands to send to the device
  • LightMode: Brightness control modes

Device Management

  • Device::new(): Create a new device service
  • device.update_devices(): Scan for nearby devices
  • device.get_devices(): Get list of discovered devices
  • device.connect(address): Connect to a specific device
  • device.disconnect(): Disconnect from current device

Commands

  • Command::LightOn: Turn on the device
  • Command::LightOff: Turn off the device
  • Command::ChangeColor(color): Set device color
  • Command::ChangeBrightness(level, mode): Set brightness
  • Command::ChangeColorMode(mode): Set lighting mode

Requirements

  • Rust 1.70+
  • Bluetooth Low Energy adapter
  • Compatible LED device (originally controlled by Duoco Stripx Android app)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Library for controlling BLE LED devices supported by the Duoco Stripx Android app

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages