繁体   English   中英

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

[英]BluetoothEventLoop( 2255): Device property changed.Bluetooth Connection Lost

我有一个示例应用程序,该应用程序通过蓝牙传输了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:PropertyChanged from / org / bluez / 3179 / hci0 / dev_22_89_8E_A9_50_1C

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

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

09-12 11:16:36.245 D / BluetoothA2DPStateReceiver(20246):onReceive():操作= 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否

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

可能是由于链接丢失所致,BT适配器已启动属性更改命令以报告链接断开与上层的连接。 请检入多设备。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM