swift - CoreBluetooth 和 Omron Evolv 血压计
问题描述
我一直在努力通过 CoreBluetooth 在我的应用程序中支持 Omron Evolv 血压监测器 (BPM)。使用有关 BPM 的蓝牙 SIG 文档(https://www.bluetooth.com/specifications/specs/然后是 BLP 和 BLS),我可以连接显示器。
我使用了以下特性:
- 血压测量,2A35
- 血压特征,2A49
BLS 文档中的第 10 页指出,血压测量是属性Indicate,据我所知,它的行为类似于 Notify 属性。
为了澄清一些代码,我调用了CBPeripheralDelegate的委托方法:
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
print("connected!")
bloodPressurePeripheral.discoverServices([bloodPressureService])
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
guard let services = peripheral.services else { return }
services.forEach { service in
print("discovered service: \(service) \n")
peripheral.discoverCharacteristics(nil, for: service)
}
}
在didDiscoverCharacteristicsFor函数中,我简单地遍历特征并检查它们的属性。
if char.properties.contains(.read) {
print("\(char.uuid): properties contains .read")
peripheral.readValue(for: char)
}
if char.properties.contains(.indicate) {
print("\(char.uuid): properties contains .indicate")
peripheral.setNotifyValue(true, for: char)
}
if char.properties.contains(.notify) {
print("\(char.uuid): properties contains .notify")
peripheral.setNotifyValue(false, for: char)
我尝试了 readValue 和 setNotifyValue 来表示我仍然得到以下结果:
<CBCharacteristic: 0x2829880c0, UUID = 2A35, properties = 0x20, value = (null), notifying = NO>
2A35: properties contains .indicate
<CBCharacteristic: 0x282988180, UUID = 2A49, properties = 0x2, value = {length = 2, bytes = 0x2700}, notifying = NO>
2A49: properties contains .read
我真的不明白为什么 2A35 的值为空。我知道有一些值,因为使用 Omron 应用程序我可以得到测量值。
我的实际问题是:有没有人有使用 CoreBluetooth 连接(欧姆龙)BPM 的经验,我忽略了什么?
谢谢回答!
解决方案
推荐阅读
- ruby-on-rails - 如何上传多个图像并同时更新一个实体。Rails API 和 JS 前端
- javascript - 从客户端将 HTML 表保存到服务器上的 CSV
- confluence - Confluence 中的“站点搜索”
- html - 用 0.2vw 宽度围绕我的三角形获得边框
- python - 使用 Django 和 sqlalchemy 连接到 Postgres 数据库
- ringcentral - 如何获取使用 RingCentral 中的小部件登录的用户的访问令牌?
- excel - 在行中显示列名,Power BI 报表
- arrays - 在 Powershell 中删除数组元素中的重复项
- sql - 如何将日期转换为“ddmmyy”格式的字符串?
- sql - SSRS 如果条件小于等于时间