Closed enseitankad0 closed 7 months ago
I recommend you use your app like a normal user to determine which errors occur
then catch them and add nicer messages
most exceptions should never occur in normal usage
I dont have a comprehensive list of errors because iOS and Android do not provide a full list of errors
but you can look online to try and find it. maybe there are some resources online
for example, here is the documentation for connect
on iOS
https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/connect(_:options:)
notice: they do not list the errors that can be thrown
Thank you for quick reply. Basically I'm migrating my project from Flutter Reactive Ble to FBP. Previously I could just read excpection's message and based on it I could determine e.g., wrong pairing (bonding) issue, if exception contains "Writing is not permitted"
.
Based on that, I could tell user to go to settings and to remove pairing manually. It was necessary because sometimes w/o this step, I couldn't reconnect to the device after the update on Nordic chip was performed.
The problem is, if I would receive the same effect I should check all possibilities (for Android and iOS) and based on that, return appropriate error.
yes.
you do do the same thing with FBP
i dont understand the problem.
So for this specific error I've mentioned, should I check whether
e is FlutterBluePlusException
+
apple-code: 3 | Writing is not permitted.
or android-code: 3 | GATT_WRITE_NOT_PERMITTED
, and based on that, create my custom error?
Or the check should be done based on:
e is PlatformException && e.code == 'writeCharacteristic
?
up to you.
id probably check for e.function == 'writeCharacteristic
and e.code == 3
Requirements
Have you checked this problem on the example app?
Yes
FlutterBluePlus Version
1.31.19
Flutter Version
3.16.0
What OS?
macOS
OS Version
14.1.1
Bluetooth Module
Norfic NRF52840
What is your problem?
I want to catch all exception and map them into a well defined classes. E.g
If I'm connecting to device id which does not exist I can check for:
and based on those rules I can return
DeviceNotFoundError
I can also check platform and code of FlutterBluePlusException
and base on it determine InsufficientEncryptionError
Question:
Logs