首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CoreBluetooth和欧姆龙血压监测仪

CoreBluetooth和欧姆龙血压监测仪
EN

Stack Overflow用户
提问于 2021-07-23 08:46:30
回答 1查看 296关注 0票数 0

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

我使用了以下特性:

2A35

  • Blood

  • 血压测量,血压特征,2A49

BLS文档中的第10页指出,血压测量是属性指示的,据我所知,该属性的行为类似于Notify属性。

为了澄清一些代码,我调用了CBPeripheralDelegate的委托方法

代码语言:javascript
运行
复制
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函数中,我简单地循环了特征并检查它们的属性。

代码语言:javascript
运行
复制
 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,以表明我仍然得到了以下结果:

代码语言:javascript
运行
复制
<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方面有任何经验,我忽略了什么?

谢谢你的回答!

EN

回答 1

Stack Overflow用户

发布于 2022-11-15 06:04:05

我试过把Ormon和Android设备连接起来。我会告诉你我从中学到了什么。

注:- Ble设备异步通信,您必须一次执行GATT操作(例如,读、写、启用通知、启用指示)。下一次操作只能在成功完成上一次操作之后才能完成。

我的设备有以下服务。

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

关贸总协定在成功连接后的第一个操作是gatt.discoverServices()。(事件onServicesDiscoverd被触发,在android中)

如果您只需要没有读取状态和时间戳的BP读数,只需启用UUID 2A35的指示即可。

代码语言:javascript
运行
复制
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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68496497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档