为什么在带有BPM传感器的Raspberry Pi中无法获得BLE指示响应?

问题描述 投票:1回答:1

我正在使用BPM OMRON BP7350。

设备可以与制造商的android应用程序完美配合,并且可以通过树莓派与设备进行连接,但是当我尝试编写指示请求0200时,BPM传感器没有任何响应。

然后,我使用nRF Connect SDK android应用程序测试了OMRON BP7350,我能够像在制造商应用程序中一样流畅地读取指示...所以我不知道可能是什么错误。

[我也尝试过使用pi中的hcitoolgatttool,可以连接到设备,但是同样,由于无法从BPM传感器获取指示,我开始认为这是我可能需要更好地了解与配对有关的问题,但是由于我的选件用尽了,所以我想知道是否可以帮助我调试这个问题。

这是来自nRF Connect SDK的日志消息:

nRF Connect, 2020-06-03
BLESmart_0000015328FFB28ADF2F (28:FF:B2:8A:DF:2F)
V 14:59:11.616 Connecting to 28:FF:B2:8A:DF:2F...
D 14:59:11.616 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
D 14:59:11.901 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I 14:59:11.901 Connected to 28:FF:B2:8A:DF:2F
D 14:59:11.902 wait(1600ms)
D 14:59:11.935 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
I 14:59:12.464 Connection parameters updated (interval: 30.0ms, latency: 0, timeout: 2000ms)
V 14:59:13.503 Discovering services...
D 14:59:13.503 gatt.discoverServices()
D 14:59:13.518 [Callback] Services discovered with status: 0
I 14:59:13.518 Services discovered
V 14:59:13.567 Generic Access (0x1800)
- Device Name [R] (0x2A00)
- Appearance [R] (0x2A01)
- Peripheral Privacy Flag [R W WNR] (0x2A02)
- Reconnection Address [R] (0x2A03)
- Peripheral Preferred Connection Parameters [R] (0x2A04)
Generic Attribute (0x1801)
- Service Changed [I] (0x2A05)
   Client Characteristic Configuration (0x2902)
Device Information (0x180A)
- System ID [R] (0x2A23)
- Model Number String [R] (0x2A24)
- Serial Number String [R] (0x2A25)
- Firmware Revision String [R] (0x2A26)
- Hardware Revision String [R] (0x2A27)
- Software Revision String [R] (0x2A28)
- Manufacturer Name String [R] (0x2A29)
- IEEE 11073-20601 Regulatory Certification Data List [R] (0x2A2A)
Unknown Service (ecbe3980-c9a2-11e1-b1bd-0002a5d5c51b)
- Unknown Characteristic [N R W WNR] (b305b680-aee7-11e1-a730-0002a5d5c51b)
   Client Characteristic Configuration (0x2902)
- Unknown Characteristic [W WNR] (db5b55e0-aee7-11e1-965e-0002a5d5c51b)
- Unknown Characteristic [W WNR] (e0b8a060-aee7-11e1-92f4-0002a5d5c51b)
- Unknown Characteristic [W WNR] (0ae12b00-aee8-11e1-a192-0002a5d5c51b)
- Unknown Characteristic [W WNR] (10e1ba60-aee8-11e1-89e5-0002a5d5c51b)
- Unknown Characteristic [N R] (49123040-aee8-11e1-a74d-0002a5d5c51b)
   Client Characteristic Configuration (0x2902)
- Unknown Characteristic [N R] (4d0bf320-aee8-11e1-a0d9-0002a5d5c51b)
   Client Characteristic Configuration (0x2902)
- Unknown Characteristic [N R] (5128ce60-aee8-11e1-b84b-0002a5d5c51b)
   Client Characteristic Configuration (0x2902)
- Unknown Characteristic [N R] (560f1420-aee8-11e1-8184-0002a5d5c51b)
   Client Characteristic Configuration (0x2902)
- Unknown Characteristic [N] (8858eb40-aee8-11e1-bb67-0002a5d5c51b)
   Client Characteristic Configuration (0x2902)
Battery Service (0x180F)
- Battery Level [N R] (0x2A19)
   Client Characteristic Configuration (0x2902)
Current Time Service (0x1805)
- Current Time [N R W] (0x2A2B)
   Client Characteristic Configuration (0x2902)
Unknown Service (5df5e817-a945-4f81-89c0-3d4e9759c07c)
- Record Access Control Point [I W] (0x2A52)
   Client Characteristic Configuration (0x2902)
- Unknown Characteristic [I] (c195da8a-0e23-4582-acd8-d446c77c45de)
   Client Characteristic Configuration (0x2902)
User Data (0x181C)
- Database Change Increment [N R W] (0x2A99)
   Client Characteristic Configuration (0x2902)
- User Index [R] (0x2A9A)
- User Control Point [I W] (0x2A9F)
   Client Characteristic Configuration (0x2902)
- Date of Birth [R W] (0x2A85)
Blood Pressure (0x1810)
- Blood Pressure Measurement [I] (0x2A35)
   Client Characteristic Configuration (0x2902)
- Blood Pressure Feature [R] (0x2A49)
D 14:59:13.568 gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
D 14:59:13.571 gatt.setCharacteristicNotification(b305b680-aee7-11e1-a730-0002a5d5c51b, true)
D 14:59:13.573 gatt.setCharacteristicNotification(49123040-aee8-11e1-a74d-0002a5d5c51b, true)
D 14:59:13.574 gatt.setCharacteristicNotification(4d0bf320-aee8-11e1-a0d9-0002a5d5c51b, true)
D 14:59:13.576 gatt.setCharacteristicNotification(5128ce60-aee8-11e1-b84b-0002a5d5c51b, true)
D 14:59:13.577 gatt.setCharacteristicNotification(560f1420-aee8-11e1-8184-0002a5d5c51b, true)
D 14:59:13.579 gatt.setCharacteristicNotification(8858eb40-aee8-11e1-bb67-0002a5d5c51b, true)
D 14:59:13.581 gatt.setCharacteristicNotification(00002a19-0000-1000-8000-00805f9b34fb, true)
D 14:59:13.584 gatt.setCharacteristicNotification(00002a2b-0000-1000-8000-00805f9b34fb, true)
D 14:59:13.585 gatt.setCharacteristicNotification(00002a52-0000-1000-8000-00805f9b34fb, true)
D 14:59:13.587 gatt.setCharacteristicNotification(c195da8a-0e23-4582-acd8-d446c77c45de, true)
D 14:59:13.588 gatt.setCharacteristicNotification(00002a99-0000-1000-8000-00805f9b34fb, true)
D 14:59:13.589 gatt.setCharacteristicNotification(00002a9f-0000-1000-8000-00805f9b34fb, true)
D 14:59:13.590 gatt.setCharacteristicNotification(00002a35-0000-1000-8000-00805f9b34fb, true)
V 14:59:37.265 Disabling indications for 00002a35-0000-1000-8000-00805f9b34fb
D 14:59:37.267 gatt.setCharacteristicNotification(00002a35-0000-1000-8000-00805f9b34fb, false)
D 14:59:37.278 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0000)
I 14:59:37.454 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 00-00
A 14:59:37.454 "Notifications and indications disabled" sent
V 14:59:37.480 Notifications and indications disabled for 00002a35-0000-1000-8000-00805f9b34fb
V 14:59:39.728 Enabling indications for 00002a35-0000-1000-8000-00805f9b34fb
D 14:59:39.728 gatt.setCharacteristicNotification(00002a35-0000-1000-8000-00805f9b34fb, true)
D 14:59:39.730 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0200)
I 14:59:39.793 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00
A 14:59:39.793 "Indications enabled" sent
V 14:59:39.805 Indications enabled for 00002a35-0000-1000-8000-00805f9b34fb
I 14:59:40.592 Indication received from 00002a35-0000-1000-8000-00805f9b34fb, value: (0x) 1E-70-00-4B-00-57-00-E4-07-06-03-0B-1F-1F-46-00-01-00-00
A 14:59:40.592 "Systolic: 112.0 mmHg
Diastolic: 75.0 mmHg
Mean AP: 87.0 mmHg
Timestamp: 11:31:31 2.07.2020
Pulse: 70.0 bpm
User ID: 1" received
I 14:59:40.635 Indication received from 00002a35-0000-1000-8000-00805f9b34fb, value: (0x) 1E-71-00-4B-00-57-00-E4-07-06-03-0E-15-26-52-00-01-00-00
A 14:59:40.635 "Systolic: 113.0 mmHg
Diastolic: 75.0 mmHg
Mean AP: 87.0 mmHg
Timestamp: 14:21:38 2.07.2020
Pulse: 82.0 bpm
User ID: 1" received
D 14:59:48.769 [Callback] Connection state changed with status: 19 and new state: DISCONNECTED (0)
W 14:59:48.770 Connection terminated by peer (status 19)
I 14:59:48.770 Disconnected
D 14:59:48.840 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED

