0

I'm experiencing a strange issue with one of my applications:

Background:

One of my features requires Bluetooth connectivity. Once a device (i.e. phone) is paired with the host, I continuously "poll" the device, to extract the RSSI (signal strength).

The polling is achieved by connecting to the device on PSM port 0x0001 (1), via Bluetooth sockets on L2CAP, sending an HCI request to query for signal strength, extracting the signal strength, and closing the connection.

Issue:

Everything works fine, and as expected, until I integrate the Simcom 7600G LTE module (Needed for internet connectivity) via PCI.

When I plug the module in, I am no longer able to do an L2CAP Bluetooth socket connection, with an error message of "Time Out" (it will time out depending on what I set the socket.settimeout(...)

As soon as I unplug the LTE module, everything works as expected and I am able to establish the socket connection with the remote Bluetooth device.

Observation:

What is strange is that the Bluetooth discovery and pairing process still works as expected, with the LTE module integrated. It is only the L2CAP Bluetooth sockets that I've written in code (Python) that no longer work, timing out every time a connection is attempted.

So, simply, when the LTE module is not in the PCI slot, everything works flawlessly - the discovery, pairing, BluetoothSocket L2CAP connection, and RSSI querying.

When it is plugged out, the discovery and pairing work, but I get Timed Out when attempting to establish a BluetoothSocket connection via L2CAP. (I've also tried RFCOMM with no luck).

Another strange observation is, when I am monitoring bluetoothctl, I can see the Agent displaying:

[CHG] Device BB:BB:BB:BB:BB:BB Connected: yes
[CHG] Device BB:BB:BB:BB:BB:BB Connected: no

And it displays this in both scenarios, with the LTE module in and out, yet at the application layer, it times out.

Questions and Assumptions:

  • As a general question, why might this be occurring?
  • Could it be some form of interference? And if so, given other protocols seem to be working fine, with all other protocols presumably on the same band (2.4GHz), why is it that L2CAP is affected? As far as I understand, the Bluetooth Stack specifies L2CAP as the underlying layer 3 protocol.
  • If not interference, what other settings could be interfering between two completely different chips, and network interfaces?

Additional Data:

Test code:

import traceback
import bluetooth
import bluetooth._bluetooth as bt

bt_sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
bt_sock.settimeout(5)
# [0, 672, 65535, 0, 1, 3, 63]
print(bt_sock.get_l2cap_options())

try:
   print("Connecting...")
   bt_sock.connect(("BB:BB:BB:BB:BB:BB", 1))
   print("Closing...")
   bt_sock.close()
except Exception as e:
   print(e)
   print(traceback.format_exc())

I've run a btmon on my adapter, with the below problem dump:

Bluetooth monitor ver 5.55
= Note: Linux version 5.4.154-5.5.0-devel+git.c65f1622951c (aarch64)                                                                                                                                                                                                                  0.210966
= Note: Bluetooth subsystem version 2.22                                                                                                                                                                                                                                              0.210971
= New Index: AA:AA:AA:AA:AA:AA (Primary,USB,hci0)                                                                                                                                                                                                                              [hci0] 0.210973
= Open Index: AA:AA:AA:AA:AA:AA                                                                                                                                                                                                                                                [hci0] 0.210973
= Index Info: AA:AA:AA:AA:AA:AA (Marvell Technology Group Ltd.)                                                                                                                                                                                                                [hci0] 0.210975
@ MGMT Open: bluetoothd (privileged) version 1.14                                                                                                                                                                                                                            {0x0001} 0.210976
@ RAW Open: python3 (privileged) version 2.22                                                                                                                                                                                                                               {0x0002} 13.767587
@ RAW Close: python3                                                                                                                                                                                                                                                        {0x0002} 13.767635
@ RAW Open: python3 (privileged) version 2.22                                                                                                                                                                                                                        {0x0002} [hci0] 13.767704
< HCI Command: Create Connection (0x01|0x0005) plen 13                                                                                                                                                                                                                     #1 [hci0] 13.771761
        Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Packet type: 0xcc18
          DM1 may be used
          DH1 may be used
          DM3 may be used
          DH3 may be used
          DM5 may be used
          DH5 may be used
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
        Role switch: Allow slave (0x01)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                                                                                  #2 [hci0] 13.776071
      Create Connection (0x01|0x0005) ncmd 1
        Status: Success (0x00)
> HCI Event: Role Change (0x12) plen 8                                                                                                                                                                                                                                     #3 [hci0] 14.798704
        Status: Success (0x00)
        Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Role: Slave (0x01)
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7                                                                                                                                                                                                                #4 [hci0] 14.804429
        Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Page scan repetition mode: R0 (0x00)
> HCI Event: Connect Complete (0x03) plen 11                                                                                                                                                                                                                               #5 [hci0] 14.804676
        Status: Success (0x00)
        Handle: 1
        Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Link type: ACL (0x01)
        Encryption: Disabled (0x00)
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2                                                                                                                                                                                                         #6 [hci0] 14.804842
        Handle: 1
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                                                                                  #7 [hci0] 14.806679
      Read Remote Supported Features (0x01|0x001b) ncmd 1
        Status: Success (0x00)
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1                                                                                                                                                                                                                      #8 [hci0] 14.806804
        Scan enable: No Scans (0x00)
> ACL Data RX: Handle 1 flags 0x02 dlen 10                                                                                                                                                                                                                                 #9 [hci0] 14.816323
      L2CAP: Information Request (0x0a) ident 2 len 2
        Type: Extended features supported (0x0002)
> HCI Event: Max Slots Change (0x1b) plen 3                                                                                                                                                                                                                               #10 [hci0] 14.822810
        Handle: 1
        Max slots: 5
> HCI Event: Read Remote Supported Features (0x0b) plen 11                                                                                                                                                                                                                #11 [hci0] 14.826428
        Status: Success (0x00)
        Handle: 1
        Features: 0xbf 0xfe 0x8f 0xfe 0xdb 0xff 0x7b 0x87
          3 slot packets
          5 slot packets
          Encryption
          Slot offset
          Timing accuracy
          Role switch
          Sniff mode
          Power control requests
          Channel quality driven data rate (CQDDR)
          SCO link
          HV2 packets
          HV3 packets
          u-law log synchronous data
          A-law log synchronous data
          CVSD synchronous data
          Paging parameter negotiation
          Power control
          Transparent synchronous data
          Broadcast Encryption
          Enhanced Data Rate ACL 2 Mbps mode
          Enhanced Data Rate ACL 3 Mbps mode
          Enhanced inquiry scan
          Interlaced inquiry scan
          Interlaced page scan
          RSSI with inquiry results
          Extended SCO link (EV3 packets)
          EV4 packets
          EV5 packets
          AFH capable slave
          AFH classification slave
          LE Supported (Controller)
          3-slot Enhanced Data Rate ACL packets
          5-slot Enhanced Data Rate ACL packets
          Sniff subrating
          Pause encryption
          AFH capable master
          AFH classification master
          Enhanced Data Rate eSCO 2 Mbps mode
          Enhanced Data Rate eSCO 3 Mbps mode
          3-slot Enhanced Data Rate eSCO packets
          Extended Inquiry Response
          Simultaneous LE and BR/EDR (Controller)
          Secure Simple Pairing
          Encapsulated PDU
          Erroneous Data Reporting
          Non-flushable Packet Boundary Flag
          Link Supervision Timeout Changed Event
          Inquiry TX Power Level
          Enhanced Power Control
          Extended features
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                                                                               #12 [hci0] 14.834553
      Write Scan Enable (0x03|0x001a) ncmd 1
        Status: Success (0x00)
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3                                                                                                                                                                                                         #13 [hci0] 14.834600
        Handle: 1
        Page: 1
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                                                                                 #14 [hci0] 14.836925
      Read Remote Extended Features (0x01|0x001c) ncmd 1
        Status: Success (0x00)
> HCI Event: Read Remote Extended Features (0x23) plen 13                                                                                                                                                                                                                 #15 [hci0] 14.845426
        Status: Success (0x00)
        Handle: 1
        Page: 1/2
        Features: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          Secure Simple Pairing (Host Support)
          LE Supported (Host)
          Simultaneous LE and BR/EDR (Host)
          Secure Connections (Host Support)
< HCI Command: Remote Name Request (0x01|0x0019) plen 10                                                                                                                                                                                                                  #16 [hci0] 14.845484
        Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
< ACL Data TX: Handle 1 flags 0x00 dlen 10                                                                                                                                                                                                                                #17 [hci0] 14.845502
      L2CAP: Information Request (0x0a) ident 1 len 2
        Type: Extended features supported (0x0002)
< ACL Data TX: Handle 1 flags 0x00 dlen 16                                                                                                                                                                                                                                #18 [hci0] 14.845526
      L2CAP: Information Response (0x0b) ident 2 len 8
        Type: Extended features supported (0x0002)
        Result: Success (0x0000)
        Features: 0x000002b8
          Enhanced Retransmission Mode
          Streaming Mode
          FCS Option
          Fixed Channels
          Unicast Connectionless Data Reception
> HCI Event: Link Supervision Timeout Changed (0x38) plen 4                                                                                                                                                                                                               #19 [hci0] 14.845680
        Handle: 1
        Timeout: 5000.000 msec (0x1f40)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                                                                                 #20 [hci0] 14.847801
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Success (0x00)
> HCI Event: Remote Name Req Complete (0x07) plen 255                                                                                                                                                                                                                     #21 [hci0] 14.859923
        Status: Success (0x00)
        Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Name: Sasa's S21 Ultra
@ MGMT Event: Device Connected (0x000b) plen 31                                                                                                                                                                                                                      {0x0001} [hci0] 14.859948
        BR/EDR Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Flags: 0x00000000
        Data length: 18
        Name (complete): Sasa's S21 Ultra
@ RAW Close: python3                                                                                                                                                                                                                                                 {0x0002} [hci0] 15.848984
< HCI Command: Disconnect (0x01|0x0006) plen 3                                                                                                                                                                                                                            #22 [hci0] 17.852261
        Handle: 1
        Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                                                                                 #23 [hci0] 17.853904
      Disconnect (0x01|0x0006) ncmd 1
        Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                                                                                                                                                            #24 [hci0] 17.867262
        Status: Success (0x00)
        Handle: 1
        Reason: Connection Terminated By Local Host (0x16)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                                                                                                                                    {0x0001} [hci0] 17.867286
        BR/EDR Address: BB:BB:BB:BB:BB:BB (OUI AC-6C-90)
        Reason: Connection terminated by local host (0x02)
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1                                                                                                                                                                                                                     #25 [hci0] 17.920401
        Scan enable: Page Scan (0x02)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                                                                               #26 [hci0] 17.924903
      Write Scan Enable (0x03|0x001a) ncmd 1
        Status: Success (0x00)
Sash
  • 1,134
  • 11
  • 23

0 Answers0