br-ble 0.2.0

This is an Bluetooth
Documentation
use crate::device::{Characteristic, Device};

pub mod device;
#[cfg(target_os = "macos")]
pub mod mac;
#[cfg(target_os = "windows")]
pub mod win;
pub fn run<F>(factory: F)
where
    F: Fn() -> Box<dyn Handler>,
{
    #[cfg(target_os = "windows")]
    win::Win::new().run(factory);
    #[cfg(target_os = "macos")]
    mac::Mac::new().run(factory);
}

pub trait Handler {
    /// 蓝牙适配器开启
    fn on_adapter_open(&mut self);
    /// 蓝牙适配器关闭
    fn on_adapter_close(&mut self);
    /// 发现设备
    fn on_discover(&mut self, device: Device);
    /// 获取设备列表
    fn listen_connected(&mut self, device_list: Vec<String>);
    /// 连接成功通知
    fn on_connect(&mut self, uuid: String);
    /// 未连接通知
    fn on_unconnect(&mut self, uuid: String);
    /// 设备关闭
    /// * uuid 设备uuid
    fn on_disconnect(&mut self, uuid: String);
    /// 特征发现通知
    fn on_characteristics(&mut self, uuid: String, characteristic: Characteristic);
    /// 开始监听具体接口
    fn listen(&mut self, uuid: String);

    /// 接收具体接口数据
    fn on_data(&mut self, uuid: String, characteristic_uuid: String, data: Vec<u8>);
}