Android 手机从蓝牙更改为 BLE 后无法连接到树莓派

Posted

技术标签:

【中文标题】Android 手机从蓝牙更改为 BLE 后无法连接到树莓派【英文标题】:Android Phone cannot connect to Raspberry Pi after changing from Bluetooth to BLE 【发布时间】:2020-02-12 07:58:28 【问题描述】:

我们已经在多台 android 设备上进行了尝试。 我们正在尝试升级我们的系统以使用 BLE 而不是 BT 以支持 ios

这是场景:

    在 Raspberry Pi 上运行 bleno 将 Android 手机连接到 BLE -> 成功 重启(硬)Raspberry PI 并启用蓝牙服务 将 Android 手机连接并配对到 BT 在 Android 手机中取消配对设备 重启(硬)Raspberry PI,禁用蓝牙服务并运行 bleno 将 Android 手机连接到 BLE -> 连接失败 (BluetoothGatt status=19)

我们尝试重置蓝牙缓存(应用程序管理器存储),并且还以编程方式 (How to Programmatically Clear Bluetooth Cache using GattServer) 手机重启也没有用,但是手机恢复出厂设置后我们可以再次连接。

以下是 BLE 连接前后树莓派上sudo btmon 的输出:

之前(成功):

> HCI Event: LE Meta Event (0x3e) plen 19                                                                     [hci0] 7.416417
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 64
        Role: Slave (0x01)
        Peer address type: Random (0x01)
        Peer address: 6D:B3:5A:EA:CB:50 (Resolvable)
        Connection interval: 48.75 msec (0x0027)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 5000 msec (0x01f4)
        Master clock accuracy: 0x01
@ MGMT Event: Device Connected (0x000b) plen 13                                                      0x0002 [hci0] 7.416643
        LE Address: 6D:B3:5A:EA:CB:50 (Resolvable)
        Flags: 0x00000000
        Data length: 0
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                              [hci0] 7.434359
        Handle: 64
> HCI Event: Command Status (0x0f) plen 4                                                                     [hci0] 7.434958
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                        [hci0] 7.435064
        Scanning: Disabled (0x00)
        Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 7.437506
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7                                                    [hci0] 7.437630
        Type: Passive (0x00)
        Interval: 60.000 msec (0x0060)
        Window: 30.000 msec (0x0030)
        Own address type: Public (0x00)
        Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 7.438086
      LE Set Scan Parameters (0x08|0x000b) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                        [hci0] 7.438189
        Scanning: Enabled (0x01)
        Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 7.438938
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 7.610374
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x0001-0xffff
        Attribute group type: Primary Service (0x2800)
> HCI Event: LE Meta Event (0x3e) plen 10                                                                     [hci0] 8.007841
      LE Connection Update Complete (0x03)
        Status: Success (0x00)
        Handle: 64
        Connection interval: 7.50 msec (0x0006)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 5000 msec (0x01f4)
> HCI Event: LE Meta Event (0x3e) plen 12                                                                     [hci0] 8.022370
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 64
        Features: 0x1d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Extended Reject Indication
          Slave-initiated Features Exchange
          LE Ping
< ACL Data TX: Handle 64 flags 0x00 dlen 16                                                                   [hci0] 8.022557
      LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
        Min interval: 40
        Max interval: 56
        Slave latency: 0
        Timeout multiplier: 500
> ACL Data RX: Handle 64 flags 0x02 dlen 10                                                                   [hci0] 8.037404
      LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
        Result: Connection Parameters accepted (0x0000)
