问题
So far I have been able to initiate a call from the AG (Audio Gateway) which is an Android phone through bluetooth connection from the phone in which my app is loaded (the HF or Hands-free), to the target phone. I have used this code for this procedure:
///////////////////////////////////////////////////////////////////////////////
//Here, how to establish voice connectivity from AG to my phone(HF)?
//////////////////////////////////////////////////////////////////////////////
// Calling the target phone from the AG via the HF using bluetooth Handfree Audio Gateway
try {
mmOutStream.write(("ATD"+phone_number+"\r").getBytes());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Right now, I am able to initiate the call from my hands free(HF) device, but I am unable to hear the ringtone or hear the other person speak.
Looks like I have just been able to trigger the call mechanism so far. How to establish audio connectivity so that I can also hear the speaker at the target phone as well as speak?
回答1:
It appears that you are trying to implement the Handsfree unit role on the Phone. One way of doing this is if you have 2 Phones, Phone A (behaves as AG), Phone B (HandsFree Unit) then
Phone B needs to send appropriate AT commands to Phone A, to make itself appear as a Bluetooth headset. If this is done right, then i dont think any changes are required on Phone A to route the audio to Bluetooth SCO link. To see what AT commands are sent by a Handsfree unit, perhaps logs from Phone A (AG) connected to a standard Bluetooth headset will help. Or the Handsfree Specification.
On Phone B, assuming that all the AT commands have been sent to Phone A to make itself appear as a HF unit and then a call is set up ( Phone A to remote party) by sending ATD from Phone B, Phone A may set up SCO as it would do with a standard Bluetooth headset. If not, then Phone B may have to invoke AudioManager.startBluetoothSco() to set up SCO. In addition to SCO being set up, Phone B would have to route audio to SCO. I think the APIs are AudioManager.SetMode() and AudioManager.setBluetoothScoOn().
来源:https://stackoverflow.com/questions/24257916/how-to-initiate-a-call-from-hf-through-ag-via-handfree-audio-gateway-in-android