Repository navigation
Fix EINVAL when connecting LE L2CAP client sockets - #64
Merged
Merged
Conversation
lowEnergyClient set both the ATT PSM and the ATT CID on the destination address. l2cap_sock_connect() rejects an address with both l2_psm and l2_cid set, so every LE GATT connection failed immediately with EINVAL. LE ATT uses the fixed channel (CID 4) with PSM 0.
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.
L2CAPSocket.lowEnergyClientbuilt the destination address with bothprotocolServiceMultiplexer: .att(l2_psm= 0x1F) andchannel: .att(l2_cid= 4). The kernel'sl2cap_sock_connect()returnsEINVALwhen both are set, so every LE GATT connection failed immediately with "Invalid argument" before anything reached the controller.LE ATT connects over the fixed channel (CID 4) with PSM 0, the same as BlueZ's
gatttool. This change drops the PSM from the destination address.Testing
GATTCentral.connect(to:)against a Govee H5072 failed in about 0.1 s withInvalid argument, andbtmonshowed no HCI traffic.LE Add Device→ passive scan →LE Create Connectioninbtmon). Debian 13, kernel 6.12, CSR 4.0 USB dongle, Swift 6.4.1.swift test: 86 tests, 1 failure.L2CAPSocketAddressTests.testClassicAddressDecodingalso fails onmasterand is unrelated to this change.