0

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?

SoulRayder
  • 5,072
  • 6
  • 47
  • 93

1 Answers1

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

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

Preeti
  • 336
  • 1
  • 7
  • Yes, but **how** do I make HF appear like a bluetooth headset to the AG? – SoulRayder Jun 20 '14 at 04:02
  • The HFU would have to register RFCOMM server with uuid for HFU and once connection is up, send AT commands( AT+BRSF etc) to AG. You may find this link useful http://stackoverflow.com/questions/16610811/how-to-send-at-commands-based-on-bt-hands-free-profile-in-android – Preeti Jun 20 '14 at 07:14
  • I am already using the link you have given :). Currently I am making use of this itself (Handsfree Audio Gateway). But apparently, connecting using this is not enough to make the HF look like a headset to the AG. I have also tried with (Headset Audio Gateway), but it doesn't work much. No other related services are avalaible with the AG (I checked programmatically). So I am stuck with just this. – SoulRayder Jun 20 '14 at 07:23
  • I dont think you can connect AG-AG. On the HF side did you register an RFCOMM socket with a corresponding SDP record for HFU? adapter.listenUsingRfcommWithServiceRecord. AG and HFU have different UUIDs. This will allow AG to connect to HF.Also I think the Class of device on the HF side needs to be updated to Audio major device and Handsfree minor device. I'm not sure if theres an API to do this.. – Preeti Jun 20 '14 at 17:46
  • The problem is it is a requirement that I only control the HF side, and on the AG side I am not supposed to do anything programmatically. – SoulRayder Jun 23 '14 at 10:52