flutter_blue_plus icon indicating copy to clipboard operation
flutter_blue_plus copied to clipboard

[Feature]: Web Bluetooth Support

Open diegobes opened this issue 2 years ago • 8 comments

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/

diegobes avatar Jan 22 '24 19:01 diegobes

feel free to open a PR!

chipweinberger avatar Jan 22 '24 20:01 chipweinberger

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 avatar Feb 15 '24 22:02 chipweinberger

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.

chipweinberger avatar Apr 27 '24 20:04 chipweinberger

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?

tnc1997 avatar Aug 12 '24 19:08 tnc1997

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

chipweinberger avatar Aug 12 '24 19:08 chipweinberger

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

also, please update the readme. etc.

chipweinberger avatar Aug 12 '24 19:08 chipweinberger

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.

tnc1997 avatar Aug 13 '24 18:08 tnc1997

@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.

chipweinberger avatar Aug 29 '24 07:08 chipweinberger