# RxBluetooth **Repository Path**: xchaun/rx-bluetooth ## Basic Information - **Project Name**: RxBluetooth - **Description**: Rx封装蓝牙,并实现蓝牙自动重连,收发消息 - **Primary Language**: Swift - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-03-08 - **Last Updated**: 2026-03-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 安装教程: - `pod RxBluetooth` ## RxBluetooth:Rx封装蓝牙,并实现蓝牙自动重连,设备扫描,收发消息 ## Source: Rx封装蓝牙代理,是其可以进行链式调用 - CBCentralManager+Rx 中心设备代理封装 - CBPeripheral+Rx 设备代理封装 - CBPeripheralManager+Rx 设备中心管理封装 - BluetoothState 蓝牙状态封装 ## Manager ### XCBluetoothManager 封装蓝牙处理 - 扫描设备,并过滤`scanForPeripherals` - 连接设备,以及设备连接过程中的error处理 `connect` - 断开连接`disconnect` - 读取数据`readValue` - 写入数据,进行了分包处理,同时避免写入消息太频繁,引入了队列,同时添加了20ms的延迟 ### XCReconnectManager 蓝牙重连操作 - 用户主动自动重连`autoReconnectLastPeripheral` - 系统自动重连, 1: 自动重连的话先是指数增加方式的重新连接蓝牙 2: 监控RSSI,当连接过的蓝牙的rssi的值变化且范围在合理范围内才开始重连`reconnectWithStrategy` ### XCBluetoothMessageManager 蓝牙消息接发封装 - 下发时间,获取设备电量,获取消息 ## Model ### 蓝牙消息模型:XCBlueToothModel,实现了Codable协议