Crate ohea_lock

Crate ohea_lock 

Source
Expand description

§Ohea Lock

A Rust library for controlling Ohea Lock BLE smart locks.

This library provides a protocol-focused implementation for communicating with Ohea Lock devices over Bluetooth Low Energy. The core library is transport-agnostic, with optional btleplug support for desktop platforms.

§Features

  • btleplug-support: Enable btleplug-based transport for desktop platforms.

§Architecture

The library is structured in layers:

  1. Protocol Layer (protocol): UUIDs, constants, and protocol types.
  2. Transport Layer (transport): Abstract trait for BLE operations.
  3. High-Level API (OheaLock): Convenient interface for lock operations.

§Example

use ohea_lock::{OheaLock, btleplug::BtleplugTransport};

// Assuming `peripheral` is an already-paired btleplug Peripheral
let transport = BtleplugTransport::connect_and_discover(peripheral).await?;
let lock = OheaLock::new(transport);

// Get device info
let info = lock.get_device_info().await?;
println!("Battery: {}%", info.battery_level);

// Control the lock
lock.unlock().await?;
lock.lock().await?;

Re-exports§

pub use error::Error;
pub use error::Result;
pub use protocol::DeviceInfo;
pub use protocol::LockState;
pub use transport::Transport;
pub use transport::TransportExt;

Modules§

error
Error types for the Ohea Lock library.
protocol
Protocol constants and types for Ohea Lock BLE communication.
transport
Transport trait abstraction for BLE communication.

Structs§

OheaLock
High-level interface for controlling an Ohea Lock device.