这是我的订阅通知/指示的代码:

def subscribe(dev_addr, char_uuid, dev_name, dev_service, indication=False):
    try:
        if dev_addr is not None:
            global mydevice, keep_subscribe
            mydevice = dev_name

            # connection process 
            print("going to connect to ", mydevice)
            p = Peripheral( dev_addr )
            p.setDelegate( ScanDelegate() )
            print("device connected: ", mydevice)

            # Setup to turn notifications on, e.g.
            svc = p.getServiceByUUID( dev_service )

            notification_value = "" # this will save the value to send
            if indication:
                # setting security level to medium for encrypted data exchage
                p.setSecurityLevel("medium")
                notification_value = b"\x02\x00"    # enable indications
            else:
                notification_value = b"\x01\x00"    # enable notifications

            # to turn on notifications, we need to write this to the characteristic
            characteristic_target = svc.getCharacteristics(char_uuid)[0]
            print("characteristic_target", characteristic_target)

            # characteristic configuration client 'almost' always is the characteristic value + 1 
            ccc_handle = characteristic_target.getHandle() + 1
            print("ccc_handle", ccc_handle)

            # write to the characteristic
            p.writeCharacteristic(ccc_handle, notification_value, withResponse=True)

            # Main loop --------
            while True:
                if p.waitForNotifications(1.0):
                    # handleNotification() was called
                    continue
                print("Waiting notifications...")
                # Perhaps do something else here
    except bluepy.btle.BTLEDisconnectError as e:
        keep_subscribe = False 
        print("device disconnected, a BTLEDisconnectError happened: ", e)

