BluetoothEventLoop(2255):设备属性已更改。蓝牙连接丢失

时间:2013-09-12 07:29:00

标签: java android bluetooth

我有一个示例应用程序,它通过蓝牙传输30个字符长度数据。数据传输适当的四天,然后断开连接。然后,几分钟后建立连接时蓝牙连接丢失。添加adb日志和代码

为什么我因设备属性更改而与平台断开连接?设备属性何时更改?设备属性更改是否是松动蓝牙连接的原因?

private static final UUID MY_UUID_SECURE = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

private class ConnectThread extends Thread {
    private final BluetoothSocket mmSocket;
    private final BluetoothDevice mmDevice;
    private String mSocketType;

    public ConnectThread(BluetoothDevice device, boolean secure) {
        mmDevice = device;
        BluetoothSocket tmp = null;
        mSocketType = secure ? "Secure" : "Insecure";

        // Get a BluetoothSocket for a connection with the
        // given BluetoothDevice
        try {

                tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);

        } catch (IOException e) {
            Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
        }
        mmSocket = tmp;
        Log.i("12345", "Socket set");
    }

    public void run() {
        Log.i("12345", "BEGIN mConnectThread SocketType:" + mSocketType);
        setName("ConnectThread" + mSocketType);

        // Always cancel discovery because it will slow down a connection
        mAdapter.cancelDiscovery();

        // Make a connection to the BluetoothSocket
        try {
            // This is a blocking call and will only return on a
            // successful connection or an exception
            mmSocket.connect();
        } catch (IOException e) {
            // Close the socket
            try {
                mmSocket.close();
                Log.i(TAG, "Closing Socket 3");
            } catch (IOException e2) {
                Log.e(TAG, "unable to close() " + mSocketType + " socket during connection failure", e2);
            }
            connectionFailed();
            return;
        }

        // Reset the ConnectThread because we're done
        synchronized (BluetoothChatService.this) {
            mConnectThread = null;
        }

        // Start the connected thread
        connected(mmSocket, mmDevice, mSocketType);
    }

日志:

09-12 11:16:36.230 V / BluetoothEventLoop.cpp(2255):event_filter:收到的信号org.bluez.Device:来自/ org / bluez / 3179 / hci0 / dev_22_89_8E_A9_50_1C的PropertyChanged

09-12 11:16:36.230 D / BluetoothEventLoop(2255):设备属性已更改

09-12 11:16:36.240 D / BluetoothA2DPStateReceiver(20246):BluetoothA2DPStateReceiver构造函数调用()

09-12 11:16:36.245 D / BluetoothA2DPStateReceiver(20246):onReceive():action = android.bluetooth.device.action.ACL_DISCONNECTED

09-12 11:16:36.245 D / BluetoothA2DPStateReceiver(20246):ACTION_ACL_DISCONNECTED

09-12 11:16:36.245 D / BluetoothA2DPSinkInfo(20246):checkBlackListCarkit():isBlackListCarkit false

09-12 11:16:36.660 D / KeyguardViewMediator(2255):setHidden false

1 个答案:

答案 0 :(得分:0)

可能是由于链路丢失,BT适配器已经启动了属性更改命令,报告链路断开连接到上层。请检查多个设备。