< ACL Data TX: Handle 64 flags 0x00 dlen 18                                                                   [hci0] 8.056423
      ATT: Read By Group Type Response (0x11) len 13
        Attribute data length: 6
        Attribute group list: 2 entries
        Handle range: 0x0001-0x0005
        UUID: Generic Access Profile (0x1800)
        Handle range: 0x0006-0x0009
        UUID: Generic Attribute Profile (0x1801)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.067455
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x000a-0xffff
        Attribute group type: Primary Service (0x2800)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.068874
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 26                                                                   [hci0] 8.093368
      ATT: Read By Group Type Response (0x11) len 21
        Attribute data length: 20
        Attribute group list: 1 entry
        Handle range: 0x000a-0x0014
        UUID: Vendor specific (ffffffff-ffff-ffff-ffff-fffffffffff0)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.104908
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x0015-0xffff
        Attribute group type: Primary Service (0x2800)
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                    [hci0] 8.126027
      ATT: Error Response (0x01) len 4
        Read By Group Type Request (0x10)
        Handle: 0x0015
        Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.142444
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0001-0x0005
        Attribute type: Include (0x2802)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.143707
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                    [hci0] 8.147126
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0001
        Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.157415
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0001-0x0005
        Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 20                                                                   [hci0] 8.160994
      ATT: Read By Type Response (0x09) len 15
        Attribute data length: 7
        Attribute data list: 2 entries
        Handle: 0x0002
        Value: 020300002a
        Handle: 0x0004
        Value: 020500012a
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.172405
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0005-0x0005
        Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.172580
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                    [hci0] 8.175935
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0005
        Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.187369
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0006-0x0009
        Attribute type: Include (0x2802)
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                    [hci0] 8.190371
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0006
        Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.202431
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0006-0x0009
        Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.203385
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 13                                                                   [hci0] 8.206600
      ATT: Read By Type Response (0x09) len 8
        Attribute data length: 7
        Attribute data list: 1 entry
        Handle: 0x0007
        Value: 200800052a
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.217417
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0008-0x0009
        Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                    [hci0] 8.220542
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0008
        Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                    [hci0] 8.232412
      ATT: Find Information Request (0x04) len 4
        Handle range: 0x0009-0x0009
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.233326
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 10                                                                   [hci0] 8.236097
      ATT: Find Information Response (0x05) len 5
        Format: UUID-16 (0x01)
        Handle: 0x0009
        UUID: Client Characteristic Configuration (0x2902)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.254911
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x000a-0x0014
        Attribute type: Include (0x2802)
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                    [hci0] 8.257998
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x000a
        Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.269937
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x000a-0x0014
        Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.270951
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 27                                                                   [hci0] 8.274584
      ATT: Read By Type Response (0x09) len 22
        Attribute data length: 21
        Attribute data list: 1 entry
        Handle: 0x000b
        Value: 0a0c0003003333333333333333333333333313
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.284914
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x000c-0x0014
        Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 27                                                                   [hci0] 8.288595
      ATT: Read By Type Response (0x09) len 22
        Attribute data length: 21
        Attribute data list: 1 entry
        Handle: 0x000e
        Value: 080f0005003333333333333333333333333313
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.307421
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x000f-0x0014
        Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.308334
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 27                                                                   [hci0] 8.311648
      ATT: Read By Type Response (0x09) len 22
        Attribute data length: 21
        Attribute data list: 1 entry
        Handle: 0x0011
        Value: 10120007003333333333333333333333333313
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 8.322401
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0012-0x0014
        Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                    [hci0] 8.325415
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0012
        Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                    [hci0] 8.337361
      ATT: Find Information Request (0x04) len 4
        Handle range: 0x000d-0x000d
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.338277
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 10                                                                   [hci0] 8.341007
      ATT: Find Information Response (0x05) len 5
        Format: UUID-16 (0x01)
        Handle: 0x000d
        UUID: Characteristic User Description (0x2901)
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                    [hci0] 8.352388
      ATT: Find Information Request (0x04) len 4
        Handle range: 0x0010-0x0010
< ACL Data TX: Handle 64 flags 0x00 dlen 10                                                                   [hci0] 8.355296
      ATT: Find Information Response (0x05) len 5
        Format: UUID-16 (0x01)
        Handle: 0x0010
        UUID: Characteristic User Description (0x2901)
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                    [hci0] 8.367413
      ATT: Find Information Request (0x04) len 4
        Handle range: 0x0013-0x0014
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.368251
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 14                                                                   [hci0] 8.371096
      ATT: Find Information Response (0x05) len 9
        Format: UUID-16 (0x01)
        Handle: 0x0013
        UUID: Client Characteristic Configuration (0x2902)
        Handle: 0x0014
        UUID: Characteristic User Description (0x2901)
