Gatt 133 exception on read characteristic and followed by gatt 22
Asked Answered
D

0

4

Problem:

  • I am getting a GATT exception 133 when trying to read the characteristics.

  • I made a delay to read but unfortunately it doesn't works followed by the GATT 22 error.

  • It happens on few devices but i don't know how to solve this problem.

Code:

public void performRead() {
    printMessage("\nperform READ started...");
    UUID serviceuid = UUID.fromString(UUID_SERVICE);
    if (BDA.getmBluetoothGatt() == null)
        return;

    BluetoothGattService service = BDA.getmBluetoothGatt().getService(
            serviceuid);
    UUID characteristicuid = UUID.fromString(UUID_CHARACTERISTIC_STATUS);
    BluetoothGattCharacteristic characteristic = null;
    if (service != null) {
        characteristic = service.getCharacteristic(characteristicuid);
    }
    if (characteristic != null) {
        boolean isSuccess = BDA.getmBluetoothGatt().readCharacteristic(characteristic);
        printMessage("isSuccess fire = " + isSuccess);
    }
}

Callback:

  @Override
    public void onCharacteristicRead(BluetoothGatt gatt,
                                     BluetoothGattCharacteristic characteristic, int status) {
        super.onCharacteristicRead(gatt, characteristic, status);
        String intentAction = "";

        if (status == BluetoothGatt.GATT_SUCCESS) {
            intentAction = MyUtils.ACTION_READ_SUCCESS;
            broadcastNotifyUpdate(characteristic,intentAction);
        } else {//**status - 133
            intentAction = MyUtils.ACTION_GATT_CHARACTERISTIC_ERROR;
            broadcastUpdate(intentAction,""+status);
        }
    }
Dray answered 1/12, 2017 at 15:21 Comment(4)
BLE device will renew the connection, at a particular interval. So there is a chance that connection renews packet is having the problem. You can try to avoid all delay after successful connection. Check the timing (connect to read characteristic) of working and non-working device.Baiel
@Baiel thanks for the reply.But i don't have any delay after successful connection.I have a delay before connect GATT after that i don't have any delay. Not sure why i get the gatt 133 on readcharacteristics followed by 22 connection state exceptionDray
I am also getting same error on Android7.0 on Nokia 2 , it disconnects just after 30 seconds after data trnasferSlattern
I solved the problem by making the connection again . On gatt callback when u get 133 errror try to connect gatt again if you get gatt error again then no option u have to disconnect the gatt and then need to discover services.Dray

© 2022 - 2024 — McMap. All rights reserved.