David Sahakyan

1pod

LGBluetooth

                 As we know CoreBluetooth is very hard to use - The methods of objects in Core bluetooth are messy

例如,connectPeripheral:options: 在 CBCentralManager 中编写,discoverCharacteristics:forService 在 Peripheral 中编写,writeValue:forCharacteristic:type,readValueForCharacteristic 同样也在 Peripheral 中。

这样的杂乱代码使得 CoreBluetooth 开发非常痛苦。例如,如果您需要读取特征值,您需要在中枢对象上调用 "connect",等待中枢代理回调,在那之后调用 "discover services",等待外围代理回调,"discover characteristic" 您计划的目标,并等待代理回调,"readValue",然后再等待一次代理回调。如果您的程序一次性建立了 2 个连接,会发生什么?处理这种情况会导致代码混乱,引发数百个错误。

无需担心,现在您可以忘掉那个地狱——LGBluetooth 使用块进行回调,您可以使用现代代码和分层调用。

许可:[MIT](https://open-source.org.cn/licenses/MIT)

  • Objective C