Skip to content

[PW_SID:1060320] [v4] Bluetooth: Increase LE connection timeout for industrial sensors#3339

Open
BluezTestBot wants to merge 2 commits intoworkflowfrom
1060320
Open

[PW_SID:1060320] [v4] Bluetooth: Increase LE connection timeout for industrial sensors#3339
BluezTestBot wants to merge 2 commits intoworkflowfrom
1060320

Conversation

@BluezTestBot
Copy link
Owner

In an industrial IoT context at Volvo Group, we use TE Connectivity
BLE pressure sensors. These sensors exhibit high latency during
the initial LE connection handshake in noisy RF environments. The
connection systematically fails on Ubuntu Core 22 (BlueZ) because the
connection attempt is aborted too early.

In the v2 thread, it was suggested that userspace (via setsockopt
SO_SNDTIMEO) dictates the connection timeout (defaulting to 40s),
suspecting that userspace was cutting the connection at 2 seconds,
not the kernel.

To verify this, an empirical test was conducted using the following
Python/Bleak script to force the application timeout to 45.0 seconds:

import asyncio
from bleak import BleakClient, BleakScanner
import time

ADDRESS = "E8:C0:B1:D4:A3:3C"

async def test_connection():
device = await BleakScanner.find_device_by_address(ADDRESS, timeout=15.0)
start_time = time.time()
try:
# Forcing 45s timeout in userspace
async with BleakClient(device, timeout=45.0) as client:
print(f"Connected in {time.time() - start_time:.2f}s")
except Exception as e:
print(f"Failed after {time.time() - start_time:.2f}s: {e}")

asyncio.run(test_connection())

  1. Result on UNMODIFIED Kernel: The userspace script patiently waited
    for the full 45 seconds before raising a TimeoutError. If the kernel
    had actually kept the radio connection attempt alive for those
    45 seconds, the connection would have succeeded around the
    12.5-second mark (as proven by the patched kernel test below).
    The fact that it did not proves that the underlying HCI connection
    attempt was aborted early by the kernel. Userspace was blind to this
    abort and kept waiting in a vacuum.

  2. Result on MODIFIED Kernel (with this patch): Using the exact same
    userspace script (45.0s timeout), the connection successfully
    established at the 12.51-second mark.

Conclusion:
This proves that the underlying HCI LE Connection creation is bound by
a strict 2-second timeout derived from conn_timeout in hci_conn.c,
and that userspace socket options do not override this hardcoded HCI
abort in our stack. The sensor physically takes 12.5 seconds to
handshake, making the 2-second kernel limit a hard blocker.

This patch increases the hardcoded LE connection timeout to 20 seconds
to provide a comfortable margin for handshake retries.

Note: If the upstream preference is to not hardcode 20 seconds globally,
I would be happy to submit a v5 that exposes this as a configurable
module parameter (e.g., le_conn_timeout).

net/bluetooth/hci_conn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

tedd-an and others added 2 commits March 2, 2026 21:39
This patch adds workflow files for ci:

[sync.yml]
 - The workflow file for scheduled work
 - Sync the repo with upstream repo and rebase the workflow branch
 - Review the patches in the patchwork and creates the PR if needed

[ci.yml]
 - The workflow file for CI tasks
 - Run CI tests when PR is created

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
In an industrial IoT context at Volvo Group, we use TE Connectivity
BLE pressure sensors. These sensors exhibit high latency during
the initial LE connection handshake in noisy RF environments. The
connection systematically fails on Ubuntu Core 22 (BlueZ) because the
connection attempt is aborted too early.

In the v2 thread, it was suggested that userspace (via setsockopt
SO_SNDTIMEO) dictates the connection timeout (defaulting to 40s),
suspecting that userspace was cutting the connection at 2 seconds,
not the kernel.

To verify this, an empirical test was conducted using the following
Python/Bleak script to force the application timeout to 45.0 seconds:

  import asyncio
  from bleak import BleakClient, BleakScanner
  import time

  ADDRESS = "E8:C0:B1:D4:A3:3C"

  async def test_connection():
      device = await BleakScanner.find_device_by_address(ADDRESS, timeout=15.0)
      start_time = time.time()
      try:
          # Forcing 45s timeout in userspace
          async with BleakClient(device, timeout=45.0) as client:
              print(f"Connected in {time.time() - start_time:.2f}s")
      except Exception as e:
          print(f"Failed after {time.time() - start_time:.2f}s: {e}")

  asyncio.run(test_connection())

1. Result on UNMODIFIED Kernel: The userspace script patiently waited
   for the full 45 seconds before raising a TimeoutError. If the kernel
   had actually kept the radio connection attempt alive for those
   45 seconds, the connection would have succeeded around the
   12.5-second mark (as proven by the patched kernel test below).
   The fact that it did not proves that the underlying HCI connection
   attempt was aborted early by the kernel. Userspace was blind to this
   abort and kept waiting in a vacuum.

2. Result on MODIFIED Kernel (with this patch): Using the exact same
   userspace script (45.0s timeout), the connection successfully
   established at the 12.51-second mark.

Conclusion:
This proves that the underlying HCI LE Connection creation is bound by
a strict 2-second timeout derived from `conn_timeout` in `hci_conn.c`,
and that userspace socket options do not override this hardcoded HCI
abort in our stack. The sensor physically takes 12.5 seconds to
handshake, making the 2-second kernel limit a hard blocker.

This patch increases the hardcoded LE connection timeout to 20 seconds
to provide a comfortable margin for handshake retries.

Note: If the upstream preference is to not hardcode 20 seconds globally,
I would be happy to submit a v5 that exposes this as a configurable
module parameter (e.g., `le_conn_timeout`).
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

CheckPatch
Desc: Run checkpatch.pl script
Duration: 0.25 seconds
Result: PENDING

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

GitLint
Desc: Run gitlint
Duration: 0.31 seconds
Result: PENDING

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

SubjectPrefix
Desc: Check subject contains "Bluetooth" prefix
Duration: 0.12 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

BuildKernel
Desc: Build Kernel for Bluetooth
Duration: 26.41 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

CheckAllWarning
Desc: Run linux kernel with all warning enabled
Duration: 28.62 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

CheckSparse
Desc: Run sparse tool with linux kernel
Duration: 32.32 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

BuildKernel32
Desc: Build 32bit Kernel for Bluetooth
Duration: 25.90 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunnerSetup
Desc: Setup kernel and bluez for test-runner
Duration: 560.97 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_l2cap-tester
Desc: Run l2cap-tester with test-runner
Duration: 32.64 seconds
Result: FAIL
Output:

Total: 96, Passed: 94 (97.9%), Failed: 2, Not Run: 0

Failed Test Cases
L2CAP LE Client - Read 32k Success                   Timed out    2.441 seconds
L2CAP LE Client - RX Timestamping 32k                Timed out    1.897 seconds

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_iso-tester
Desc: Run iso-tester with test-runner
Duration: 104.97 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_bnep-tester
Desc: Run bnep-tester with test-runner
Duration: 6.24 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_mgmt-tester
Desc: Run mgmt-tester with test-runner
Duration: 124.87 seconds
Result: FAIL
Output:

Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.116 seconds

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_rfcomm-tester
Desc: Run rfcomm-tester with test-runner
Duration: 9.68 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_sco-tester
Desc: Run sco-tester with test-runner
Duration: 14.60 seconds
Result: FAIL
Output:

WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_ioctl-tester
Desc: Run ioctl-tester with test-runner
Duration: 11.50 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_mesh-tester
Desc: Run mesh-tester with test-runner
Duration: 12.42 seconds
Result: FAIL
Output:

Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    2.776 seconds
Mesh - Send cancel - 2                               Timed out    1.994 seconds

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_smp-tester
Desc: Run smp-tester with test-runner
Duration: 8.67 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

TestRunner_userchan-tester
Desc: Run userchan-tester with test-runner
Duration: 6.74 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

IncrementalBuild
Desc: Incremental build with the patches in the series
Duration: 0.91 seconds
Result: PENDING

@github-actions github-actions bot force-pushed the workflow branch 3 times, most recently from ab1b299 to 0bcc21a Compare March 6, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants