Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
215 views
in Technique[技术] by (71.8m points)

bluetooth - How to initiate a call from HF through AG via Handfree Audio Gateway in Android?

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+"
").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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

  1. 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.

  2. 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().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...