title: How to send AT commands based on BT Hands-Free profile in android?
body: <p>I am trying to establish Bluetooth connection between an Android device with other mobile phone over Handsfree profile. I am using following code - </p>
  
  <pre><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());
                  }
              }
          }               
      }
  }
  </code></pre>
  
  <p>I can create RFCOMMSocket using this code. </p>
  
  <p>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- <strong>"+CHUP"</strong>. I am not sure whether this is possible or not.</p>
  
  <p>At this point, I am stuck. I have read Bluetooth APIs where I found - </p>
  
  <pre><code>     BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
  </code></pre>
  
  <p>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. </p>
  
  <p>Any input from you all will be great help for me.</p>
  
  <p>Thanks in advance.</p>