chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
791 stars 479 forks source link

[Help]: Not able to write to the bluetooth device in Xiaomi phone #723

Closed huubao2309 closed 11 months ago

huubao2309 commented 11 months ago

Requirements

Have you checked this problem on the example app?

Yes

FlutterBluePlus Version

1.30.3

Flutter Version

3.13.9

What OS?

Android

OS Version

Android 12

Bluetooth Module

LoRa Wireless Stick Lite V3 /433/470-510/863/868-915/928 Hz ESP32 Lora Development Board SX1276 ESP32-PICO-D4 Esp32

What is your problem?

Not able to write to the Bluetooth device in Xiaomi phone (Redmi Note 11) Note: On iOS, the problem does not occur.

Logs

FlutterBluePlusException | writeCharacteristic | android-code: 19 | UNKNOWN_GATT_ERROR (19)

Code

    final List<BluetoothService> services = await device.discoverServices();
    for (final BluetoothService service in services) {
      // Reads all characteristics
      final List<BluetoothCharacteristic> characteristics =
          service.characteristics;
      for (final BluetoothCharacteristic c in characteristics) {
        if (c.properties.write) {
          // Writes to a characteristic
          await c.write(data); // <--- Cannot write value
        }
      }
    }
chipweinberger commented 11 months ago

what is the characteristic uuid causing the error?

ios automatically hides some of the system characteristics

chipweinberger commented 11 months ago

closing due to inactivity. cannot help you without more details.