【发布时间】:2016-10-13 06:06:17
【问题描述】:
我正在尝试使用 Python 和 pygattlib 在我的计算机上从小米手环 1S 获取心率测量通知。
我可以使用用户信息成功初始化设备(点击传感器以“配对”),使用相同的用户信息进行后续连接,振动设备,读取设备信息和步数并收听步数通知。
但是,一旦我将心率传感器控制点更改为手动模式(将 0x150201 写入值句柄 0x4e / uuid 0x2a39),设备背面的光学传感器开始闪烁,但我没有收到写入响应并且我的蓝牙连接中断,所以我无法接收心率通知!
这是会话的 hcldump 日志,显示连接详细信息以及服务和特征的枚举。 跳下去查看问题。
HCI sniffer - Bluetooth packet analyzer ver 5.37
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
type 0x00 (passive)
interval 60.000ms window 30.000ms
own address: 0x00 (Public) policy: white list only
> HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Parameters (0x08|0x000b) ncmd 1
status 0x00
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x01 (scanning enabled)
filter duplicates 0x01 (enabled)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x00
> HCI Event: LE Meta Event (0x3e) plen 23
LE Advertising Report
ADV_IND - Connectable undirected advertising (0)
bdaddr C8:0F:10:32:CA:B6 (Public)
Flags: 0x06
Unknown type 0xff with 6 bytes data
RSSI: -65
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x00 (scanning disabled)
filter duplicates 0x00 (disabled)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x00
< HCI Command: LE Create Connection (0x08|0x000d) plen 25
bdaddr C8:0F:10:32:CA:B6 type 0
interval 96 window 96 initiator_filter 0
own_bdaddr_type 0 min_interval 40 max_interval 56
latency 0 supervision_to 42 min_ce 0 max_ce 0
> HCI Event: Command Status (0x0f) plen 4
LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
> HCI Event: LE Meta Event (0x3e) plen 19
LE Connection Complete
status 0x00 handle 64, role master
bdaddr C8:0F:10:32:CA:B6 (Public)
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2
> HCI Event: Command Status (0x0f) plen 4
LE Read Remote Used Features (0x08|0x0016) status 0x00 ncmd 1
> HCI Event: LE Meta Event (0x3e) plen 12
LE Read Remote Used Features Complete
status 0x00 handle 64
Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x0001, end 0xffff
type-uuid 0x2800
> ACL data: handle 64 flags 0x02 dlen 24
ATT: Read By Group resp (0x11)
attr handle 0x0001, end group handle 0x0009
value 0x00 0x18
attr handle 0x000c, end group handle 0x000f
value 0x01 0x18
attr handle 0x0010, end group handle 0x0039
value 0xe0 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x003a, end 0xffff
type-uuid 0x2800
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 24
ATT: Read By Group resp (0x11)
attr handle 0x003a, end group handle 0x0048
value 0xe1 0xfe
attr handle 0x0049, end group handle 0x004e
value 0x0d 0x18
attr handle 0x004f, end group handle 0x0051
value 0x02 0x18
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x0052, end 0xffff
type-uuid 0x2800
> ACL data: handle 64 flags 0x02 dlen 9
ATT: Error (0x01)
Error: Attribute not found (10)
Read By Group req (0x10) on handle 0x0052
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0001, end 0x0009
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0002, value 0x02 0x03 0x00 0x00 0x2a
handle 0x0004, value 0x02 0x05 0x00 0x01 0x2a
handle 0x0006, value 0x0a 0x07 0x00 0x02 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0007, end 0x0009
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x0008, value 0x02 0x09 0x00 0x04 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x000c, end 0x000f
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x000d, value 0x22 0x0e 0x00 0x05 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x000e, end 0x000f
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 9
ATT: Error (0x01)
Error: Attribute not found (10)
Read By Type req (0x08) on handle 0x000e
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0010, end 0x0039
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0011, value 0x02 0x12 0x00 0x01 0xff
handle 0x0013, value 0x0a 0x14 0x00 0x02 0xff
handle 0x0015, value 0x12 0x16 0x00 0x03 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0016, end 0x0039
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0018, value 0x0a 0x19 0x00 0x04 0xff
handle 0x001a, value 0x08 0x1b 0x00 0x05 0xff
handle 0x001c, value 0x12 0x1d 0x00 0x06 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x001d, end 0x0039
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x001f, value 0x12 0x20 0x00 0x07 0xff
handle 0x0022, value 0x04 0x23 0x00 0x08 0xff
handle 0x0024, value 0x1a 0x25 0x00 0x09 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0025, end 0x0039
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0027, value 0x0a 0x28 0x00 0x0a 0xff
handle 0x0029, value 0x0a 0x2a 0x00 0x0b 0xff
handle 0x002b, value 0x12 0x2c 0x00 0x0c 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x002c, end 0x0039
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x002e, value 0x0a 0x2f 0x00 0x0d 0xff
handle 0x0030, value 0x1a 0x31 0x00 0x0e 0xff
handle 0x0033, value 0x0a 0x34 0x00 0x0f 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0034, end 0x0039
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 20
ATT: Read By Type resp (0x09)
length: 7
handle 0x0035, value 0x10 0x36 0x00 0x10 0xff
handle 0x0038, value 0x02 0x39 0x00 0xc9 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x003a, end 0x0048
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x003b, value 0x08 0x3c 0x00 0xdd 0xfe
handle 0x003d, value 0x02 0x3e 0x00 0xde 0xfe
handle 0x003f, value 0x02 0x40 0x00 0xdf 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0040, end 0x0048
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0041, value 0x08 0x42 0x00 0xd0 0xfe
handle 0x0043, value 0x08 0x44 0x00 0xd1 0xfe
handle 0x0045, value 0x02 0x46 0x00 0xd2 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0046, end 0x0048
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x0047, value 0x08 0x48 0x00 0xd3 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0049, end 0x004e
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 20
ATT: Read By Type resp (0x09)
length: 7
handle 0x004a, value 0x10 0x4b 0x00 0x37 0x2a
handle 0x004d, value 0x0a 0x4e 0x00 0x39 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x004f, end 0x0051
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 1
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x0050, value 0x04 0x51 0x00 0x06 0x2a
< ACL data: handle 64 flags 0x00 dlen 9
ATT: Write req (0x12)
handle 0x0017 value 0x01 0x00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 5
ATT: Write resp (0x13)
< ACL data: handle 64 flags 0x00 dlen 25
ATT: Read By Type req (0x08)
start 0x0001, end 0xffff
type-uuid 0000ff01-0000-1000-8000-00805f9b34fb
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 21
handle 0x0012, value 0xc8 0x32 0xca 0xb6 0x04 0x00 0x04 0x6c 0x00 0x06 0x00 0x02 0x07 0x03 0x10 0x04 0x12 0x4c 0x03
< ACL data: handle 64 flags 0x00 dlen 27
ATT: Write req (0x12)
handle 0x0019 value 0xf6 0xe4 0x63 0x5c 0x01 0x1e 0xc1 0x4a 0x00 0x04 0x00 0x31 0x35 0x35 0x30 0x30 0x35 0x30 0x35 0x00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 5
ATT: Write resp (0x13)
< ACL data: handle 64 flags 0x00 dlen 9
ATT: Write req (0x12)
handle 0x004c value 0x01 0x00
> ACL data: handle 64 flags 0x02 dlen 8
ATT: Handle notify (0x1b)
handle 0x0016
value 0x05
> ACL data: handle 64 flags 0x02 dlen 5
ATT: Write resp (0x13)
HCI sniffer - Bluetooth packet analyzer ver 5.37
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
type 0x00 (passive)
interval 60.000ms window 30.000ms
own address: 0x00 (Public) policy: white list only
> HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Parameters (0x08|0x000b) ncmd 1
status 0x00
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x01 (scanning enabled)
filter duplicates 0x01 (enabled)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x00
> HCI Event: LE Meta Event (0x3e) plen 23
LE Advertising Report
ADV_IND - Connectable undirected advertising (0)
bdaddr C8:0F:10:32:CA:B6 (Public)
Flags: 0x06
Unknown type 0xff with 6 bytes data
RSSI: -65
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x00 (scanning disabled)
filter duplicates 0x00 (disabled)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x00
< HCI Command: LE Create Connection (0x08|0x000d) plen 25
bdaddr C8:0F:10:32:CA:B6 type 0
interval 96 window 96 initiator_filter 0
own_bdaddr_type 0 min_interval 40 max_interval 56
latency 0 supervision_to 42 min_ce 0 max_ce 0
> HCI Event: Command Status (0x0f) plen 4
LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
> HCI Event: LE Meta Event (0x3e) plen 19
LE Connection Complete
status 0x00 handle 64, role master
bdaddr C8:0F:10:32:CA:B6 (Public)
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2
> HCI Event: Command Status (0x0f) plen 4
LE Read Remote Used Features (0x08|0x0016) status 0x00 ncmd 1
> HCI Event: LE Meta Event (0x3e) plen 12
LE Read Remote Used Features Complete
status 0x00 handle 64
Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x0001, end 0xffff
type-uuid 0x2800
> ACL data: handle 64 flags 0x02 dlen 24
ATT: Read By Group resp (0x11)
attr handle 0x0001, end group handle 0x0009
value 0x00 0x18
attr handle 0x000c, end group handle 0x000f
value 0x01 0x18
attr handle 0x0010, end group handle 0x0039
value 0xe0 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x003a, end 0xffff
type-uuid 0x2800
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 24
ATT: Read By Group resp (0x11)
attr handle 0x003a, end group handle 0x0048
value 0xe1 0xfe
attr handle 0x0049, end group handle 0x004e
value 0x0d 0x18
attr handle 0x004f, end group handle 0x0051
value 0x02 0x18
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x0052, end 0xffff
type-uuid 0x2800
> ACL data: handle 64 flags 0x02 dlen 9
ATT: Error (0x01)
Error: Attribute not found (10)
Read By Group req (0x10) on handle 0x0052
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0001, end 0x0009
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0002, value 0x02 0x03 0x00 0x00 0x2a
handle 0x0004, value 0x02 0x05 0x00 0x01 0x2a
handle 0x0006, value 0x0a 0x07 0x00 0x02 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0007, end 0x0009
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x0008, value 0x02 0x09 0x00 0x04 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x000c, end 0x000f
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x000d, value 0x22 0x0e 0x00 0x05 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x000e, end 0x000f
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 9
ATT: Error (0x01)
Error: Attribute not found (10)
Read By Type req (0x08) on handle 0x000e
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0010, end 0x0039
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0011, value 0x02 0x12 0x00 0x01 0xff
handle 0x0013, value 0x0a 0x14 0x00 0x02 0xff
handle 0x0015, value 0x12 0x16 0x00 0x03 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0016, end 0x0039
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0018, value 0x0a 0x19 0x00 0x04 0xff
handle 0x001a, value 0x08 0x1b 0x00 0x05 0xff
handle 0x001c, value 0x12 0x1d 0x00 0x06 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x001d, end 0x0039
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x001f, value 0x12 0x20 0x00 0x07 0xff
handle 0x0022, value 0x04 0x23 0x00 0x08 0xff
handle 0x0024, value 0x1a 0x25 0x00 0x09 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0025, end 0x0039
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0027, value 0x0a 0x28 0x00 0x0a 0xff
handle 0x0029, value 0x0a 0x2a 0x00 0x0b 0xff
handle 0x002b, value 0x12 0x2c 0x00 0x0c 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x002c, end 0x0039
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x002e, value 0x0a 0x2f 0x00 0x0d 0xff
handle 0x0030, value 0x1a 0x31 0x00 0x0e 0xff
handle 0x0033, value 0x0a 0x34 0x00 0x0f 0xff
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0034, end 0x0039
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 20
ATT: Read By Type resp (0x09)
length: 7
handle 0x0035, value 0x10 0x36 0x00 0x10 0xff
handle 0x0038, value 0x02 0x39 0x00 0xc9 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x003a, end 0x0048
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x003b, value 0x08 0x3c 0x00 0xdd 0xfe
handle 0x003d, value 0x02 0x3e 0x00 0xde 0xfe
handle 0x003f, value 0x02 0x40 0x00 0xdf 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0040, end 0x0048
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 7
handle 0x0041, value 0x08 0x42 0x00 0xd0 0xfe
handle 0x0043, value 0x08 0x44 0x00 0xd1 0xfe
handle 0x0045, value 0x02 0x46 0x00 0xd2 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0046, end 0x0048
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x0047, value 0x08 0x48 0x00 0xd3 0xfe
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0049, end 0x004e
type-uuid 0x2803
> ACL data: handle 64 flags 0x02 dlen 20
ATT: Read By Type resp (0x09)
length: 7
handle 0x004a, value 0x10 0x4b 0x00 0x37 0x2a
handle 0x004d, value 0x0a 0x4e 0x00 0x39 0x2a
< ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x004f, end 0x0051
type-uuid 0x2803
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 1
> ACL data: handle 64 flags 0x02 dlen 13
ATT: Read By Type resp (0x09)
length: 7
handle 0x0050, value 0x04 0x51 0x00 0x06 0x2a
< ACL data: handle 64 flags 0x00 dlen 9
ATT: Write req (0x12)
handle 0x0017 value 0x01 0x00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 5
ATT: Write resp (0x13)
< ACL data: handle 64 flags 0x00 dlen 25
ATT: Read By Type req (0x08)
start 0x0001, end 0xffff
type-uuid 0000ff01-0000-1000-8000-00805f9b34fb
> ACL data: handle 64 flags 0x02 dlen 27
ATT: Read By Type resp (0x09)
length: 21
handle 0x0012, value 0xc8 0x32 0xca 0xb6 0x04 0x00 0x04 0x6c 0x00 0x06 0x00 0x02 0x07 0x03 0x10 0x04 0x12 0x4c 0x03
这就是有趣的开始!首先我通过读取设备信息并写入与初始化设备时相同的用户信息来对设备进行身份验证,为此我收到 0x05(“身份验证正常”)在通知句柄 0x1b / uuid 0xff03 上。
然后我在句柄 0x4c / uuid 0x2a37 上启用心率通知。
< ACL data: handle 64 flags 0x00 dlen 27
ATT: Write req (0x12)
handle 0x0019 value 0xf6 0xe4 0x63 0x5c 0x01 0x1e 0xc1 0x4a 0x00 0x04 0x00 0x31 0x35 0x35 0x30 0x30 0x35 0x30 0x35 0x00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> ACL data: handle 64 flags 0x02 dlen 5
ATT: Write resp (0x13)
< ACL data: handle 64 flags 0x00 dlen 9
ATT: Write req (0x12)
handle 0x004c value 0x01 0x00
> ACL data: handle 64 flags 0x02 dlen 8
ATT: Handle notify (0x1b)
handle 0x0016
value 0x05
> ACL data: handle 64 flags 0x02 dlen 5
ATT: Write resp (0x13)
最后我写信给心率传感器控制点。对于这个写请求,我没有收到写响应 (0x13) 并且连接被丢弃:
< ACL data: handle 64 flags 0x00 dlen 10
ATT: Write req (0x12)
handle 0x004e value 0x15 0x02 0x01
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
> HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 64 reason 0x08
Reason: Connection Timeout
如您所见,我收到 HCI 事件 Disconn Complete (0x05),原因代码为 0x08,而不是收到 0x13 写入响应。
我在这里做错了什么?
将 0x150200 写入句柄可以正常工作。写入 0x150001(启用睡眠读出)、0x150101(启用连续读出)或 0x150201(开始手动读出)会导致立即断开连接。睡眠或继续时,设备会继续定期闪烁传感器灯。设置了读数,所以看起来我的命令正在到达设备,但我找不到连接断开的原因。
我使用 Ubuntu,Linux 内核版本为 4.4.0-22-generic,bluez 版本为 5.37-0ubuntu5。命令 btmgmt 信息返回:
$ sudo btmgmt info
Index list with 1 item
hci0: Primary controller
addr 14:2D:27:E4:82:04 version 6 manufacturer 15 class 0x0c010c
supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy configuration static-addr
current settings: powered bondable ssp br/edr le secure-conn
name smokva
short name
【问题讨论】:
-
如果你在写一些命令包后总是出现连接超时(0x08),那么你电脑的蓝牙堆栈没有问题。似乎您的心率监测设备在收到该命令时会发疯。你想用小端写0x150201吗?那么你应该写 0x01 0x02 0x15 而不是 0x15 0x02 0x01。
-
根据this source code和我在使用小米手环官方应用时可以从手机获取的蓝牙日志,序列为0x15 0x02 0x01。
-
很可能我错过了在此之前发送一些命令,或者我未能正确初始化传感器。但是与其他在线来源和记录的日志相比,看起来我正在做所有需要的事情。如果有人对此设备有经验或可以分享我收到断开连接事件的其他原因,那就太好了...
标签: python bluetooth bluetooth-lowenergy gatt