> ACL Data RX: Handle 64 flags 0x02 dlen 7                                                                    [hci0] 8.382770
      ATT: Exchange MTU Request (0x02) len 2
        Client RX MTU: 255
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                    [hci0] 8.385864
      ATT: Exchange MTU Response (0x03) len 2
        Server RX MTU: 255
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.397320
        Num handles: 1
        Handle: 64
        Count: 2
> HCI Event: LE Meta Event (0x3e) plen 10                                                                     [hci0] 8.465343
      LE Connection Update Complete (0x03)
        Status: Success (0x00)
        Handle: 64
        Connection interval: 60.00 msec (0x0030)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 5000 msec (0x01f4)
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                    [hci0] 8.644851
      ATT: Write Request (0x12) len 4
        Handle: 0x0013
          Data: 0100
< ACL Data TX: Handle 64 flags 0x00 dlen 5                                                                    [hci0] 8.648926
      ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                    [hci0] 8.764880
      ATT: Write Request (0x12) len 4
        Handle: 0x0013
          Data: 0000
< ACL Data TX: Handle 64 flags 0x00 dlen 5                                                                    [hci0] 8.768936
      ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                    [hci0] 8.884933
      ATT: Write Request (0x12) len 4
        Handle: 0x0013
          Data: 0100
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 8.886011
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 5                                                                    [hci0] 8.890188
      ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 9.004875
      ATT: Write Request (0x12) len 6
        Handle: 0x000c
          Data: 317c6964
< ACL Data TX: Handle 64 flags 0x00 dlen 5                                                                    [hci0] 9.033321
      ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 24                                                                   [hci0] 9.125075
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 9.126033
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x01 dlen 24                                                                   [hci0] 9.126060
> ACL Data RX: Handle 64 flags 0x01 dlen 23                                                                   [hci0] 9.127135
      ATT: Write Request (0x12) len 66
        Handle: 0x000f
          Data: 307c307c7b22446576696365416363657373546f6b656e223a2232363465663937302d346362362d313165612d383230612d623832376562316564313439227d
< ACL Data TX: Handle 64 flags 0x00 dlen 5                                                                    [hci0] 9.165770
      ATT: Write Response (0x13) len 0
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 9.432895
        Num handles: 1
        Handle: 64
        Count: 1
...

之后(失败):

> HCI Event: LE Meta Event (0x3e) plen 19                                                                     [hci0] 5.509223
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 64
        Role: Slave (0x01)
        Peer address type: Random (0x01)
        Peer address: 48:3F:15:CC:76:5F (Resolvable)
        Connection interval: 48.75 msec (0x0027)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 5000 msec (0x01f4)
        Master clock accuracy: 0x01
@ MGMT Event: Device Connected (0x000b) plen 13                                                      0x0002 [hci0] 5.509416
        LE Address: 7C:03:5E:9F:D1:A7 (OUI 7C-03-5E)
        Flags: 0x00000000
        Data length: 0
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                              [hci0] 5.514306
        Handle: 64
