FlutterBleLib icon indicating copy to clipboard operation
FlutterBleLib copied to clipboard

Android Connection Status 133 Gatt Error - Cannot Connect

Open KrystofM opened this issue 4 years ago • 13 comments

Having trouble on some older Android devices with connecting to peripheral. For example Huawei P8Lite Android 6. The connection throws Gatt Error 133:

BleError (Error code: 201, ATT error code: null, iOS error code: null, Android error code: 133, reason: Disconnected from 8C:AA:B5:A7:62:4A with status 133 (GATT_ERROR), internal message: null, device ID: 8C:AA:B5:A7:62:4A, service UUID: null, characteristic UUID: null, descriptor UUID: null)

Disconnected from 8C:AA:B5:A7:62:4A with status 133 (GATT_ERROR)

This seems to be a problem in the function connectToDevice in DeviceConnectingDelegate.

Tracked this down even further to safeConnectToDevice in BleModule in multiplatformbleadapter.

Another flutter ble library has seem to solve this issue somehow: https://github.com/pauldemarco/flutter_blue/issues/231 https://github.com/pauldemarco/flutter_blue/pull/229/files

Any ideas on how to solve this issue?

KrystofM avatar Dec 21 '20 14:12 KrystofM

This seems quite relevant also: https://github.com/Polidea/RxAndroidBle/issues/530

@mikolak Any ideas?

KrystofM avatar Dec 21 '20 15:12 KrystofM

The example in this repo simulates the behavior as well. This seems like an issue that can be solved either by trying to reconnect on fail or on Android 6 or less passing a an argument to gatt connection: https://stackoverflow.com/questions/25330938/android-bluetoothgatt-status-133-register-callback

D/com.polidea.flutter_ble_lib.FlutterBleLibPlugin(22598): on native side observed method: observeConnectionState
I/flutter (22598): 2020-12-22T16:36:41.761853	D	new DeviceDetailsBloc.<ac>:	 Connecting to Undout_A76248
D/com.polidea.flutter_ble_lib.FlutterBleLibPlugin(22598): on native side observed method: connectToDevice
I/flutter (22598): 2020-12-22T16:36:41.798351	D	new DeviceDetailsBloc.<ac>:	 Observed new connection state: 
I/flutter (22598): PeripheralConnectionState.disconnected
D/BluetoothGatt(22598): connect() - device: 8C:AA:B5:A7:62:4A, auto: false
D/BluetoothGatt(22598): registerApp()
D/BluetoothGatt(22598): registerApp() - UUID=67cf31a8-cc2e-4179-b675-b0edbea2679f
D/BluetoothGatt(22598): onClientRegistered() - status=0 clientIf=5
D/BluetoothGatt(22598): onClientConnectionState() - status=133 clientIf=5 device=8C:AA:B5:A7:62:4A
D/BluetoothManager(22598): getConnectionState()
D/BluetoothManager(22598): getConnectedDevices
D/BluetoothGatt(22598): close()
D/BluetoothGatt(22598): unregisterApp() - mClientIf=5
I/flutter (22598): 2020-12-22T16:37:17.663322	E	new DeviceDetailsBloc.<ac>:	 BleError (Error code: 201, ATT error code: null, iOS error code: null, Android error code: 133, reason: Disconnected from 8C:AA:B5:A7:62:4A with status 133 (GATT_ERROR), internal message: null, device ID: 8C:AA:B5:A7:62:4A, service UUID: null, characteristic UUID: null, descriptor UUID: null)

KrystofM avatar Dec 22 '20 13:12 KrystofM

Okay to is seems RxAndroid lib is doing that when connecting without reflection:

private BluetoothGatt connectGattCompat(BluetoothGattCallback bluetoothGattCallback, BluetoothDevice device, boolean autoConnect) {
        RxBleLog.v("Connecting without reflection");

        if (Build.VERSION.SDK_INT >= 23 /* Build.VERSION_CODES.M */) {
            return device.connectGatt(context, autoConnect, bluetoothGattCallback, TRANSPORT_LE);
        } else {
            return device.connectGatt(context, autoConnect, bluetoothGattCallback);
        }
    }

KrystofM avatar Dec 22 '20 14:12 KrystofM

I had same problem about this issues @KrystofM did you solved this problem ?

JAICHANGPARK avatar Jan 21 '21 04:01 JAICHANGPARK

@JAICHANGPARK , @KrystofM I have the same issue, did you ever solve this?

Mushroomizer avatar Feb 22 '21 15:02 Mushroomizer

@JAICHANGPARK @Mushroomizer We have whitelisted a bunch of Huawei devices, it is a known problem for these devices to be problematic and even big companies like Garmin or Fitbit have them on a whitelist.

KrystofM avatar Feb 26 '21 23:02 KrystofM

Ovearll Status 133 Gatt Error is a pretty generic BLE error and could mean a lot of things. Had some similar problems with some Samsung devices and we had to change the firmware BLE stack on our device to be able to connect to it ( some really mysterious errors and issues come up with androids overall ).

KrystofM avatar Feb 26 '21 23:02 KrystofM

Did somebody solve this bug?

matteotan avatar Jan 21 '22 11:01 matteotan

connection failed gatt status 133

QGB avatar May 27 '23 02:05 QGB

it impossible to solve this problems ,the only way to improve connect success, jus retry ,retry retry .

ManBali avatar Jul 17 '23 09:07 ManBali

please helping me, theres issue the same gat status 133

arbaelbarca avatar Sep 26 '23 16:09 arbaelbarca

Same here.. :/

DevTiago avatar Dec 06 '23 16:12 DevTiago