swift - Swift - 无法通过 BLE 读取多个特征
问题描述
我的应用程序能够通过 BLE 成功订阅这两个特征,但它只从其中一个特征中读取数据。以下是我能够成功读取单个特征但不能读取多个特征的代码。
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
guard characteristic == rxCharacteristic,
let data:Data = characteristic.value
else { return }
var myFloatArray = Array<Float>(repeating: 0, count: data.count/MemoryLayout<Float>.stride)
myFloatArray.withUnsafeMutableBytes { data.copyBytes(to: $0) }
解决方案
推荐阅读
- java - 是什么让 Spring Boot 控制台变得丰富多彩?
- javascript - 使用 Javascript 修改外部 SVG 图像
- nightwatch.js - Nightwatch 不创建 html 报告,如果 nightwatch 有任何运行时失败
- c - 为什么程序启动 udevd 不能正确解析名称?
- javascript - 如何在javascript中使用递归检查数组是否已排序?
- apache - Awstats 工具:Awstats 主页上缺少图标和直方图栏的问题 - 可能是定义到 Apache 中的路径问题
- python - 你可以调用/使用从 Python 列表返回的函数吗?
- google-sheets - 从谷歌表格中的计数中忽略单元格
- mysql - 如何将多个订单行添加到表中的给定orderid(主键)
- ruby - Ruby:将子命名空间命名为父命名空间,以便类只能使用父命名空间进行实例化