Here I am trying to connect two android devices using Bluetooth classic and transfer calls through HFP profile.
If Device A has an incoming call, I need to notify Device B and accept/decline from the device B side and even need to talk from device B side.
I have made changes from source side in Bluetooth configs to enable A2DP sink and HF role (disabled AG role) for HFP profile in Device B.
I am confused about How AT commands works. I have to pass AT commands through output stream (Bluetooth classic connection).
Is it enough just pass AT commands(as per HFP document) to accept the call or Do I have to handle calls in the Device B side based on received AT command? I am creating an app for this work.
And also calls automatically will stream through the connection if the call accepted through AT command or Do i have to manually do something for this from the app level?
Android framework provide good support for HFP.
As how to act as an HF role:
private BluetoothHeadsetClient mBluetoothHeadsetClient;
private final ServiceListener mHfpServiceListener = new ServiceListener() {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
if (profile == BluetoothProfile.HEADSET_CLIENT) {
mBluetoothHeadsetClient = (BluetoothHeadsetClient) proxy;
}
}
@Override
public void onServiceDisconnected(int profile) {
if (profile == BluetoothProfile.HEADSET_CLIENT) {
mBluetoothHeadsetClient = null;
}
}
};
mAdapter.getProfileProxy(context.getApplicationContext(), mHfpServiceListener,
BluetoothProfile.HEADSET_CLIENT);
mBluetoothHeadsetClient.connect(remoteDevice)
IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED);
filter.addAction(BluetoothHeadsetClient.ACTION_AG_EVENT);
mContext.registerReceiver(this, filter);
filter.addAction(BluetoothHeadsetClient.ACTION_CALL_CHANGED);
mContext.registerReceiver(this, filter);
mBluetoothHeadsetClient.dail
mBluetoothHeadsetClient.acceptCall
mBluetoothHeadsetClient.sendVendorAtCommand
Android provide high level APIs, and you don't need to send a AT comand to accept the call.