trouble
trouble copied to clipboard
Support for BLE 4.0/4.1 (pre-4.2) device compatibility?
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!
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?
This conclusion was actually reached by AI:
This
UnspecifiedReasonerror 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 thetrouble-hostsource 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-hostrequires 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-hostlibrary 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).
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.