3

BLE デバイスへの接続中にアプリに問題が発生しました。アプリが接続を試行するたびに、OnConnectionStateChange() メソッドでエラー コード 0x0006 (リクエストはサポートされていません) を取得します。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

4

1 に答える 1

0

Android Lollipop バージョンの BlueDroid フレームワークに問題があると思います。connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback) pass autoConnect = false;を使用する場合。

Lollipop 版では autoConnect を true にすると onClientConnectionState に異常が発生しますが、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;
        }
    }
于 2016-07-11T10:37:04.330 に答える