• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to send AT commands based on BT Hands-Free profile in android?

KavitaDev

Newbie
I am trying to establish Bluetooth connection between an Android device with other mobile phone over Handsfree profile. I am using following code -

Code:
private static final UUID MY_UUID = UUID.fromString("0000111F-0000-1000-8000-00805F9B34FB"); // UUID for Hands free profile 

// Some code...

// Get Bluetooth Adapter. 
m_oBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 

// Some code... 

// For paired BT device, getting a connection established.
if(null != m_oBluetoothDevice)
{
    if(BluetoothDevice.BOND_BONDED == m_oBluetoothDevice.getBondState())
    {
      try
      {
         m_oBluetoothSocket = m_oBluetoothDevice.createRfcommSocketToServiceRecord(MY_UUID);     
         m_oBluetoothSocket.connect();
         Log.i(TAG, "Socket Connected");
      }
      catch(Exception e)
      {
         if(null != m_oBluetoothSocket)
         {
             Log.i(TAG, "Closing socket");
             try 
             {
                m_oBluetoothSocket.close();
             }
             catch (Exception e1) 
             {
                Log.i(TAG, "Error while closing socket : " + e1.getMessage());
             }
         }
      }               
   }
}
I can create RFCOMMSocket using above code.

Now I want to send AT commands based on Bluetooth Hands-Free profile. e.g. If other mobile phone receives a phone call, my Android device can reject this call by sending AT command- "+CHUP". I am not sure whether this is possible or not.

At this point, I am stuck. I have read Bluetooth APIs where I found -

Code:
BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
Can we use this Intent for sending AT commands? Is this a proper way to send AT command based on Bluetooth Hands-Free profile? Please someone help me out and give me proper direction.

Any input from you all will be great help for me.

Thanks in advance.
 
Back
Top Bottom