boskokg / flutter_blue_plus

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

[Help]: setNotityValue(true) error #781

Closed roger66 closed 5 months ago

roger66 commented 5 months ago

Requirements

Have you checked this problem on the example app?

No

FlutterBluePlus Version

1.31.12

Flutter Version

3.16.9

What OS?

Android

OS Version

10

Bluetooth Module

unknown

What is your problem?

setNotifyValue return GATT_WRITE_NOT_PERMITTED,but FBP1.1.3 is success

Logs

D/[FBP-Android]( 6078): [FBP] onMethodCall: setNotifyValue
D/BluetoothGatt( 6078): setCharacteristicNotification() - uuid: b044efa0-71ed-11ec-a494-020017000b7b enable: true
E/[FBP-Android]( 6078): [FBP] onDescriptorWrite:
E/[FBP-Android]( 6078): [FBP]   chr: b044efa0-71ed-11ec-a494-020017000b7b
E/[FBP-Android]( 6078): [FBP]   desc: 2902
E/[FBP-Android]( 6078): [FBP]   status: GATT_WRITE_NOT_PERMITTED (3)
E/flutter ( 6078): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FlutterBluePlusException | setNotifyValue | android-code: 3 | GATT_WRITE_NOT_PERMITTED
E/flutter ( 6078): #0      BluetoothCharacteristic.setNotifyValue (package:flutter_blue_plus/src/bluetooth_characteristic.dart:280:11)
roger66 commented 5 months ago

peripheral's descriptor only have PERMISSION_READ,use FBP1.13 no problem

chipweinberger commented 5 months ago

If you want the same behavior as 1.1.3, you can just ignore the error.

FBP 1.1.3 did not check for errors. It had no error handling support.

It's possible your WRITE is working despite the error. Or it's possible its not working and you just never noticed. Only the ble device knowns for sure if it worked or not.

roger66 commented 5 months ago

After ignoring,Does onValueReceived work?

chipweinberger commented 5 months ago

depends on your device!

roger66 commented 5 months ago

Is it the same if I don't call setNotifyValue?

chipweinberger commented 5 months ago

not the same. the request is sent if you call setNotifyValue

  1. request sent
  2. device responds with error
roger66 commented 5 months ago

If I ignore the setNofityValue error

roger66 commented 5 months ago

E/flutter (31546): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FlutterBluePlusException | writeCharacteristic | android-code: 133 | UNKNOWN_GATT_ERROR (133) E/flutter (31546): #0 BluetoothCharacteristic.write (package:flutter_blue_plus/src/bluetooth_characteristic.dart:215:9) E/flutter (31546): E/flutter (31546): #1 BleUtils._subpackageSend (package:test_ble/ble_utils.dart:204:5) E/flutter (31546): E/flutter (31546):

roger66 commented 5 months ago

writeCharacteristic not work

roger66 commented 5 months ago

Before I call setNotifyValue,writeCharacteristic can work

chipweinberger commented 5 months ago

you should be looking at the logs on your device. these are GATT errors. i.e. device errors.