Raspberry Pi 无法重新连接到已配对的蓝牙设备

问题描述 投票:0回答:2

我使用带有 BlueZ v5.5 的 Raspberry Pi 3 与蓝牙秤进行通信。

问题:我可以在配对后立即配对秤并与其通信(读/写特性)。但如果我断开与体重秤的连接,我就无法重新连接。

我在 Raspberry Pi 方面所做的事情:

  1. 须藤蓝牙ctl
  2. (默认情况下我注册了代理KeyboardDisplay)
  3. 扫描
  4. (我看到设备的ADV)
  5. 扫描关闭
  6. 信任 MAC 地址
  7. 配对 MAC 地址
  8. (我输入体重秤屏幕上显示的 6 位密码)
  9. (已建立连接)
  10. 信任 MAC 地址
  11. 断开MAC地址
  12. 连接MAC地址
  13. (连接失败)

这是 btmon 的输出:

< HCI Command: LE Create Connection (0x08|0x000d) plen 25                                                                                                        
        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: MAC ADDRESS
        Own address type: Public (0x00)
        Min connection interval: 10.00 msec (0x0008)
        Max connection interval: 20.00 msec (0x0010)
        Connection latency: 0 (0x0000)
        Supervision timeout: 6000 msec (0x0258)
        Min connection length: 0.000 msec (0x0000)
        Max connection length: 0.000 msec (0x0000)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                        
      LE Create Connection (0x08|0x000d) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19                                                                                                                        
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 64
        Role: Master (0x00)
        Peer address type: Public (0x00)
        Peer address: MAC ADDRESS
        Connection interval: 18.75 msec (0x000f)
        Connection latency: 0 (0x0000)
        Supervision timeout: 6000 msec (0x0258)
        Master clock accuracy: 0x00
@ MGMT Event: Device Connected (0x000b) plen 37                                                                                                             
        LE Address: MAC ADDRESS
        Flags: 0x00000000
        Data length: 24
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        16-bit Service UUIDs (partial): 1 entry
          Weight Scale (0x181d)
        Appearance: Weight Scale (0x0c80)
        Unknown EIR field 0x1b: 00610601d3ca5d
        Service Data (UUID 0x181d): 
@ MGMT Event: Device Connected (0x000b) plen 37                                                                                                             
        LE Address: MAC ADDRESS
        Flags: 0x00000000
        Data length: 24
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        16-bit Service UUIDs (partial): 1 entry
          Weight Scale (0x181d)
        Appearance: Weight Scale (0x0c80)
        Unknown EIR field 0x1b: 00610601d3ca5d
        Service Data (UUID 0x181d): 
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                                                                                 
        Handle: 64
> HCI Event: Command Status (0x0f) plen 4                                                                                                                        
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 12                                                                                                                        
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 64
        Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
< HCI Command: LE Start Encryption (0x08|0x0019) plen 28                                                                                                         
        Handle: 64
        Random number: 0x3a0760acb556aa15
        Encrypted diversifier: 0xa2f4
        Long term key: 1639a13299a91d0000519e1041643419
> HCI Event: Command Status (0x0f) plen 4                                                                                                                        
      LE Start Encryption (0x08|0x0019) ncmd 1
        Status: Success (0x00)
> HCI Event: Encryption Change (0x08) plen 4                                                                                                                     
        Status: PIN or Key Missing (0x06)
        Handle: 64
        Encryption: Disabled (0x00)
< HCI Command: Disconnect (0x01|0x0006) plen 3                                                                                                                   
        Handle: 64
        Reason: Authentication Failure (0x05)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                        
      Disconnect (0x01|0x0006) ncmd 1
        Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                                                   
        Status: Success (0x00)
        Handle: 64
        Reason: Connection Terminated By Local Host (0x16)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                           
        LE Address: MAC ADDRESS
        Reason: Connection terminated due to authentication failure (0x04)

我浏览了大量的页面和线程,但无法解决这个问题。任何建议将不胜感激。非常感谢!

bluetooth raspberry-pi raspberry-pi3 bluez
2个回答
0
投票

因此,解决方案是仔细研究 SMP 配对数据包。

我的 SMP 配对请求(来自主设备)包含以下参数:

Initiator key distribution: EncKey Sign LinkKey (0x0d)
Responder key distribution: EncKey IdKey Sign LinkKey (0x0f)

SMP 配对响应(来自从机)的情况有所不同:

Initiator key distribution: IdKey (0x02)
Responder key distribution: EncKey IdKey (0x03)

所以从站向主站索要 IdKey 并且很认真地对待它。相反,BlueZ 堆栈只是忽略了需求并且没有提供 IdKey。

快速解决方法是将一些硬编码的 id 密钥发送到从属设备。


-1
投票

你能帮忙吗?我不知道如何解决这个问题。我查看了大量内容,但没有找到解决方案。我正在将 Rpi 与 Bullseye OS 和 Bluez 版本 5.50 一起使用

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