蓝牙低功耗:Android Gatt-Client连接到Linux Gatt服务器
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了蓝牙低功耗:Android Gatt-Client连接到Linux Gatt服务器,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1481字,纯文字阅读大概需要3分钟。
内容图文
![蓝牙低功耗:Android Gatt-Client连接到Linux Gatt服务器](/upload/InfoBanner/zyjiaocheng/950/37fa22b8bb6f4406beb55af88180db30.jpg)
我尝试通过蓝牙低能量GATT模式将android连接到linux.
Bluez中有一个示例代码:btgatt-server.c,我用它作为服务器.
Android Side与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和Broadcom蓝牙模块发生的错误. Android以某种方式连接到错误的l2cap通道.
解决方法是明确禁用广告中的BR / EDR支持.
谷歌与#8中的解决方案的错误报告可以找到here,提示上的引用帮助了我:
I have obtained information from Broadcom regarding this bug and I don’t think its a bug on their part. If one does not specifically set the ‘BR/EDR not supported’ bit in the advertisement (bit 2), the Broadcom stack will use BR/EDR and BTLE.
Changing the leading advertisement package from 020102 to 020106 solved the problem.
使用bluez btmgmt在设备hci0上配置通告,我发出以下命令:
btmgmt -i hci0 power off
btmgmt -i hci0 le on
btmgmt -i hci0 connectable on
btmgmt -i hci0 bredr off # Disables BR/EDR !
btmgmt -i hci0 advertising on
btmgmt -i hci0 power on
启动bluez btgatt-server示例:
btgatt-server -i hci0 -s low -t public -r -v
内容总结
以上是互联网集市为您收集整理的蓝牙低功耗:Android Gatt-Client连接到Linux Gatt服务器全部内容,希望文章能够帮你解决蓝牙低功耗:Android Gatt-Client连接到Linux Gatt服务器所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。