使用此功能,我可以从其他传感器获取数据,但如果BPM无法成功,我怎么不能从该设备获取数据?

python android raspberry-pi bluetooth-lowenergy bluez
1个回答
0
投票

如Martijn van Welie所建议,似乎您未启用正确描述符上的指示。这是您需要使用hcitool和gatttool执行的步骤序列:-

使用以下方法扫描您的设备:-

sudo hcitool lescan

一旦找到,请使用以下gatttool命令连接到设备:-

gatttool -I
[                 ][LE]> connect 00:11:22:33:44:55

如果上述方法不起作用,可能是由于您的设备使用了随机地址,在这种情况下,您需要尝试:-

[                 ][LE]> connect 00:11:22:33:44:55 random

现在已连接,您需要找到0x2902描述符的句柄并在其上启用指示。为此,您需要首先找到“血压”特征的处理范围(0x1810)

[00:11:22:33:44:55][LE]> characteristics # This lists all the characteristics

请记下血压特性的句柄及其后一个(例如0x001c,0x001e)。现在,您要使用以下命令在该句柄范围内查找描述符:-

[00:11:22:33:44:55][LE]> char-desc 0x001c 0x001e

这应该返回一些描述符,其中一个是0x2902(例如,句柄:0x0016,uuid:00002902-0000-1000-8000-00805f9b34fb)。然后,您需要在该句柄上启用指示:-

[00:11:22:33:44:55][LE]> char-write-req 0x0016 0200

这将在您的设备上启用指示。

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