Android Bluetooth PBAP

I will try to briefly imagine what I'm working on, and then present my question ... any help would be greatly appreciated!

I tried to connect the Android device to other phones in order to import phone book information via Bluetooth using the phone book access profile. To achieve this, I am trying to host my device as a PCE, while the other phone will act as a PSE.

I know that the role of PSE is already implemented on Android, so I'm studying its code and trying to somehow convert it to implement the other way.

So my problem is: when the server socket is created, it does not specify any UUID, it just starts listening on port 19, for example:

mServerSocket = mAdapter.listenUsingRfcommOn(PORT_NUM);

Wasn't it necessary to register for the PBAP service? How to make other devices discover the service and, more importantly, the UUID should be used when trying to connect to my PCE device using:

mSocket = mDevice.createRfcommSocketToServiceRecord(UUID_PBAP);

Thanks Pedro.

+3
source share
2 answers

you must use uuid to create the client socket, sdp will find the polling channel for you.

You don’t need to worry about the channel number, and the channel you have assigned is not always right in different channels.

+1
source

use this method: listenUsingRfcommWithServiceRecord for the BluetoothAdapter with the correct UUID.

0
source

Source: https://habr.com/ru/post/1762908/


All Articles