Open srtonz opened 2 years ago
Grr... That's really infuriating that the Win32 APIs are half-implemented. Why do they have the other BluetoothGatt
functions if you can't find devices? :( The endless Microsoft back-and-forth on preferred APIs keeps bringing the pain.
Unfortunately, the WinRT projection classes are in a very preliminary state. I've been making some progress this weekend, ironically, but I don't yet have event handlers or WinRT generics supported. So yeah, this is not possible without significant future iteration on the projection work.
I would NOT
recommand Dart projection on WinRT
for BluetoothLE for now
Actually you have two options
C++/WinRT
APIs via MethodChannel or dart:ffi
dart:ffi
example on USB: https://github.com/woodemi/quick_usbdart:ffi
example on cronet
: https://github.com/Sunbreak/cronet_flutterSetupAPI
and APIs inside bthledef.h
Related PR: https://github.com/timsneath/win32/pull/392
Thanks both. We already have a working C++/WinRT implementation to use for now, this was really just trying to see how far we can push things into Dart "only". Feel free to ping me here if you need contributions in the future.
@srtonz it's a long shot, but is your implementation open source by any chance? Just getting into the BLE space quite a bit and am having simiilar issues getting BLE to work with Flutter.
@azimuthdeveloper that was the intention originally, but work didn't progress beyond prototyping. At the moment a combination of flutter_reactive_ble
and quick_blue
(for Desktop) is working for us.
@srtonz I did that for a while but I could never get my app to be stable. I ended up writing the entire Windows bit in Rust which has been rock solid. I might do an article or YouTube video on how to do it.
Now that dart-windows/win32#370 has been closed I was hoping to get BLE device discovery and communication going.
Unfortunately the
BluetoothFindFirstDevice
function does not work for BLE devices, and instead it's recommended to use theBluetoothLEAdvertisementWatcher
class for finding nearby BLE devices.I've been able to make some progress toward this (thanks to the Calendar example), but I'm struggling to understand how to add event handlers for
Received
andStopped
events. Running thegenerate.cmd
script with some debug modifications this is the error it's generating:I'd be happy to give this a go, but unsure where to start and whether this is currently possible at all?