BlueZ icon indicating copy to clipboard operation
BlueZ copied to clipboard

Intermittent Not connectable devices reported URGENT HELP Required

Open AGandhiCraniUS opened this issue 2 years ago • 6 comments

Hi @Vudentz

I hope you are well. I am reaching out as I had a very urgent question I had with BlueZ on the Raspberry Pi.

Like you had pointed out in this post, there is an issue with connections failing over time. You had pointed out a patch over here but the URL for it is no longer accessible.

Could you please help me out with this URGENT issue. My Raspberry Pi can connect to the device initally but eventually loses the ability to do so.

Thank you.

AGandhiCraniUS avatar Sep 14 '23 16:09 AGandhiCraniUS

@ MGMT Event: Device Connected (0x000b) plen 25                       {0x0001} [hci0] 52.873989
        LE Address: FD:8B:12:79:6F:8D (Static)
        Flags: 0x00000008
          Connection Locally Initiated
        Data length: 12
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Name (complete): ENV0002
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2          #121 [hci0] 52.874373
        Handle: 16 Address: FD:8B:12:79:6F:8D (Static)
@ RAW Open: btmon (privileged) version 2.22                                  {0x0002} 52.876311
@ RAW Close: btmon                                                           {0x0002} 52.876377
> HCI Event: Command Status (0x0f) plen 4                                 #122 [hci0] 52.877874
      LE Read Remote Used Features (0x08|0x0016) ncmd 2
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 4                                  #123 [hci0] 52.897866
      LE Channel Selection Algorithm (0x14)
        Handle: 16 Address: FD:8B:12:79:6F:8D (Static)
        Algorithm: #2 (0x01)
> HCI Event: Disconnect Complete (0x05) plen 4                            #124 [hci0] 53.122916
        Status: Success (0x00)
        Handle: 16 Address: FD:8B:12:79:6F:8D (Static)
        Reason: Connection Failed to be Established (0x3e)
@ MGMT Event: Device Disconnected (0x000c) plen 8                     {0x0001} [hci0] 53.123042
        LE Address: FD:8B:12:79:6F:8D (Static)
        Reason: Unspecified (0x00)
< HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8       #125 [hci0] 53.167435
        Own address type: Public (0x00)
        Filter policy: Ignore not in accept list (0x01)
        PHYs: 0x01
        Entry 0: LE 1M
          Type: Passive (0x00)
          Interval: 60.000 msec (0x0060)
          Window: 60.000 msec (0x0060)
> HCI Event: Command Complete (0x0e) plen 4                               #126 [hci0] 53.169902
      LE Set Extended Scan Parameters (0x08|0x0041) ncmd 2
        Status: Success (0x00)
< HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6           #127 [hci0] 53.170070
        Extended scan: Enabled (0x01)
        Filter duplicates: Enabled (0x01)
        Duration: 0 msec (0x0000)
        Period: 0.00 sec (0x0000)
> HCI Event: Command Complete (0x0e) plen 4                               #128 [hci0] 53.172916
      LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 38                                 #129 [hci0] 53.404913
      LE Extended Advertising Report (0x0d)
        Num reports: 1
        Entry 0
          Event type: 0x0013
            Props: 0x0013
              Connectable
              Scannable
              Use legacy advertising PDUs
            Data status: Complete
          Legacy PDU Type: ADV_IND (0x0013)
          Address type: Random (0x01)
          Address: FD:8B:12:79:6F:8D (Static)
          Primary PHY: LE 1M
          Secondary PHY: No packets
          SID: no ADI field (0xff)
          TX power: 127 dBm
          RSSI: -101 dBm (0x9b)
          Periodic advertising interval: 0.00 msec (0x0000)
          Direct address type: Public (0x00)
          Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
          Data length: 0x0c
        02 01 06 08 09 45 4e 56 30 30 30 32              .....ENV0002    
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Name (complete): ENV0002
< HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6           #130 [hci0] 53.405076
        Extended scan: Disabled (0x00)
        Filter duplicates: Disabled (0x00)
        Duration: 0 msec (0x0000)
        Period: 0.00 sec (0x0000)
> HCI Event: Command Complete (0x0e) plen 4                               #131 [hci0] 53.407918
      LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
        Status: Success (0x00)
< HCI Command: LE Extended Create Connection (0x08|0x0043) plen 26        #132 [hci0] 53.408056
        Filter policy: Accept list is not used (0x00)
        Own address type: Public (0x00)
        Peer address type: Random (0x01)
        Peer address: FD:8B:12:79:6F:8D (Static)
        Initiating PHYs: 0x01
        Entry 0: LE 1M
          Scan interval: 60.000 msec (0x0060)
          Scan window: 60.000 msec (0x0060)
          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                                 #133 [hci0] 53.410918
      LE Extended Create Connection (0x08|0x0043) ncmd 2
        Status: Success (0x00)
< HCI Command: LE Create Connection Cancel (0x08|0x000e) plen 0           #134 [hci0] 53.784542
> HCI Event: Command Complete (0x0e) plen 4                               #135 [hci0] 53.788014
      LE Create Connection Cancel (0x08|0x000e) ncmd 2
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19                                 #136 [hci0] 53.790010
      LE Connection Complete (0x01)
        Status: Unknown Connection Identifier (0x02)
        Handle: 0 Address: 00:00:00:00:00:00 (OUI 00-00-00)
        Role: Central (0x00)
        Peer address type: Random (0x01)
        Peer address: FD:8B:12:79:6F:8D (Static)
        Connection interval: 0.00 msec (0x0000)
        Connection latency: 0 (0x0000)
        Supervision timeout: 0 msec (0x0000)
        Central clock accuracy: 0x00

AGandhiCraniUS avatar Sep 14 '23 18:09 AGandhiCraniUS

@AGandhiCraniUS I suspect this has been fixed upstream by https://github.com/bluez/bluetooth-next/commit/5cd39700de9b699ef2f333ba3c405e51afbf0eb0

Vudentz avatar Sep 14 '23 19:09 Vudentz

How would I implement this? I am using the Bleak Python library with BlueZ 5.66

AGandhiCraniUS avatar Sep 14 '23 19:09 AGandhiCraniUS

How would I implement this? I am using the Bleak Python library with BlueZ 5.66

This is down in the kernel, either update it or have that patch applied and recompile the kernel, btw which version are you guys running?

Vudentz avatar Sep 14 '23 19:09 Vudentz

5.15.92-v8 We are using BalenaOS, which provides fleet management tools for Raspberry Pis

AGandhiCraniUS avatar Sep 14 '23 19:09 AGandhiCraniUS

One thing of importance is that if we reboot the raspberry pi the connections come back online and stay online. This also does not happen reliably on all the Pis, only on some of them

AGandhiCraniUS avatar Sep 14 '23 19:09 AGandhiCraniUS