-
Notifications
You must be signed in to change notification settings - Fork 71
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
[Windows] Unhandled Exception: PlatformException(IllegalArgument, Unknown devicesId: .... , null, null) #136
Comments
You can use prerelease plugin version 0.5.0-dev.2
|
@alevlako Thanks for the fast response!
Have tried this. Unfortunately this does not fix the error... |
@rebeccasc |
I fixed it with some workaround. Maybe it's not the smartest way to solve it but it works for me. First I wrap the code block with an flutter runZonedGuarded so the error can be caught. It turned out that the thrown error cannot be caught by a simple var connectionRetry = 5;
while (connectionRetry > 0 && !(await connectPlatformWindows())) {
// connection failed, try again
connectionRetry--;
}
Future<bool> connectPlatformWindows() async {
var success = true;
await runZonedGuarded(() async {
// run the code ahead ...
QuickBlue.setValueHandler((String deviceId, String characteristicId, Uint8List value) {
// do something with the recevied values
});
QuickBlue.connect(deviceId);
// give quick_blue some time to handle async function
await Future.delayed(const Duration(seconds: 2));
await QuickBlue.setNotifiable(
deviceId,
myUartServiceUUID,
myUartCharacteristicsUUID,
BleInputProperty.notification);
// give quick_blue some time to handle async function
await Future.delayed(const Duration(milliseconds: 250));
}, (e, stack) {
success = false;
});
return success;
} Hope it helps. |
Thanks for reply, |
The plugin behaves like this when there is no bluetooth receiver (dongle) connected to the PC. This is a known issue and it has the fix. |
QuickBlue irregularly throws an exception when calling
This exception does not always occur thats why I assume it's a timing error.
Here's the full code:
What I did trying to fix it:
deviceId
. ThedeviceId
comes from the scan result and stable works forQuickBlue.connect(deviceId);
Is this related to: #93, or #90?
Does anyone have an idea how I can fix/avoid the exception?
Thanks!
The text was updated successfully, but these errors were encountered: