Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help]: Issue Enabling Notifications for a Characteristic #675

Closed
1 task done
ellik159 opened this issue Nov 12, 2023 · 1 comment
Closed
1 task done

[Help]: Issue Enabling Notifications for a Characteristic #675

ellik159 opened this issue Nov 12, 2023 · 1 comment
Labels
help Questions, help, observations, or possible bugs

Comments

@ellik159
Copy link

Requirements

  • I've looked at the README 'Common Problems' section

Have you checked this problem on the example app?

No

FlutterBluePlus Version

1.28.7

Flutter Version

3.13.9

What OS?

Android

OS Version

13

Bluetooth Module

Dont know

What is your problem?

The problem occurs when trying to enable notifications for a characteristic. In the example app, it works fine, but in my own app, where I'm using a provider with Riverpod, it doesn't work and I get the following error:

CCCD descriptor for characteristic not found
This is my code.

Future<void> connectToDevice(BluetoothDevice device) async {
    try {
      await device.connect(mtu: null);
      // state = device;
      final services = await device.discoverServices();

      for (var service in services) {
        for (var char in service.characteristics) {
          if (char.uuid.uuid == "0000ffe4-0000-1000-8000-00805f9a34fb") {
            print(char.descriptors);
            char.lastValueStream.listen((event) {
              print(event);
            });
            await char.setNotifyValue(true);
          }
        }
      }
    } catch (e) {
      // Manejar el error
      await device.disconnect(queue: false);
      print('Error al conectar: $e');
      throw Exception();
    }

In prints show like the descriptor exist buy when i try to connect throw this

Logs

I/flutter (24903): [FBP] [[ OnDiscoveredServices ]] result: {error_string: GATT_SUCCESS, success: 1, remote_id: D7:D2:9B:8F:E9:F0, error_code: 0, services: [{included_services: [], characteristics: [{descriptors: [], service_uuid: 1800, remote_id: D7:D2:9B:8F:E9:F0, characteristic_uuid: 2a00, properties: {broadcast: 0, write_without_response: 0, notify_encryption_required: 0, read: 1, authenticated_signed_writes: 0, extended_properties: 0, indicate: 0, indicate_encryption_required: 0, write: 1, notify: 0}}, {descriptors: [], service_uuid: 1800, remote_id: D7:D2:9B:8F:E9:F0, characteristic_uuid: 2a01, properties: {broadcast: 0, write_without_response: 0, notify_encryption_required: 0, read: 1, authenticated_signed_writes: 0, extended_properties: 0, indicate: 0, indicate_encryption_required: 0, write: 0, notify: 0}}, {descriptors: [], service_uuid: 1800, remote_id: D7:D2:9B:8F:E9:F0, characteristic_uuid: 2a04, properties: {broadcast: 0, write_without_response: 0, notify_encryption_required: 0, read: 1, authenti
D/BluetoothGatt(24903): onConnectionUpdated() - Device=D7:D2:9B:8F:E9:F0 interval=24 latency=10 timeout=400 status=0
I/flutter (24903): [BluetoothDescriptor{remoteId: D7:D2:9B:8F:E9:F0, serviceUuid: 0000ffe5-0000-1000-8000-00805f9a34fb, characteristicUuid: 0000ffe4-0000-1000-8000-00805f9a34fb, descriptorUuid: 2902, lastValue: []}]
I/flutter (24903): []
I/flutter (24903): [FBP] <getAdapterState> result: {adapter_state: 4}
I/flutter (24903): [FBP] <setNotifyValue> args: {remote_id: D7:D2:9B:8F:E9:F0, service_uuid: 0000ffe5-0000-1000-8000-00805f9a34fb, secondary_service_uuid: null, characteristic_uuid: 0000ffe4-0000-1000-8000-00805f9a34fb, force_indications: false, enable: true}
D/[FBP-Android](24903): [FBP] onMethodCall: setNotifyValue
D/BluetoothGatt(24903): setCharacteristicNotification() - uuid: 0000ffe4-0000-1000-8000-00805f9a34fb enable: true
W/[FBP-Android](24903): [FBP] CCCD descriptor for characteristic not found: 0000ffe4-0000-1000-8000-00805f9a34fb
I/flutter (24903): [FBP] <setNotifyValue> result: false
@ellik159 ellik159 added the help Questions, help, observations, or possible bugs label Nov 12, 2023
@ellik159
Copy link
Author

Update Fixed , update to new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help Questions, help, observations, or possible bugs
Projects
None yet
Development

No branches or pull requests

1 participant