PhilipsHue / flutter_reactive_ble

Flutter library that handles BLE operations for multiple devices.
https://developers.meethue.com/
Other
661 stars 321 forks source link

How to connect with duplicate UUID characteristics via flutter_reactive_ble? #844

Closed PYJTERSTM32 closed 6 months ago

PYJTERSTM32 commented 6 months ago

Hello everyone, I have a problem with the flutter_reactive_ble library and I'm not quite sure how to fix an error. Specifically, I have an Ipega-9083S gamepad controller that registers as a GATT HID. I wrote a simple app to practice and display the joystick movements or button presses on the phone. I found the characteristic using BLE SCAN and it presents itself as follows: Status:

Status: CONNECTED, NOT BONDED

    DEVICE INFORMATION
        PRIMARY SERVICE
        Manufacturer Name String (UUID: 0x2A29)
        Firmware Revision String (UUID: 0x2A26)
        PnP ID (UUID: 0x2A50)

    GENERIC ACCESS
        PRIMARY SERVICE
        Device Name (UUID: 0x2A00)
        Appearance (UUID: 0x2A01)
        Peripheral Preferred Connection Parameters (UUID: 0x2A04)

    GENERIC ATTRIBUTE
        PRIMARY SERVICE
        Service Changed (UUID: 0x2A05)

    HUMAN INTERFACE DEVICE
        PRIMARY SERVICE
        Protocol Mode (UUID: 0x2A4E)
        Report (UUID: 0x2A4D)
        Report Map (UUID: 0x2A4B)
        HID Information (UUID: 0x2A4A)
        HID Control Point (UUID: 0x2A4C)

Here are the detailed information for the HUMAN INTERFACE DEVICE (0x1812) PRIMARY SERVICE:

Protocol Mode
        UUID: 00002A4E-0000-1000-8000-00805F9B34FB
        Properties: READ, WRITE NO RESPONSE
        Write Type: WRITE REQUEST

    Report
        UUID: 00002A4D-0000-1000-8000-00805F9B34FB
        Properties: READ, NOTIFY
        Deskryptory:
            Client Characteristic Configuration
                UUID: 00002902-0000-1000-8000-00805F9B34FB
                UKNOWN
                UUID: 00002908-0000-1000-8000-00805F9B34FB
    Report
        UUID: 00002A4D-0000-1000-8000-00805F9B34FB
        Properties: READ, NOTIFY
        Deskryptory:
            Client Characteristic Configuration
                UUID: 00002902-0000-1000-8000-00805F9B34FB
                UKNOWN
                UUID: 00002908-0000-1000-8000-00805F9B34FB

    Report Map
        UUID: 00002A4B-0000-1000-8000-00805F9B34FB
        Properties: READ

    HID Information
        UUID: 00002A4A-0000-1000-8000-00805F9B34FB
        Properties: READ

    HID Control Point
        UUID: 00002A4C-0000-1000-8000-00805F9B34FB
        Properties: WRITE NO RESPONSE
        Write Type: WRITE REQUEST

And as you can see, the characteristic 0x2A4D is displayed twice. After running my code, I get an error on the snackbar:

Subscription error for characteristic: Exception: Multiple matching characteristics found: QualifiedCharacteristic(characteristicId: 00002a4d-0000-1000-8000-00805f9b34fb, serviceId: 00001812-0000-1000-8000-00805f9b34fb, deviceId: 03:34:08:20:58:A8)

flutter_reactive_ble does not currently support an explicit distinction between two characteristics with the same UUID, at least I haven't found anything like that. Can you help me how to approach this problem? I have attached my main.dart project so as not to lengthen this post. Thank you in advance for your help.

main.dart.txt

Taym95 commented 6 months ago

Please read doc on API

https://github.com/PhilipsHue/flutter_reactive_ble/blob/master/packages/flutter_reactive_ble/lib/src/reactive_ble.dart#L165