Bluetooth -> service discovery failed

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 17:42:20
philDev

OK, I got the same problem, but I think I can answer a few of your questions. If your PC opened an SPP Port, for example, by using "sdptool add --channel=3 SP" your Android phone would be the client opening a socket and connecting with this socket to the server (your PC or any other Bluetooth device, for example, GPS, mouse, etc.).

You can get this information by reading the article Bluetooth, the definition of a client did I take out of this article.

If you are opening an SPP Port on the server (your PC, etc.) you are offering a standard service and there is a special UUID assigned to this service. This would be: 00001101-0000-1000-8000-00805F9B34FB if I'm not mistaken.

So I think we should get a qualified answer from an Android developer. Or ask this question on Thursday during the IRC office hours.

Hint: If you are connecting to a Bluetooth serial board then try using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB. However if you are connecting to an Android peer then please generate your own unique UUID.

The Link

Brad Hein

Although it could be your UUID, I would also suggest you make sure the Bluetooth MAC is accurate and upper-case.

I would also suggest running hcidump -X in a terminal on the Linux box, and see if you can see any two-way traffic between your Linux machine and phone throughout the process.

Yoann

I found a way to be sure that the UUID is found on the device. On the client side, before device.createRfcommSocketToServiceRecord(uuid); add:

Process process = Runtime.getRuntime().exec("su -c 'sdptool records " + device.getAddress() + "'");
process.waitFor();

The process is frozen during 20-30 seconds, because Android is fetching services. But after, if the server is in discovery mode (if the server is an Android phone), the connection succeeds every time!

chihying

I had the same problem when reconnecting SPP after the first connect.

This is because rfcomm channel=-1 in BluetoothService.java. I added updateDeviceServiceChannelCache() to the end of fetchRemoteUuids(), and then it worked!

AbdiT

This thing happens mostly to HTC. I faced the same problem. If you first connected successfully but fail afterwards, just restart the phone and the service that failed will restart in doing so.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!