I try to connect android to linux via bluetooth low energy GATT mode.
There is a example code in Bluez: btgatt-server.c, I use it as server.
The Android Side be as the Android official example:Connecting to a GATT Server. That is, use function BluetoothDevice::connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback).
After running, the Android part returned the connection be successful,(the parameter of BluetoothGattCallback::onConnectionStateChange be STATE_CONNECTED), but the program in linux(btgatt-server) did not get any response, that still block in waiting accepting. ( line 485).
I also used another example code : l2cap-ble.c, the result was totally the same.
Anyone could help me? my goal is : after connecting, linux gatt server would send a data to Android. Then disconnecting.
thank you lots.
I just now faced the same problems.
This seems like a bug that happens with Android and Broadcom bluetooth modules. Android somehow connects to the wrong l2cap channel.
A workaround is to explicitely disable BR/EDR support in the advertisements.
The bug report on google with the solution in #8 can be found here, the quote on the hint that helped me:
Using bluez btmgmt for configuring the advertisements on device hci0 i issue the following commands:
Starting the bluez btgatt-server example: