Problem description I have a BLE device. I want to communicate with it. My Android application code:
device.connectGatt(context, false, ...)
If the device is in pairing mode, I can connect to it. But if I want to connect to already paired device with the same code, I get an error. Exactly the same use case works well on my Linux PC with the device in pairing and non-pairing mode. (I've used Python gatt module for it)
I've dumped the Bluetooth traffic and I see some differences there during the connection.
Linux/not pairing
- Sent: LE Create Connection
- Rcvd: Command Status (LE Create Connection)
- Rcvd: LE Meta (LE Connection Complete)
- Sent: LE Read Remote Features
- Rcvd: LE Meta (LE Channel Selection Algorithm)
- Rcvd: Command Status (LE Read Remote Features)
- Rcvd: LE Meta (LE Read Remote Features Complete)
- Sent: LE Start Encryption
Android/pairing
- Sent: LE Create Connection
- Rcvd: Command Status (LE Create Connection)
- Rcvd: LE Meta (LE Enhanced Connection Complete)
- Sent: LE Read Peer Resolvable Address
- Rcvd: Command Complete (LE Read Peer Resolvable Address)
- Sent: LE Read Remote Features
- Rcvd: Command Status (LE Read Remote Features)
- Rcvd: LE Meta (LE Read Remote Features Complete)
- Sent: Read Remote Version Information
- Rcvd: Command Status (Read Remote Version Information)
- Rcvd: Read Remote Version Information Complete
- Sent: LE Start Encryption
Android/not pairing
- Sent: LE Create Connection
- Rcvd: Command Status (LE Create Connection)
- Rcvd: LE Meta (LE Enhanced Connection Complete)
- Sent: LE Read Peer Resolvable Address
- Rcvd: Command Complete (LE Read Peer Resolvable Address)
- Sent: LE Read Remote Features
- Rcvd: Command Status (LE Read Remote Features)
- Rcvd: LE Meta (LE Read Remote Features Complete) <-- Failed with Status: Connection Failed to be Established (0x3e)
So I've decided to compare the content of
LE Meta (LE Read Remote Features Complete)
packets of all 3 tries:
Linux/not pairing: Supported LE Features: 0x0000000000004105, LE Encryption, Extended Reject Indication, LE 2M PHY, Channel Selection Algorithm #2
Android/pairing: Supported LE Features: 0x0000000000000005, LE Encryption, Extended Reject Indication
Android/not pairing: Supported LE Features: 0x00000000000000ef, LE Encryption, Connection Parameters Request Procedure, Extended Reject Indication, Slave-Initiated Features Exchange, Data Packet Length Extension, LL Privacy, Extended Scanner Filter Policies
Does anyone knows how can I solve this problem?