> HCI Event: Command Status (0x0f) plen 4                                                                     [hci0] 5.515424
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                        [hci0] 5.515546
        Scanning: Disabled (0x00)
        Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 5.517443
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7                                                    [hci0] 5.517576
        Type: Passive (0x00)
        Interval: 60.000 msec (0x0060)
        Window: 30.000 msec (0x0030)
        Own address type: Public (0x00)
        Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 5.518191
      LE Set Scan Parameters (0x08|0x000b) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                        [hci0] 5.518314
        Scanning: Enabled (0x01)
        Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 5.519025
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                        [hci0] 5.545371
        Scanning: Disabled (0x00)
        Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 5.548676
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Add Device To White List (0x08|0x0011) plen 7                                               [hci0] 5.548813
        Address type: Random (0x01)
        Address: 48:3F:15:CC:76:5F (Resolvable)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 5.550213
      LE Add Device To White List (0x08|0x0011) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7                                                    [hci0] 5.550348
        Type: Passive (0x00)
        Interval: 60.000 msec (0x0060)
        Window: 30.000 msec (0x0030)
        Own address type: Public (0x00)
        Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 5.551350
      LE Set Scan Parameters (0x08|0x000b) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                        [hci0] 5.551468
        Scanning: Enabled (0x01)
        Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                   [hci0] 5.552194
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                   [hci0] 5.751468
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x0001-0xffff
        Attribute group type: Primary Service (0x2800)
> HCI Event: LE Meta Event (0x3e) plen 10                                                                     [hci0] 6.145226
      LE Connection Update Complete (0x03)
        Status: Success (0x00)
        Handle: 64
        Connection interval: 7.50 msec (0x0006)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 5000 msec (0x01f4)
> HCI Event: LE Meta Event (0x3e) plen 12                                                                     [hci0] 6.159776
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 64
        Features: 0x1d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Extended Reject Indication
          Slave-initiated Features Exchange
          LE Ping
< ACL Data TX: Handle 64 flags 0x00 dlen 16                                                                   [hci0] 6.159947
      LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
        Min interval: 40
        Max interval: 56
        Slave latency: 0
        Timeout multiplier: 500
> ACL Data RX: Handle 64 flags 0x02 dlen 10                                                                   [hci0] 6.174753
      LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
        Result: Connection Parameters accepted (0x0000)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                        [hci0] 6.414272
        Num handles: 1
        Handle: 64
        Count: 1
< HCI Command: Disconnect (0x01|0x0006) plen 3                                                               [hci0] 10.174344
        Handle: 64
        Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4                                                                    [hci0] 10.175510
      Disconnect (0x01|0x0006) ncmd 1
        Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4                                                               [hci0] 15.169553
        Status: Success (0x00)
        Handle: 64
        Reason: LMP Response Timeout / LL Response Timeout (0x22)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                   0x0002 [hci0] 15.169664
        LE Address: 7C:03:5E:9F:D1:A7 (OUI 7C-03-5E)
        Reason: Unspecified (0x00)

debian 版本:9.3

Raspbian GNU/Linux 9(延伸)

Linux raspberrypi 4.9.59+ #1047 Sun Oct 29 11:47:10 GMT 2017 armv6l GNU/Linux

注意:如果我们使用https://scribles.net/changing-a-bluetooth-device-address-on-raspberry-pi/更改树莓派的蓝牙mac地址,在运行bleno之前,Android能够再次连接到BLE。

【问题讨论】:

【参考方案1】:

在 Raspberry Pi 上运行的蓝牙服务 (BlueZ) 是经过蓝牙认证的 Linux 官方蓝牙堆栈,除非您有充分的理由不使用它,否则应该使用它。然而,Bleno 更像是一个 hack,完全独立的蓝牙堆栈,仅应用于测试目的和类似目的,因为它尚未经过认证(并且可能还有很长的路要走)。 bleno 中的配对/粘合也不能正常工作。似乎 bleno 没有响应收到的“按组类型读取请求”,我不知道为什么,然后它发送了一个断开连接命令。

【讨论】:

以上是关于Android 手机从蓝牙更改为 BLE 后无法连接到树莓派的主要内容,如果未能解决你的问题,请参考以下文章

Android BLE蓝牙踩坑总结

HM10与Arduino和Android BLE之间的蓝牙低功耗大数据传输

无法通过 BLE 将 Android 应用程序连接到 Raspberry Pi 3

Android中不稳定的BLE连接

由于位置许可,BLE 蓝牙扫描无法在 Android 10 和 11 上运行

android蓝牙BLE(三) —— 广播