RxBluetoothKit RxSwift蓝牙封装库

RxBluetoothKit 的蓝牙封装,真是帮了不少忙。用RxSwift那一套来搞CoreBluetooth,比起原生回调方式,代码清爽多了。比如你要连个 BLE 设备,几行链式调用就能搞定,响应也快,异常也自然,写起来心情都好点。

RxSwift 的响应式写法,和CoreBluetooth这种状态多、流程杂的 API 还挺搭的。像scanForPeripheralsestablishConnection这些操作,你可以链式写一串,逻辑流转直观,看得懂也改得动。

Central 和 Peripheral 模式它都支持,想自己当外设也行,基本接口都覆盖得挺全。而且它有多细节做得还不错,比如连接后自动重连、断开这些,也都考虑到了。蛮适合写那种低功耗蓝牙外设的 App。

有个典型例子:只连一次蓝牙设备,用法像这样:

manager.scanForPeripherals(withServices: [serviceId])
  .take(1)
  .flatMap { $0.peripheral.establishConnection() }

顺手贴点相关文章,如果你想补补基础,可以看看这些:

如果你平时就在用RxSwift,又要搞蓝牙,那这个库真的值得试试。要注意哦,别忘了权限和蓝牙状态,别到时候设备找不到还怪库不好用~

folder
RxBluetoothKit:用于RxSwift的iOS和OSX蓝牙库 预估大小:252个文件
file
.gitignore 310B
file
ExampleApp.entitlements 352B
file
Cartfile 34B
file
docSet.dsidx 84KB
file
Characteristic.html 46KB
file
PeripheralManager.html 72KB
file
CentralManager.html 68KB
file
Peripheral.html 182KB
file
highlight.css 4KB
file
jazzy.css 9KB
file
spinner.gif 2KB
file
BluetoothError.html 57KB
file
PeripheralManager.html 72KB
file
CentralManager.html 68KB
file
Peripheral.html 182KB
file
highlight.css 4KB
file
jazzy.css 9KB
file
spinner.gif 2KB
file
BluetoothError.html 57KB
file
RxBluetoothKit.h 389B
zip 文件大小:736.38KB