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

后端 未结 2 787
迷失自我
迷失自我 2020-12-08 12:07

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

private          


        
2条回答
  •  隐瞒了意图╮
    2020-12-08 13:04

    You need to create InputStream and OutputStream so you can talk to the phone:

    mmInStream = m_oBluetoothSocket.getInputStream();
    mmOutStream = m_oBluetoothSocket.getOutputStream();
    

    To setup the HFP connection you start to send:

    mmOutStream.write("AT+BRSF=20\r".getBytes());
    

    Where 20 is code for what you support of HFP.

    And to read from the phone:

    buffer = new byte[200];
    mmInStream.read(buffer);
    command = new String(buffer).trim();
    

    So now you can talk beetwen the devices and you can read more about the Handsfree profile on https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=238193

提交回复
热议问题