fix: remove BleakClient.pair() call that breaks BLE on no-PIN devices#159
Open
ecapuano wants to merge 1 commit into
Open
fix: remove BleakClient.pair() call that breaks BLE on no-PIN devices#159ecapuano wants to merge 1 commit into
ecapuano wants to merge 1 commit into
Conversation
…ices without PIN
The pair() call after BLE connection establishment causes an ATT protocol
error 0x0e ("Unlikely Error") on Meshtastic devices with Bluetooth PIN
disabled. Although the pair() call is wrapped in a try/except, on
Linux/BlueZ it corrupts the GATT connection state — subsequent
characteristic reads and notifications fail, causing the integration to
never complete setup and report "Unable to connect to the device."
The pair() call was documented as best-effort ("should not harm if not
needed"), but it actively prevents connection on no-PIN devices, which is
the required configuration since PIN support is not yet implemented (meshtastic#37).
For devices that do require pairing, the call also did not work reliably
due to Bleak limitations (hbldh/bleak#1434).
Fixes meshtastic#99
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BleakClient.pair()call inBluetoothConnection._connect()that causes ATT error 0x0e ("Unlikely Error") on Meshtastic devices with Bluetooth PIN disabledpair()call corrupts the GATT connection state on Linux/BlueZ, causing all subsequent characteristic reads/notifications to failDetails
The
pair()call was intended as best-effort ("should not harm if not needed"), but on devices without PIN:pair()triggers an ATT protocol error 0x0e on the BlueZ stackexcept, the pairing attempt corrupts the BLE connection statestart_notify,read_gatt_char) fail withBleakDBusErrororNotConnectedbluetoothctl connectworks fine from the host — the issue is specifically thepair()call from within Bleak/habluetooth.For devices that do require pairing, the
pair()call also did not work reliably due to Bleak limitations (hbldh/bleak#1434), as noted in the removed comment.Testing
Tested on:
Before: "Unable to connect to the device" every time
After: Connection succeeds, integration sets up normally
Fixes #99
Related: #37
Test plan
🤖 Generated with Claude Code