How to query remote mobile phone via Bluetooth as to whether it supports PBAP or not?

安稳与你 提交于 2019-12-22 09:48:45

问题


Suppose two Android mobile phones are paired via Bluetooth and connection is established. How to programmatically determine at the client whether the remote device (the server) supports Bluetooth profiles such as PBAP?

And if it does support it, then how to programmatically initiate a PBAP session with the remote device?

I have extensively searched the net and so far have been unable to find API support and documentation for the same.

Edit

Would fetching the remote device's UUIDs be of any use here? If yes, how do I get to know whether it supports PBAP from that?

Update

I managed to connect to the remote device using:

mBluetoothSocket = mBluetoothDevice.createRfcommSocketToServiceRecord(applicationUUID);
                            btAdapter.cancelDiscovery();
                            mBluetoothSocket.connect();

where

 private UUID applicationUUID = UUID.fromString("0000111E-0000-1000-8000-00805F9B34FB");

for hands free profile mode. Is there any such fixed UUID for connecting through PBAP mode though?

Update 2

Now I am able to pair with the remote device using the UUID 0000112F, which is the UUID for PSE access. When the connection is established, I get a message on the remote device asking me whether I can allow remote device access to call logs and contacts. I click on yes.


回答1:


I managed to connect to the remote device using:

mBluetoothSocket = mBluetoothDevice.createRfcommSocketToServiceRecord(applicationUUID);
                        btAdapter.cancelDiscovery();
                        mBluetoothSocket.connect();

where

 private UUID applicationUUID = UUID.fromString("0000112F-0000-1000-8000-00805F9B34FB");

I am able to pair with the remote device using the UUID 0000112F, which is the UUID for PSE access. When the connection is established, I get a message on the remote device asking me whether I can allow client access to call logs and contacts. I click on yes. PBAP connection is made.

Posting this for reference to any person struggling with this in future :).



来源:https://stackoverflow.com/questions/23948610/how-to-query-remote-mobile-phone-via-bluetooth-as-to-whether-it-supports-pbap-or

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