CoreBluetooth 和 Omron Evolv 血压计

问题描述 投票:0回答:2

我一直致力于通过 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的值为空。我知道有一些值,因为通过欧姆龙应用程序我可以获得测量值。

我的实际问题是:有人有使用 CoreBluetooth 连接(欧姆龙)BPM 的经验吗?我忽略了什么?

感谢您的回答!

swift bluetooth hardware core-bluetooth
2个回答
1
投票

我尝试过将 Ormon Evolv 与 Android 设备连接。 我会告诉你我从中学到了什么。

注意:- Ble 设备异步通信,您必须一次执行一项 GATT 操作(例如,读取、写入、启用通知、启用指示)。前一个操作成功后才能进行下一个操作。

我的设备有以下服务。

  1. UUID 180a 的 DEVICE_INFO_SERVICE
  2. BATTERY_SERVICE_UUID,UUID 180f
  3. CURRENT_TIME_SERVICE_UUID,UUID 1805
  4. BLOOD_PRESSURE_SERVICE_UUID,UUID 1810

连接成功后第一个 GATT 操作是 gatt.discoverServices() 。 (在android中触发了onServicesDiscoverd事件)

如果您只需要血压读数而不需要读取状态和时间戳,只需启用UUID 2A35的指示即可

val bloodPressureService = gatt?.getService(BLOOD_PRESSURE_SERVICE_UUID)
    val bloodPressureChar = bloodPressureService?.getCharacteristic(BLOOD_PRESSURE_CHAR_UUID)
    gatt?.setCharacteristicNotification(bloodPressureChar, true)

    val bloodDescriptor = bloodPressureChar?.getDescriptor(CCC_DESCRIPTOR_UUID)
    bloodDescriptor?.value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE
    gatt?.writeDescriptor(bloodDescriptor)

0
投票

你的话题解决了吗? 我完全在同一点! 尝试使用 esp32 作为灵活库的客户端读取欧姆龙血压设备! 2A35 的读数为空。 谢谢您的回复和问候

© www.soinside.com 2019 - 2024. All rights reserved.