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

Bluetooth #57

Closed
flutter-painter opened this issue Jun 30, 2020 · 13 comments · Fixed by #190
Closed

Bluetooth #57

flutter-painter opened this issue Jun 30, 2020 · 13 comments · Fixed by #190
Labels
enhancement New feature or request help wanted Good candidate for others to work on

Comments

@flutter-painter
Copy link

Thank you so much for sharing this repo :)

I would like to provide thermal printing using bluetooth for a Flutter desktop app used on windows.
It seems this could be achieved using the win32 API calls mentioned :

Once implemented, it could also lead to a dedicated bluetooth repo similar to your filepicker_windows.

@timsneath timsneath added the help wanted Good candidate for others to work on label Jul 2, 2020
@timsneath
Copy link
Contributor

I'd be happy to work on this with you. Would you be interested in collaborating a little?

There are a lot of Bluetooth APIs provided by Windows, so it would be helpful to know which ones provide the base functionality you need, and then we can always extend this. It might also be good to connect with someone like @pauldemarco who has written a high-level Flutter API with flutter_blue and add a Windows implementation that depends on my win32 repo for the low-level APIs.

@flutter-painter
Copy link
Author

Thanks for your quick reply !
I also looked after at flutter_blue and indeed noticed they had already opened issues for mac and windows.

Starting next week I'll be happy to dive into this.
I'll revert after more reading and a selection of key bluetooth APIs.

@timsneath
Copy link
Contributor

Sounds good. I've started work on this here: https://github.com/timsneath/win32/tree/bluetooth

@pauldemarco
Copy link

Great stuff. I’d love to help in any way I can. Perhaps it’s time to convert flutter_blue into a Federated plugin. @timsneath do you happen to know if the federated plugin framework is stable?

@timsneath
Copy link
Contributor

Yes, the federated plugin model itself is stable. There may be minor changes to the plugin APIs for Windows and Linux themselves, but you should feel confident to migrate the overall plugin across.

@timsneath
Copy link
Contributor

@926 I checked in some initial support for Bluetooth device discovery with win32 1.6.7. See https://github.com/timsneath/win32/blob/master/lib/src/bthprops.dart and https://github.com/timsneath/win32/blob/master/example/bluetooth.dart.

One slight challenge is that I don't have a modern Windows laptop (I'm doing my development from a Macbook connected to a cloud instance of Windows at present), so testing is a little problematic. I'm going to see what I can lay my hands on.

@flutter-painter
Copy link
Author

Hi, @timsneath, thanks for this, and sorry for the delay, I've had more work than planned,
I borrowed a pc to test device discovery,
if needed I can run queries

@timsneath
Copy link
Contributor

timsneath commented Jul 15, 2020 via email

@flutter-painter
Copy link
Author

Hi Tim,
Please excuse me but I will have no time to advance on this, work caught up.
Ambition was to combine bluetooth with thermal printing using : https://github.com/kakzaki/blue_thermal_printer
There are a bunch of use cases, such as Point of Sale apps, that will find it super handy.

@timsneath
Copy link
Contributor

No problem. If there's someone else out there who wants Bluetooth on Windows from Flutter/Dart, I'm more than happy to collaborate on the Win32 API side of the house /cc @pauldemarco who may have some ideas on community contributors.

@timsneath timsneath added the enhancement New feature or request label Nov 23, 2020
@Sunbreak
Copy link
Contributor

Sunbreak commented Jan 7, 2021

I'd like to help. But I'm only familiar with BluetoothLE: https://github.com/woodemi/quick_blue

Any document for thermal printing on Win7?

@catchkvs
Copy link

catchkvs commented Apr 3, 2021

@timsneath I also have usecase for bluetooth on windows. I was trying the example
https://github.com/timsneath/win32/blob/main/example/bluetooth.dart
But i am not able to discover any bluetooth devices. I am not getting error.

In the above example https://github.com/timsneath/win32/blob/main/example/bluetooth.dart#L16
no sure why btRadioHandle is not being used anywhere?

@timsneath
Copy link
Contributor

Hi @catchkvs, there were some limitations with the FFI support in Dart 2.12 which made it hard to fully implement Bluetooth support. As a result, this sample doesn't work on the current stable release of Flutter or Dart. (That's why it wasn't listed in the README.)

Dart 2.13 will add support for packed structs and arrays, which makes this possible. I've updated the example accordingly, and now for example, on my machine it returns the following:

[C:\src\win32] dart example\bluetooth.dart
Found a radio with handle: 0x00000204
Radio name: TIM-SURFACE
Radio address: 03:55:55:8E:34:C8
Bluetooth radio is discoverable.
No devices found.

You'll need the dart2.13 branch of this package, along with the latest dev or master branch of Flutter or Dart, to be able to execute this sample, but you'll find the updated version here:
https://github.com/timsneath/win32/blob/dart2.13/example/bluetooth.dart

Until it's released, you can use this version of the package from your code by adding a dependency directly to the git reference, like this:

dependencies:
  win32:
    git: 
      url: https://github.com/timsneath/win32.git
      ref: dart2.13

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Good candidate for others to work on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants