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

Make startScan() async and check BLE availability #9

Merged
merged 3 commits into from
May 7, 2022

Conversation

azimuthdeveloper
Copy link
Contributor

@azimuthdeveloper azimuthdeveloper commented Apr 29, 2022

On Windows, if startScan() is called while the Bluetooth switch is in the "off" state, quick_blue causes a native crash.

This PR first checks that Bluetooth is enabled, and if it is not, returns an error back up to the Flutter system to deal with.

It also changes the implementation of startScan to async. That's because, in my tests, it seems like the error was only caught properly if startScan was made async.

EDIT: Also check if the bluetooth adapter is available before trying to use it. It's possible that the bluetooth object could be null if there was no eligible hardware to be used on the computer.

@Sunbreak
Copy link
Collaborator

There is isBluetoothAvailable. Why check the bluetoothRadio again in startScan?

@azimuthdeveloper
Copy link
Contributor Author

Because if there isn't an available BLE adapter or its turned off on the system, it causes a native crash, which makes the entire app crash. I'm trying to prevent against native crashes for any reason.

Signed-off-by: wangkun <wangkun@woodemi.com>
@Sunbreak
Copy link
Collaborator

Fix async & format

@Sunbreak Sunbreak merged commit 36e496c into woodemi:develop May 7, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants