我尝试通过蓝牙低功耗GATT模式将android连接到linux。蓝牙低功耗:Android Gatt-Client连接到Linux Gatt服务器
在Bluez中有一个示例代码:btgatt-server.c,我用它作为服务器。
安卓侧视为Android official example:Connecting to a GATT Server。也就是说,使用函数BluetoothDevice :: connectGatt(Context context,boolean autoConnect,BluetoothGattCallback callback)。
运行后,Android部分返回连接成功,(参数BluetoothGattCallback :: onConnectionStateChange为STATE_CONNECTED),但linux(btgatt-server)中的程序没有得到任何响应,仍然阻塞在等待接受。 (第485行)。
我还使用了另一个示例代码:l2cap-ble.c,结果完全相同。
任何人都可以帮助我吗?我的目标是:连接之后,linux gatt服务器会向Android发送数据。然后断开连接。
非常感谢。
当您尝试发生什么从你的Android应用发现服务?还可以尝试'btmon'来查看是否有任何数据包交换真的发生在您的蓝牙接口中。 –
在我的[博客](http://gaiger-programming.blogspot.tw/2015/01/bluetooth-low-energy-customizing-gatt.html)中,我已经做了这个问题来定制gatt服务,请参考它。 –