trouble icon indicating copy to clipboard operation
trouble copied to clipboard

Support for BLE 4.0/4.1 (pre-4.2) device compatibility?

Open jmjoy opened this issue 3 months ago • 3 comments

Hi,

I'm encountering a compatibility issue when using @embassy-rs/trouble for BLE development. My controller device only supports BLE 4.0/4.1 and does not support BLE 4.2 features such as Data Length Extension.

When running the examples/esp32/src/bin/ble_bas_central_sec.rs example and attempting to pair with this device, I get the following errors:

ERROR - [smp] Failed to handle command PairingResponse, Security(UnspecifiedReason)
ERROR - Handling of command failed Security(UnspecifiedReason)
ERROR - Failed to handle security manager packet, Security(UnspecifiedReason)

Does @embassy-rs/trouble plan to support devices with BLE 4.0/4.1 (pre-4.2)? Are there any recommendations or workarounds for compatibility with devices below BLE 4.2?

Thank you!

jmjoy avatar Aug 20 '25 06:08 jmjoy

DLE is not mandated at all by trouble, and I think in general it should work with BLE 4.0. How can you be sure it's related to the BLE version?

lulf avatar Aug 20 '25 07:08 lulf

This conclusion was actually reached by AI:

This UnspecifiedReason error is most likely because the peer device does not support LE Secure Connections (a security feature of BLE 4.2+) or the pairing parameters are incompatible. Let me check the trouble-host source code to see when this error specifically occurs.

Searching for UnspecifiedReason|secure_connection (/host/src/security_manager/), 19 text results found.

Found it! The problem is here:

if !peer_features.security_properties.secure_connection() {
    return Err(Error::Security(Reason::UnspecifiedReason));
}

trouble-host requires the peer device to support LE Secure Connections, but your gamepad may only support the older BLE 4.0/4.1 security protocols.

Let me check if there's a configuration option to disable this requirement:

Reading central.rs, lines 450 to 470

Reading peripheral.rs, lines 365 to 385

The problem is obvious! The trouble-host library hard-codes a check during the pairing process, forcing the peer device to support LE Secure Connections. There is no configuration option to bypass it.

This means your gamepad is likely an older BLE 4.0/4.1 device that does not support LE Secure Connections (a BLE 4.2+ feature).

jmjoy avatar Aug 20 '25 07:08 jmjoy

Ah, I see, it's the lack of 4.0 pairing support. Let's keep this open in case someone wants to work on it then.

lulf avatar Sep 05 '25 08:09 lulf