Closed umuttsaltan closed 1 year ago
try using the example app!
I/flutter (14956): [FBP] <setNotification> args: {remote_id: 84:F7:03:1B:DD:E6, service_uuid: 0000181a-0000-1000-8000-00805f9b34fb, secondary_service_uuid: null, characteristic_uuid: 00002a37-0000-1000-8000-00805f9b34fb, enable: true}
I/flutter (14956): [FBP] <setNotification> result: null
I/flutter (14956): [FBP] [[ OnDescriptorResponse ]] result: {secondary_service_uuid: null, error_string: GATT_SUCCESS, service_uuid: 0000181a-0000-1000-8000-00805f9b34fb, success: 1, remote_id: 84:F7:03:1B:DD:E6, descriptor_uuid: 00002902-0000-1000-8000-00805f9b34fb, error_code: 0, type: 1, characteristic_uuid: 00002a37-0000-1000-8000-00805f9b34fb, value: }
^ these logs are interesting. OnDescriptorResponse
returned success, which means <setNotification>
succeeded, but the value
in the result is empty. I am not sure why that would be. It is supposed to return the new value of the descriptor.
Perhaps your device has bugs!
did you figure it out?
No, i don't know what's the problem. Tried too many things but same error.
Sample function from my code :
void powerChar() async { final powerServiceUuid = Guid("0000181a-0000-1000-8000-00805f9b34fb"); final powerCharacteristicUuid = Guid("7e422156-ab78-11ed-afa1-0242ac120002");
for (var service in servicesList) {
if (service.uuid == powerServiceUuid) {
BluetoothCharacteristic? powerCharacteristic;
for (var characteristic in service.characteristics) {
if (characteristic.uuid == powerCharacteristicUuid) {
powerCharacteristic = characteristic;
break;
}
}
if (powerCharacteristic == null) {
print("Power characteristic not found.");
return;
}
try {
await powerCharacteristic
.setNotifyValue(powerCharacteristic.isNotifying == false);
} catch (e) {
print("Power Char: $e");
}
powerCharacteristic.lastValueStream.listen((power) {
if (power.length == 2) {
int powerdata = (power[0] << 8) + power[1];
dataDeviceController.powerData[currentDeviceIndex!] =
powerdata.toString();
}
});
}
}
}
Am i doing something wrong ?
the problem seems to be your bluetooth device, not your flutter code.
I checked the device, descriptors allows only read. Could this be the problem ? Does package trying to writeDesc when setNotify ? If thats the problem can i fix this, change anything on device software ?
that is a problem. you must change device firmware
did you fix it?
No, my friend works on device firmware. I said the problem, after he change the firmware i'll try it again.
does it work on iOS?
Hello, I am joining this conversation because I have encountered the same error message since I upgraded from version 1.4.0 to version 1.14.23
Before with version 1.4.0 it worked with my BLE device (this is not a problem on the device side) (android, flutter 3.13)
When upgrading to version 1.14.23 the only ones I changed concern the connection (static call, method name etc.)
Thanks for your help
So it turns out there was a bug in FBP.
Android actually deprecated the API we were using, because it made this bug easy to make.
In short, descriptor.getValue()
can only be reliably called after a READ, not a WRITE.
I've fixed this on master branch. please try it: e270e09dc68fee0296b90b6933258b73ca34f6b8
So it turns out there was a bug in FBP.
Android actually deprecated the API we were using, because it made this bug easy to make.
In short,
descriptor.getValue()
can only be reliably called after a READ, not a WRITE.I've fixed this on master branch. please try it: dc08c77
I have updated to 1.14.23, but the error is still reported on Android, but it is normal on iOS.
@brain9520 , you must use master branch
dependencies:
flutter:
sdk: flutter
your_package_name:
git:
url: https://github.com/boskokg/flutter_blue_plus
ref: master
According to what you said, the error is no longer reported, but there are other problems, I will try to solve it myself first, thank you. Then I have another question, that is, flutter_blue_plus does not seem to have duplicate devices when scanning on iOS, but many duplicate Bluetooth devices will appear when scanning on Android. Is there a parameter that can be turned off and set to not repeat scanning.
but there are other problems
what problems?
Then I have another question, that is, flutter_blue_plus does not seem to have duplicate devices when scanning on iOS, but many duplicate Bluetooth devices will appear when scanning on Android. Is there a parameter that can be turned off and set to not repeat scanning.
please file a separate issue, with logs & screenshots
@brain9520 that issue not not related to notifications, and should not be in this thread. please file seperate issue
fixed in 1.14.24
I also found this problem. My problem is caused by setting mtu. When setting setNotifyValue, I have to wait for mtu setting to complete before using it
FlutterBluePlus Version
1.14.11
Flutter Version
3.10.6
What OS?
Android
OS Version
Android 11
What happened?
I'm using setNotifyValue when im getting data from BLE device. When i set this value i get some errors.
try{ await buttonCharacteristic.setNotifyValue(true); } catch(e){ print("ButtonChar $e"); }
I used this like that for an exception and im getting these errors :
Logs