无法在免提和Android移动之间建立音频通信

时间:2013-10-03 11:00:08

标签: android mobile audio bluetooth

我的要求是开发一个应用程序,它将接收呼叫,断开呼叫,并通过蓝牙[配对]使用免提配置文件从免提拨号到Android移动设备。

注意:我正在尝试将一部手机设为免提,而我试图通过蓝牙配对其他手机,如果来电话,我应该可以通过免提手机接听和讲话。这可能吗???

抓取n个帖子后,我可以将AT命令从免提发送到Android手机。因此,如果我在Android移动设备上接听电话,我可以断开呼叫,并且我也可以通过在免提中运行以下代码从免提设备拨打电话。

m_oBluetoothSocket = btDevice.createRfcommSocketToServiceRecord(MY_UUID);
Log.i("Not Connected +:  ", "Socket Connected");

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

// AT command to receive call
 mmOutStream.write("ATA\r".getBytes());
    dis = new DataInputStream(mmInStream);
    av = dis.available();
    if (av != 0) {
        byte[] b = new byte[av];
        dis.read(b);
        System.out.println(new String(b) + "Recieved form modem");
}

要断开呼叫,我用ATA\r命令替换了AT+CHUP

我面临的问题是在接到电话后,我无法说话或听到,也无法与手机进行音频通讯。

我按照本指南来实现这一目标,但在接到免提电话后,我无法进行音频通信。

http://www.mcpc-jp.org/news/pdf/CCAP_Guideline_Ver10a.pdf

在上面的文档中,我遵循6.2.5.1。使用以下代码接听来自HF(无带内振铃)部分的来电。

m_oBluetoothSocket = btDevice.createRfcommSocketToServiceRecord(MY_UUID);
Log.i("Not Connected +:  ", "Socket Connected");

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

 mmOutStream.write("AT+CIND=?\r".getBytes());
 DataInputStream dis = new DataInputStream(mmInStream);
    int av = dis.available();
    if (av != 0) {
        byte[] b = new byte[av];
        dis.read(b);
        System.out.println(new String(b) + "CIND=? Recieved form modem");
 }

mmOutStream.write("AT+CIND?\r".getBytes());
dis = new DataInputStream(mmInStream);
av = dis.available();
if (av != 0) {
    byte[] b = new byte[av];
    dis.read(b);
    System.out.println(new String(b)
            + "CIND Recieved form modem");
}

mmOutStream.write("AT+CMER\r".getBytes());
dis = new DataInputStream(mmInStream);
av = dis.available();
if (av != 0) {
    byte[] b = new byte[av];
    dis.read(b);
    System.out.println(new String(b) + "NREC Recieved form modem");
}

mmOutStream.write("AT+NREC=0\r".getBytes());
dis = new DataInputStream(mmInStream);
av = dis.available();
if (av != 0) {
    byte[] b = new byte[av];
    dis.read(b);
    System.out.println(new String(b) + "NREC Recieved form modem");
}

mmOutStream.write("AT+CHLD=?\r".getBytes());
dis = new DataInputStream(mmInStream);
av = dis.available();
if (av != 0) {
    byte[] b = new byte[av];
    dis.read(b);
    System.out.println(new String(b) + "CHLD  Recieved form modem");
}

mmOutStream.write("ATA=?\r".getBytes());
dis = new DataInputStream(mmInStream);
av = dis.available();
if (av != 0) {
    byte[] b = new byte[av];
    dis.read(b);
    System.out.println(new String(b) + "CHLD  Recieved form modem");
}

Manifest文件中的权限。

<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BROADCAST_STICKY"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

我能够从Android手机获得适当的响应,但在接到电话后我无法说话和听到。

请帮我解决这个问题。

0 个答案:

没有答案