Ошибка Android BLE 0x06 Запрос не поддерживается

Мое приложение сталкивается с проблемой при подключении к устройству BLE. При каждой попытке подключения приложение получает код ошибки 0x0006 (запрос не поддерживается) в методе OnConnectionStateChange(). Я пробовал выключать/включать Bluetooth, но все равно получаю ту же ошибку.

Я столкнулся с этой проблемой в LG D410 (Android 5.0.2). После того, как я обновил свой телефон LG до 5.0.2, приложение начало получать эту ошибку. Мое приложение отлично работает с Samsung Galaxy S4 (Android 5.1), Nexus 5 (Android 6.0).

Почему я получаю эту ошибку? Что можно сделать, чтобы это исправить?

Вот логи ошибок:

02-26 05:30:53.919 D/MyBluetoothClass-1392940(21607): trying to connect with address: 78:A5:04:86:D4:16 02-26 05:30:53.944 D/MyBluetoothClass-1392940(21607): Create a new GATT connection. 02-26 05:30:53.945 D/BluetoothGatt(21607): connect() - device: 78:A5:04:86:D4:16, auto: true 02-26 05:30:53.945 D/BluetoothGatt(21607): registerApp() 02-26 05:30:53.945 D/BluetoothGatt(21607): registerApp() - UUID=a81c9b62-f822-4e42-9af0-752a8eab82a1 02-26 05:30:53.947 D/BluetoothGatt(21607): onClientRegistered() - status=0 clientIf=5 02-26 05:30:53.947 D/MyBluetoothClass-1392940(21607): Connection attempt started; results reported asynchronously 02-26 05:30:53.947 D/BluetoothGatt(21607): refresh() - device: 78:A5:04:86:D4:16 02-26 05:30:53.950 D/BluetoothGatt(21607): onClientConnectionState() - status=6 clientIf=5 device=78:A5:04:86:D4:16 02-26 05:30:53.951 D/MyBTGattCallback(21607): onConnectionStateChange, newState: 0 02-26 05:30:53.951 E/MyBTGattCallback(21607): onConnectionStateChange status 0006 desc Req not supported


person Alina    schedule 04.03.2016    source источник


Ответы (1)


Я думаю, что есть проблема в инфраструктуре BlueDroid в версиях Android Lollipop. если вы используете connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback) pass autoConnect = false;

установка autoConnect в значение true вызывает аномалии в onClientConnectionState в версии Lollipop, однако в Marshmallow работает надлежащим образом.

Я заставил это работать.

@Override
protected void onStart() {
    super.onStart();
    Log.d(TAG,"connecting Gatt");
    bluetoothGatt = bleScanResult.getBluetoothDevice().connectGatt(this, false, callback);
}


@Override
    protected void onStop() {
        super.onStop();
        if (bluetoothGatt != null) {
            Log.d(TAG,"disconnecting Gatt");
            bluetoothGatt.disconnect();
            bluetoothGatt.close();
            bluetoothGatt = null;
        }
    }
person navalkishoreb    schedule 11.07.2016