>开始扫描
>开始连接设备
>调用discoverServices
>在回调中调用discovercharacteristics
– (void)peripheral:(CBPeripheral *)peripheral diddiscoverServices:(NSError *)错误
>在回调内调用discoverDescriptorsForCharacteristic
– (void)peripheral:(CBPeripheral *)peripheral diddiscovercharacteristicsForService:(CBService *)service error:(NSError *)error
>内部回调
– (void)peripheral:(CBPeripheral *)peripheral diddiscoverDescriptorsForCharacteristic:(CBCharacteristic *)特征错误:(NSError *)错误
我打了电话:
if ( [[descriptor.UUID representativeString] isEqualToString:@"2902" ] ) { const unsigned char raw_data[] = {0x02}; NSData *myData = [NSData dataWithBytes: raw_data length: 2]; [self.cBCP writeValue:myData forDescriptor:descriptor]; }
但我的应用程序在writeVale崩溃:.控制台中的错误消息是:
Cannot write Client Characteristic Configuration descriptors using
this method!
任何的想法?谢谢
解决方法
>仅通知:将启用通知.
>仅指示:将启用指示.
>指示&通知:仅启用通知.
因此,如果需要启用指示,则特征必须仅具有指示属性,并且应删除通知.
我猜这背后的主要原因是指示速度慢得多,因此iOS总是更喜欢最快的选项,除非需要指明.
Read more on the Apple docs