当前位置: 首页 > 知识库问答 >
问题:

使用小米MiBand 1S和BLE测量心率

燕烨
2023-03-14

我正在尝试使用Python和pygattlib从小米MiBand 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

这就是乐趣的开始!首先,我通过读取设备信息并写入与初始化设备时相同的用户信息来对设备进行身份验证,为此,我在通知句柄0x1b/uuid 0xff03上接收0x05(“身份验证确定”)。

然后,我在句柄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

如您所见,我没有接收0x13写入响应,而是获取了具有原因代码0x08的HCI事件Disconn完成(0x05)。

我到底做错了什么?


将0x150200写入句柄可以正常工作。写入0x150001(启用Hibernate读出)、0x150101(启用连续读出)或0x150201(启动手动读出)会导致立即断开连接。当设置睡眠或控制读数时,设备会继续定期闪烁传感器指示灯,因此看起来我的命令正在到达设备,但我无法找到连接中断的原因。


我使用的是Ubuntu,Linux内核版本是4.4.0-22-通用版和5.37-0ubuntu5。命令btmgmt info返回

$ 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 

共有1个答案

卞云瀚
2023-03-14

我设法进行了测量,处理了从官方应用程序中嗅到的包,但是当我稍后尝试做同样的事情时,它不再工作了,现在我遇到了同样的问题。你解决了在句柄0x004c中编写命令后断开连接的问题吗?

以下是曾经运行过的shell命令:

root@raspberrypi:/# gatttool -b C8:0F:10:3C:7E:51 -I
[C8:0F:10:3C:7E:51][LE]> connect
[C8:0F:10:3C:7E:51][LE]> char-read-hnd 0x0012
Characteristic value/descriptor: c8 3c 7e 51 04 00 04 07 00 06 00 02 16 04 10 04 16 4c 03 01 
[C8:0F:10:3C:7E:51][LE]> char-write-req 0x0019 74bef4600019af41000400746573740000000043
Characteristic value was written successfully
ffff0F:10:3C:7E:51][LE]> char-write-req 0x0028 10071f110138ffffffffffff
Characteristic value was written successfully
[C8:0F:10:3C:7E:51][LE]> char-write-req 0x002d 0100
Characteristic value was written successfully
[C8:0F:10:3C:7E:51][LE]> char-write-req 0x001e 0100
Characteristic value was written successfully
[C8:0F:10:3C:7E:51][LE]> char-write-req 0x001b 06
Characteristic value was written successfully
[C8:0F:10:3C:7E:51][LE]> char-write-req 0x001b 0a10071f1101300000
Characteristic value was written successfully
Notification handle = 0x001d value: 00 00 00 00 
Notification handle = 0x001d value: 00 00 00 00 
[C8:0F:10:3C:7E:51][LE]> char-write-req 0x004c 0100
Characteristic value was written successfully
[C8:0F:10:3C:7E:51][LE]> char-write-req 0x004e 150201
Characteristic value was written successfully
Notification handle = 0x004b value: 06 47 

心率是0x47,最后一个数字。

 类似资料:
  • 我正在尝试实现简单的sdk,用于与健身跟踪小米乐队合作。目前,我可以跟踪步骤、驱动振动、处理传感器触摸,但我在心率测量方面有问题。我的sdk基于https://github.com/pangliang/miband-sdk-android.要测量心率,我需要将描述符写入适当的特征,以便在该特征的值更改时能够处理回调,然后将适当的数据写入心率控制点特征,以直接启动心率测量过程。问题是,在将启动该过程

  • 自我介绍 为什么选择小米 介绍自己的项目 测试的流程 怎么测试CPU 快排 python装饰器 自己的优势 反问。。。 还是太菜了

  • ###小米一面 项目问了一嘴 具体记不得了 岗位方向有要求吗 为什么干测开 coding:最长不重复子序列; 找k个数,和为n,在1~9中选择,字典序排序输出(dfs+剪枝,没调出来,整体对了) sql题 测开理解 sql会吗 ACID 场景:取快递 ###小米二面 面试官很和蔼 上来说一面对基础知识什么的已经考察过了 这轮面试主要考察一些场景 先询问了实习相关的知识,如软件从开始到上线的整个流程

  • #2023春招##内推##校招##小米2023秋招求职进度交流##测试开发# 10月18日,感觉问题考察的非常全面,后端、前端、QT开发相关都问了一些,算法也是hard,前前后后一个小时。 1、SpringBoot的开始注解 2、解释一下AOP 3、SpringMVC是什么 4、Spring中的层级结构(Controller、Service、Dao、Entity层) 5、get和post请求,po

  • #软件开发2024笔面经# 只能说我看的面经有点离谱,居然是错的。结果面试问了一样的,面完发现错了! 1,计网三次握手,为什么不是二次和四次 2,java内存模型 3,count(1)和count(*)区别,看的面经上告诉我性能一样。。。。面完百度发现错了 4,死锁是什么,必要条件有哪些 5,linux指令,说出十个 6,手撕代码,红包金额n,数量m,随机且发完。 希望下次不要一紧张就忘。。。。差

  • 面试官不开摄像头,时长也才四十分钟,不会凉了吧 问: 实习经历 Java程序怎么运行的,底层发生了什么 New一个对象之后发生了什么 Tcp三次握手四次挥手 熟悉哪些自动化测试工具 Jmeter怎么进行压力测试的 Qps是什么,怎么通过它测试系统的瓶颈 手撕: 快排,写完递归后让我写个非递归的 反转链表 #如何判断面试是否凉了#