我正在设计一个 iOS 应用程序,它带有一个定制的蓝牙设备,可以从我的 iPhone 发送和接收文本。当我发送 CBCharacteristicWriteType.WithoutResponse 时,我能够将文本数据发送到设备,但是根据 Apple 文档,使用它发送数据是尽力而为,不能保证。当我尝试使用 .WithResponse 写入数据时,出现未知错误,因此我在 iPhone 上下载了 BT 服务器日志,并看到以下消息:
writeCharacteristic - Notice - ATT - Writing value with response to characteristic handle 0x0025 on device "(#my device number#)"
runCommand - Error - ATT - Characteristic handle 0x0024 is not writeable!
processCommands - Error - ATT - Command failed for device "(#my device number#)"
这会是蓝牙芯片的问题吗?还是我做错了什么?非常感谢任何输入!如果需要任何额外的代码,请告诉我,我会提供!
最佳答案
您需要检查CBService
上CBCharacteristic
的属性
- 如果指定了CBCharacteristicPropertyWrite
,则特性支持写入响应。如果仅指定了 CBCharacteristicPropertyWriteWithoutResponse
,则无法执行带有响应的写入。
要更改此设置,您需要修改 BLE 设备中的固件。
关于ios - 核心蓝牙 - 无法使用 CBCharacteristicWriteType.WithResponse 写入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28482672/