Skip to content

Android issue with readCharacteristic call #262

@prabudevarrajan

Description

@prabudevarrajan

Error message on readCharacteristic call after changing targetSdkVersion from "30" to "31".

 BluetoothService: Read error: [BluetoothError]:error_function_call, readCharacteristic, [B@260bdf5, {"peripheralUUID":"XX:B4:6A:C9:75:AB","serviceUUID":"fe78","characteristicUUID":"73fdxxx-626c-4f9b-a52e-b1d226efcf8d"}

In Android there are two readCharacteristic() function callback. See the attached image and android documentation

image

So, if we patch onCharacteristicRead call from 3 arguments to 4 arguments (byte: any) the plugin works fine with sdkVersion check

  onCharacteristicRead(gatt: android.bluetooth.BluetoothGatt, characteristic: android.bluetooth.BluetoothGattCharacteristic, byte: any, status: number) {
            this.subDelegates.forEach((d) => {
                if (d.onCharacteristicRead) {
                   if (sdkVersion < 33) {
                    d.onCharacteristicRead(gatt, characteristic, value);
                } else {
                    d.onCharacteristicRead(gatt, characteristic, status);
                }
            });
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions