我正在尝试读取BLE设备的特征值,在我的例子中BLE设备是Minew S1温度和湿度传感器,我尝试读取的属性值是“Radio Tx Power”。 我使用的是 RaspberryPi 4,bluetoothctl 版本是 5.55。
Primary Service (Handle 0x0004)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f
a3c87500-8ed3-4bdf-8a39-a01bebede295
Eddystone Configuration Service
Characteristic (Handle 0x6510)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char002c
a3c8750b-8ed3-4bdf-8a39-a01bebede295
(Advanced) Factory reset
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char002a
a3c8750a-8ed3-4bdf-8a39-a01bebede295
ADV Slot Data
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0028
a3c87505-8ed3-4bdf-8a39-a01bebede295
(Advanced) Advertised Tx Power
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
a3c87504-8ed3-4bdf-8a39-a01bebede295
Radio Tx Power
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0024
a3c87503-8ed3-4bdf-8a39-a01bebede295
Advertising Interval
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0022
a3c87502-8ed3-4bdf-8a39-a01bebede295
Active Slot
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0020
a3c87501-8ed3-4bdf-8a39-a01bebede295
Capabilities
Primary Service (Handle 0xa2d8)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b
7f280001-8204-f393-e0a9-e50e24dcca9e
Vendor specific
Characteristic (Handle 0xad98)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b/char001c
7f280002-8204-f393-e0a9-e50e24dcca9e
Vendor specific
Descriptor (Handle 0x0000)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b/char001c/desc001e
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
使用 bluetoothctl 我尝试读取数据,但收到此错误
[nRF5x]# select-attribute /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
[nRF5x:/service001f/char0026]# read
Attempting to read /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
[CHG] Device AC:23:3F:AB:7B:D8 ServicesResolved: no
[CHG] Device AC:23:3F:AB:7B:D8 Connected: no
Failed to read: org.bluez.Error.Failed
[bluetooth]#
当连接到 Android 手机时,所有这些都工作正常。
请帮我解决这个问题。
编辑(添加调试):
> HCI Event: Command Complete (0x0e) plen 4 #37 [hci0] 23.110065
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
< HCI Command: LE Create Connection (0x08|0x000d) plen 25 #38 [hci0] 23.110095
Scan interval: 60.000 msec (0x0060)
Scan window: 60.000 msec (0x0060)
Filter policy: White list is not used (0x00)
Peer address type: Public (0x00)
Peer address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Own address type: Public (0x00)
Min connection interval: 30.00 msec (0x0018)
Max connection interval: 50.00 msec (0x0028)
Connection latency: 0 (0x0000)
Supervision timeout: 420 msec (0x002a)
Min connection length: 0.000 msec (0x0000)
Max connection length: 0.000 msec (0x0000)
> HCI Event: Command Status (0x0f) plen 4 #39 [hci0] 23.110613
LE Create Connection (0x08|0x000d) ncmd 1
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19 #40 [hci0] 23.210757
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 64
Role: Master (0x00)
Peer address type: Public (0x00)
Peer address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Connection interval: 48.75 msec (0x0027)
Connection latency: 0 (0x0000)
Supervision timeout: 420 msec (0x002a)
Master clock accuracy: 0x00
@ MGMT Event: Device Connected (0x000b) plen 37 {0x0001} [hci0] 23.210785
LE Address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Flags: 0x00000000
Data length: 24
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
16-bit Service UUIDs (complete): 1 entry
Unknown (0xffe1)
Service Data (UUID 0xffe1): a101641cfd48e6d87bab3f23ac
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2 #41 [hci0] 23.210905
Handle: 64
> HCI Event: Command Status (0x0f) plen 4 #42 [hci0] 23.211771
LE Read Remote Used Features (0x08|0x0016) ncmd 1
Status: Success (0x00)
> HCI Event: Command Complete (0x0e) plen 14 #43 [hci0] 23.211775
LE Read Remote Used Features (0x08|0x0016) ncmd 1
Status: Success (0x00)
00 00 00 00 00 00 00 00 00 00 ..........
> HCI Event: LE Meta Event (0x3e) plen 12 #44 [hci0] 23.337233
LE Read Remote Used Features (0x04)
Status: Success (0x00)
Handle: 64
Features: 0x21 0x00 0x00 0x00 0x00 0x00 0x00 0x00
LE Encryption
LE Data Packet Length Extension
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #45 [hci0] 23.337677
ATT: Exchange MTU Request (0x02) len 2
Client RX MTU: 517
> ACL Data RX: Handle 64 flags 0x02 dlen 7 #46 [hci0] 23.532018
ATT: Exchange MTU Response (0x03) len 2
Server RX MTU: 23
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #47 [hci0] 23.532452
ATT: Read Request (0x0a) len 2
Handle: 0x0003
> HCI Event: Number of Completed Packets (0x13) plen 5 #48 [hci0] 23.580957
Num handles: 1
Handle: 64
Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 10 #49 [hci0] 23.629552
ATT: Read Response (0x0b) len 5
Value: 6e52463578
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #50 [hci0] 23.629713
ATT: Read Request (0x0a) len 2
Handle: 0x0005
> ACL Data RX: Handle 64 flags 0x02 dlen 7 #51 [hci0] 23.727010
ATT: Read Response (0x0b) len 2
Value: 0000
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #52 [hci0] 23.727179
ATT: Read Request (0x0a) len 2
Handle: 0x0027
> HCI Event: Number of Completed Packets (0x13) plen 5 #53 [hci0] 23.775948
Num handles: 1
Handle: 64
Count: 2
> HCI Event: Disconnect Complete (0x05) plen 4 #54 [hci0] 32.502249
Status: Success (0x00)
Handle: 64
Reason: Remote User Terminated Connection (0x13)
@ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0001} [hci0] 32.502320
LE Address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Reason: Connection terminated by remote host (0x03)
谢谢你。
我正在使用 Minew P1 并面临同样的问题;我想读取感官数据。我在 iPhone 上安装了 BLE 调试配置文件,并使用“Apple PacketLogger”(XCode 的一部分)来检查连接。有关更多信息,请按照本教程操作:https://www.bluetooth.com/blog/a-new-way-to-debug-iosbluetooth-applications/
现在我能够完全看到 BLE 线路上来回传输的数据。设备的某些服务是开放的 - 例如 Eddystone 信标控制服务。
但他们也有自己的,即 BLE 特性“7F280002-8204-F393-E0A9-E50E24DCCA9E”。
发送“同步历史信息”让我获得以下 ATT 发送命令,然后是一堆 ATT 接收数据包(其中包含数据)
会话 1:仅通过 ATT Send 请求数据
7F280002-8204-F393-E0A9-E50E24DCCA9E - 值:EF0C 7F1D AA25 E15F 7B12 BED6 45DD 5C99
7F280002-8204-F393-E0A9-E50E24DCCA9E - 值:9AB1 258D 4B4A 3E34 9D19 6B04 280B F956
会话 2:仅通过 ATT Send 请求数据
7F280002-8204-F393-E0A9-E50E24DCCA9E - 值:FD9A 668A C70A D98F 2751 21CE 184E 3948
7F280002-8204-F393-E0A9-E50E24DCCA9E - 值:2D58 C91E 1BAC 6CFB 014C F06F 557D 1420
这表明某种加密 - 两个完全相同的会话,但它们的负载完全不同。
我希望知道这里发生了什么,以及如何解码它。到目前为止还没有运气,我希望有人可以帮助解决这个问题。