首先导入框架
#importCoreBluetooth/CoreBluetooth.h
我们需要一个管理者来管理蓝牙设备,CBCentralManager
首先创建管理者
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="color:#0088;box-sizing: border-box;">self</span>.manager = [[<span style="box-sizing: border-box;">CBCentralManager</span> alloc]<span style="color:#06666;box-sizing: border-box;">initWithDelegate:</span><span style="color:#0088;box-sizing: border-box;">self</span> <wbr></wbr></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="color:#06666;box-sizing: border-box;">queue:</span>[<span style="box-sizing: border-box;">NSOperationQueue</span> mainQueue] <wbr></wbr></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="color:#06666;box-sizing: border-box;">options:</span><span style="color:#0088;box-sizing: border-box;">nil</span>]; <span style="color:#0880;box-sizing: border-box;">//options</span>是筛选设备的条件</code>
创建完管理者后 会执行代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>centralManagerDidUpdateS<wbr>tate:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBCentralManager</span> *)</span>central</wbr></span></code>
可以查看manager的一个属性 : state 来识别蓝牙的状态 ,该属性是一个枚举值CBCentralManagerState
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="color:#0088;box-sizing: border-box;">typedef</span> NS_ENUM(<span style="color:#66066;box-sizing: border-box;">NSInteger</span>, CBCentralManagerState) { CBCentralManagerStateUnk<wbr>nown = <span style="color:#06666;box-sizing: border-box;">0</span>, <span style="color:#8800;box-sizing: border-box;">//初始的时候是未知的(刚刚创建的时候)</span> CBCentralManagerStateRes<wbr>etting, <span style="color:#8800;box-sizing: border-box;">//正在重置状态</span> CBCentralManagerStateUns<wbr>upported, <span style="color:#8800;box-sizing: border-box;">//设备不支持的状态</span> CBCentralManagerStateUna<wbr>uthorized, <span style="color:#8800;box-sizing: border-box;">//设备未授权状态</span> CBCentralManagerStatePow<wbr>eredOff, <span style="color:#8800;box-sizing: border-box;">//设备关闭状态</span> CBCentralManagerStatePow<wbr>eredOn, <span style="color:#8800;box-sizing: border-box;">//设备开启状态 -- 可用状态</span> };</wbr></wbr></wbr></wbr></wbr></wbr></code>
如果是处于 CBCentralManagerStatePow
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">[<span style="color:#0088;box-sizing: border-box;">self</span>.manager <span style="color:#06666;box-sizing: border-box;">scanForPeripheralsWithSe<wbr>rvices:</wbr></span><span style="color:#0088;box-sizing: border-box;">nil</span> <span style="color:#06666;box-sizing: border-box;">options:</span><span style="color:#0088;box-sizing: border-box;">nil</span>];</code>
可以设置一个计时器 在一段时间后停止搜索,避免耗电
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"> <span style="color:#06666;box-sizing: border-box;">[self.manager stopScan]</span><span style="color:#8800;box-sizing: border-box;">;</span></code>
如果搜索到了设备,那么会调用代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>centralManager:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBCentralManager</span> *)</span>central <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">didDiscoverPeripheral:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBPeripheral</span> *)</span>peripheral <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">advertisementData:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">NSDictionary</span><<span class="hljs-variable" style="box-sizing: border-box;">NSString</span> *,id> *)</span>advertisementData <wbr></wbr></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">RSSI:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">NSNumber</span> *)</span>RSSI</code>
其中 peripheral是搜索到的设备,advertisementData是关于设备的一些信息,RSSI是设备的信号强度
可以根据 advertisementData 里面的 kCBAdvDataServiceUUIDs 的值UUID来筛选某种设备
搜索到设备后就可以进行连接了,蓝牙4.0支持一对多连接。
连接设备
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">[<span style="color:#0088;box-sizing: border-box;">self</span>.manager <span style="color:#06666;box-sizing: border-box;">connectPeripheral:</span>peripheral <span style="color:#06666;box-sizing: border-box;">options:</span><span style="color:#0088;box-sizing: border-box;">nil</span>]; </code>
连接成功后 会执行代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>centralManager:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBCentralManager</span> *)</span>central <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">didConnectPeripheral:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBPeripheral</span> *)</span>peripheral</span></code>
如果需要断开某个设备,则调用方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="color:#06666;box-sizing: border-box;">[self.manager cancelPeripheralConnecti<wbr>on:peripheral]</wbr></span><span style="color:#8800;box-sizing: border-box;">;</span></code>
设备不管是自己断开还是手动断开,都会调用代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>centralManager:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBCentralManager</span> *)</span>central <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">didDisconnectPeripheral:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBPeripheral</span> *)</span>peripheral error:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">NSError</span> *)</span>error</span></code>
在这里可以判断一下,如果不是手动断开的连接,则可以再连接断开的设备,实现断开设备自动连接的功能
CBCentralManager就是用来做以上这些事情的,要给设备发送数据和接受数据 则要用到 CBPeripheral
首先设置设备的代理
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">peripheral.<span style="color:#0088;box-sizing: border-box;">delegate</span> = <span style="color:#0088;box-sizing: border-box;">self</span>;</code>
然后开始搜索设备服务
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="color:#06666;box-sizing: border-box;">[peripheral discoverServices:nil]</span><span style="color:#8800;box-sizing: border-box;">;</span></code>
搜索成功后会执行代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>peripheral:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBPeripheral</span> *)</span>peripheral <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">didDiscoverServices:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">NSError</span> *)</span>error</span></code>
在这里 设备的 services属性里面就有设备服务的数据了,可以遍历这个数组来匹配到我们需要的服务,这个一般跟硬件厂商协商,这里我们假如需要UUID为FF00的服务
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"> <span style="color:#0088;box-sizing: border-box;">for</span>(CBService *s <span style="color:#0088;box-sizing: border-box;">in</span> peripheral.services){ <span style="color:#0088;box-sizing: border-box;">if</span>([s.UUID isEqual:[CBUUID UUIDWithString:@<span style="color:#0880;box-sizing: border-box;">"FF00"</span>]]){ [peripheral discoverCharachteristics<wbr>:nil <span style="color:#0088;box-sizing: border-box;">for</span>Service:s]; } }</wbr></code>
如果成功匹配到服务,那么调用方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="color:#06666;box-sizing: border-box;">[peripheral discoverCharacteristics:nil forService:s]</span><span style="color:#8800;box-sizing: border-box;">; </span></code>
成功后会执行代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>peripheral:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBPeripheral</span> *)</span>peripheral <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">didDiscoverCharacteristi<wbr>csForService:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBService</span> *)</span>service error:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">NSError</span> *)</span>error</wbr></span></code>
在这个方法里面,服务的属性 characteristics ,会是一组的CBCharacteristic,是服务的一些特征,在这里,我们假设发送数据需要用到特征的UUID为 FF02
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">for</span> (<span style="color:#66066;box-sizing: border-box;">CBCharacteristic</span> *c <span style="color:#0088;box-sizing: border-box;">in</span> service.characteristics){ <span style="color:#0088;box-sizing: border-box;">if</span>([c.<span style="color:#66066;box-sizing: border-box;">UUID</span> isEqual:[<span style="color:#66066;box-sizing: border-box;">CBUUID</span> <span style="color:#66066;box-sizing: border-box;">UUIDWithString</span>:@<span style="color:#0880;box-sizing: border-box;">"FF02"</span>]]){ <span style="color:#66066;box-sizing: border-box;">NSData</span> *<span style="box-sizing: border-box;"><span style="color:#0088;box-sizing: border-box;">data</span> = [self stringToHex:@"550504010101AA"];</span> [peripheral writeValue:<span style="box-sizing: border-box;"><span style="color:#0088;box-sizing: border-box;">data</span> <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">forCharacteristic:c <span style="color:#0088;box-sizing: border-box;">type</span>:<span style="color:#66066;box-sizing: border-box;">CBCharacteristicWriteWit<wbr>houtResponse</wbr></span>];</span> } }</code>
发送的数据为 550504010101AA,我们将其转换为 NSData 类型 调用方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">[peripheral writeValue:<span style="box-sizing: border-box;"><span style="color:#0088;box-sizing: border-box;">data</span> <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">forCharacteristic:ctype:<span style="color:#66066;box-sizing: border-box;">CBCharacteristicWriteWit<wbr>houtResponse</wbr></span>] //将数据发送给设备</span></code>
发送成功后会执行代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>peripheral:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBPeripheral</span> *)</span>peripheral <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">didWriteValueForCharacte<wbr>ristic:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBCharacteristic</span> *)</span>characteristic error:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">NSError</span> *)</span>error</wbr></span></code>
如果是读取设备的数据 那么使用方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">[peripheral readValueForCharacterist<wbr>ic:c] </wbr></code>
读取数据后会执行代理方法
<code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">- <span style="color:#66066;box-sizing: border-box;">(void)</span>peripheral:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBPeripheral</span> *)</span>peripheral <wbr></wbr></span></code><code style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'source Code pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span style="box-sizing: border-box;">didUpdateValueForCharact<wbr>eristic:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">CBCharacteristic</span> *)</span>characteristic error:<span style="color:#66066;box-sizing: border-box;">(<span style="box-sizing: border-box;">NSError</span> *)</span>error</wbr></span></code>
完成