chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
785 stars 475 forks source link

[Feature]: Web Bluetooth Support #769

Open diegobes opened 10 months ago

diegobes commented 10 months ago

FlutterBluePlus Version

all

Flutter Version

all

What OS?

All

OS Version

Supported Chrome

Bluetooth Module

any

What is your feature request?

With Chrome ( behind flag ) supporting Web Bluetooth standard, This can be a great addition for Flutter Web Development.

If anyone is interested please let me know

Logs

Chrome Web BLE support:
https://developer.chrome.com/docs/capabilities/bluetooth?hl=en

Web Bluetooth W3C Spec:
https://webbluetoothcg.github.io/web-bluetooth/
chipweinberger commented 10 months ago

feel free to open a PR!

chipweinberger commented 9 months ago

Just some thoughts. To keep all the platform code similar, we should simulate the API of a platform channel, even though we don't actually need one.

in _invokeMethod

if (Platform.isWeb) {
    out = await FlutterBluePlusWeb.invokeMethod(method, arguments);
} else {
    out = await _methodChannel.invokeMethod(method, arguments);
}

in _initFlutterBluePlus

if (Platform.isWeb) {
    FlutterBluePlusWeb.setMethodCallHandler(_methodCallHandler);
} else {
    _methodChannel.setMethodCallHandler(_methodCallHandler);
}
chipweinberger commented 7 months ago

I've started on web support: https://github.com/boskokg/flutter_blue_plus/compare/master...feature/web-bluetooth-support

I implemented startScan. It should be pretty straightforward to implement the rest, if someone wants to.

tnc1997 commented 3 months ago

I implemented startScan. It should be pretty straightforward to implement the rest, if someone wants to.

Hi @chipweinberger, thank you for your work on this package!

I hope you don't mind, I have implemented the web platform, based on your initial branch.

What is the recommended approach for testing the web implementation?

chipweinberger commented 3 months ago

thats awesome. No recommended approach. Just try to test everything :)

chipweinberger commented 3 months ago

your code looks good. I think stopScan should be a no-op, not unsupported.

also, please update the readme. etc.

tnc1997 commented 3 months ago

your code looks good. I think stopScan should be a no-op, not unsupported.

also, please update the readme. etc.

Thank you for your feedback, I have refactored stopScan to be a no-op, and also updated the readme.

chipweinberger commented 2 months ago

@tnc1997 recently created a PR for Web: https://github.com/chipweinberger/flutter_blue_plus/pull/964

However, FBP plans to remain Android/iOS/Mac only for the foreseeable future.

If you'd like to add web support, please do it via wrapper (example: https://pub.dev/packages/flutter_blue_plus_windows).

I'll keep this issue open until someone creates a wrapper for Web.

tnc1997 commented 1 week ago

An in development fork of Flutter Blue Plus that supports web using a platform interface is available here.

Please note that this unofficial fork is not endorsed by Chip Weinberger and is supported on a best efforts basis.

I would like to thank Chip Weinberger for their ongoing work on the existing Android/iOS/macOS package.