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

[0.13.0] "UniversalBle.connect" seems to be fully broken for iOS? #92

Open
AlexDochioiu opened this issue Oct 19, 2024 · 9 comments
Open

Comments

@AlexDochioiu
Copy link

I tried to upgrade universal_ble for our package from version 0.12.0 to 0.13.0 and it seems that connect just does not work anymore. Behaviour observations:

[0.12.0][iOS] Calling await for UniversalBle.connect causes it to hang and not complete.
[0.12.0][iOS] Calling UniversalBle.connect without awaiting seems to work perfectly fine (When connection completes, I get notified via the listener added to UniversalBle.onConnectionChange)

[0.13.0][iOS] Calling await for UniversalBle.connect causes it to hang and not complete.
[0.13.0][iOS] Calling UniversalBle.connect without awaiting seems to still not work, unlike 0.12.0. UniversalBle.onConnectionChange never gets invoked.

@rohitsangwan01
Copy link
Contributor

@AlexDochioiu now connect will either complete or throw error if failed to connect, can you please cross check

@AlexDochioiu
Copy link
Author

@rohitsangwan01 On version 0.13.0? It just seems to always fail to connect and time out with error along the lines of:

PlatformException(IllegalArgument, Unknown deviceId: DE:F1:2C:9F:41:60, null, null)

@fotiDim
Copy link
Contributor

fotiDim commented Oct 28, 2024

@AlexDochioiu can you try the example app and verify that it works? Can you also cross-check with another type of peripheral?

@AlexDochioiu
Copy link
Author

I will do that. But, for context. The exact same device (and device type) works consistently on 0.12.0 and never works on 0.13.0.

@fotiDim
Copy link
Contributor

fotiDim commented Oct 28, 2024

0.13 was a big release. We did plenty of changes but we are also actively using it with multiple hardware configurations and didn't face any issue. Let's try to narrow it down and see where the problem lies.

@rohitsangwan01
Copy link
Contributor

@AlexDochioiu in your code, now you don't have to handle all the complexity of waiting for the connection from callbacks here

Now all this is handled within UniversalBle and you can just call connect api and await for the completion

try {
  print("Connecting");
  await UniversalBle.connect(
    deviceId,
    connectionTimeout: const Duration(seconds: 5),
  );
  print("Connected successfully");
} catch (e) {
  print("Connection Failed with error: $e");
}

@AlexDochioiu
Copy link
Author

Sorry for being slow to reply. I tried that and it did not work for me. I believe the await to connect was always failing with platform error: unknown device id for some reason. I'll need to update again to 0.13 to double check since it's been a while and my memory is a bit foggy.

@rohitsangwan01
Copy link
Contributor

@AlexDochioiu To avoid this error unknown device id , you need to perform a scan before attempting a connection. Only after scanning can you interact with the device. This applies to previous versions as well.

@AlexDochioiu
Copy link
Author

@rohitsangwan01 I am performing a scan. That's how I get the device id in the first place. It's not hard coded/etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants