我刚刚面临同样的问题.
这似乎是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