首页 > 解决方案 > CoreBluetooth 和 Omron Evolv 血压计

问题描述

我一直在努力通过 CoreBluetooth 在我的应用程序中支持 Omron Evolv 血压监测器 (BPM)。使用有关 BPM 的蓝牙 SIG 文档(https://www.bluetooth.com/specifications/specs/然后是 BLP 和 BLS),我可以连接显示器。

我使用了以下特性:

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 的经验,我忽略了什么?

谢谢回答!

标签: swiftbluetoothhardwarecore-bluetooth

解决方案


推荐阅读