回调:编写GATT描述符时出错:133

时间:2019-03-23 17:55:44

标签: android bluetooth

我正在使用我的设备和自定义APP。在此刻,我的APP无需配对即可很好地工作。如果启用配对,则会在此处发现此错误,并且无法与设备通信。我该如何解决该错误?我在Android 9.0上使用了三星A8。

这是我的onConnectionStateChange:

@Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
        super.onConnectionStateChange(gatt, status, newState);
        String intentAction;
        BluetoothAdapter bleAdapter = ((BluetoothManager) getSystemService(BLUETOOTH_SERVICE)).getAdapter();
        Set<BluetoothDevice> paired = bleAdapter.getBondedDevices();

        for (BluetoothDevice device : paired) {
           // device.
            Log.e(TAG, "onConnectionStateChange: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+status+" <><><><><>< "+ newState);
            if (device.getName().equals("RCQ4-BLE")) {
                //Log.e("Paired", "It paired" + bleAdapter.getBondedDevices());
                switch (newState) {
                    case BluetoothProfile.STATE_CONNECTED:
                       // mBluetoothGatt.connect();
                        intentAction = ACTION_GATT_CONNECTED;
                        Log.e("Device", "Connected but not working");
                        broadcastUpdate(intentAction);
                        Log.e("gattCallback", "STATE_CONNECTED");
                        mBluetoothGatt.discoverServices();
                        //gatt.discoverServices();
                        break;
                    case BluetoothProfile.STATE_DISCONNECTED:
                        Log.e("gattCallback", "STATE_DISCONNECTED");
                        intentAction = ACTION_GATT_DISCONNECTED;
                        broadcastUpdate(intentAction);
                        addNotification();
                        // Close connection completely after disconnect, to be able
                        // to start clean.
                        if (mBluetoothGatt != null) {
                            mBluetoothGatt.close();
                            mBluetoothGatt = null;
                        }
                        break;
                    default:
                        Log.e("gattCallback", "STATE_OTHER");
                }
            }
        }
    }

在onStateConnectionChange中,我收到状态22。

0 个答案:

没有答案