ios ble - Write Without Response"属性 - 忽略无响应写入

use*_*603 1 ios core-bluetooth bluetooth-lowenergy

在iOS7.1.1上,以下BLE操作成功 - 它假设我有一个BLE连接设置等...

[[self peripheral]writeValue:dataToWrite forCharacteristic:nextCharacteristic type:CBCharacteristicWriteWithResponse];
Run Code Online (Sandbox Code Playgroud)

但如果我切换"类型" CBCharacteristicWriteWithoutResponse,我得到以下警告,外围设备没有收到命令:(

[[self peripheral]writeValue:dataToWrite forCharacteristic:nextCharacteristic type:CBCharacteristicWriteWithoutResponse];
Run Code Online (Sandbox Code Playgroud)

错误:

CoreBluetooth[WARNING] Characteristic <CBCharacteristic: 0x178081f90 UUID = 249C2001-00D7-4D91-AC75-22D57AE2FFB8, Value = (null), Properties = 0x28, Notifying = YES, Broadcasting = NO> does not specify the "Write Without Response" property - ignoring response-less write**
Run Code Online (Sandbox Code Playgroud)

任何线索都赞赏!

Pau*_*w11 7

当BLE外围设备宣传特征时,广告包括那些特征的属性.其中包括该特性支持的操作 - 无响应读取,通知,写入和响应写入.

在这种情况下,似乎该特性支持写入响应但不支持写入而没有响应,因此当您尝试写入而没有响应时,您会收到警告并且写入操作无法完成

  • 完美的现场答案 - 在 ios 上会执行此检查,但在某些其他平台上,BLE 实现不会执行此检查,因此它可以在特性中的正确标志下正常工作。 (2认同)