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 Low-Energy Samples #402

Open
azimuthdeveloper opened this issue Apr 11, 2022 · 5 comments
Open

Bluetooth Low-Energy Samples #402

azimuthdeveloper opened this issue Apr 11, 2022 · 5 comments
Labels
documentation Improvements to documentation / samples

Comments

@azimuthdeveloper
Copy link

Hey,

I saw that BTLE is now part of win32 and that's super exciting. From reading the documentation though, it seems like there isn't an example on how to subscribe to characteristics or equivalent.

Is this possible with the existing implementation, and if so, would you accept a PR with an example that shows how to subscribe to BTLE characteristic notifications? If so, I might need some rough notes on how this works so I can do a sample up.

@timsneath
Copy link
Contributor

Hi there! Thank you for the request. Yes -- you're very welcome to submit an example of this, but I have very little knowledge of implementing Bluetooth LE myself, so unfortunately I can't give you much in the way of pointers.

My focus with this project is projecting the underlying Win32 / COM APIs to Dart, but there are too many different subsystems for me to myself be an expert in all of them. You might look for a C/C++ example that you can port over, whether in the Microsoft documentation or elsewhere. If you submit something that is based on another example, please include a link to the original example in your pull request, and make sure that it's OSS-licensed, so that I can include the relevant acknowledgements in the readme.

@timsneath timsneath added the documentation Improvements to documentation / samples label Apr 20, 2022
@azimuthdeveloper
Copy link
Author

Thanks for that Tim. I think I've found some doco here which I can consult: https://docs.microsoft.com/en-us/samples/microsoft/windows-universal-samples/bluetoothle/

Frustratingly, a lot of links on the page are returning "access denied". But there's still a sample I can reference, which I can try to make work. I think @Sunbreak is trying to implement this as well for his quick_blue package, so I'll keep an eye on that repository as well.

@Sunbreak
Copy link
Contributor

Sunbreak commented Apr 23, 2022

Thanks for that Tim. I think I've found some doco here which I can consult: https://docs.microsoft.com/en-us/samples/microsoft/windows-universal-samples/bluetoothle/

It is an example of UWP APIs of BluetoothLE, which quick_blue uses right now. Windows 1703+ acquired


I have done some examples on win32 APIs of BluetoothLE. But I wouldn't recommand using them

It is quite cumbersome to find nearby BluetoothLE devices via win32 APIs: https://stackoverflow.com/questions/54912411/detecting-ble-device-in-range-on-win32


If you're interesting in handling WM_DEVICECHANGE, take a look at https://github.com/woodemi/quick_device_watcher

Or you could reference Chromium project: https://chromium.googlesource.com/chromium/src/+/HEAD/device/base/device_monitor_win.cc

@azimuthdeveloper
Copy link
Author

So, before this, I was creating a WPF app with BLE functionality but I much prefer using Flutter for the UI and other reasons. The reason why I have begun this journey is because I really want to use (and contribute) to a stable and reliable BLE solution for Flutter because I have a hobby app that uses BLE quite significantly.

So, to that end (and this might not be the best place for these questions, but I'll ask anyway...). These may be really stupid questions so I appreciate the patience. I'm really blazing the trail with Flutter on Windows here because I really want to create desktop apps with native functionality.

  1. When we talk about UWP API's, I take it the are different to win32 API's? So, we can't leverage the BLE UWP API's from this project anyway, because they're not part of the win32 API?
  2. Following on from above, we can technically use win32 for BLE, but it's much more complicated and involved than just using the UWP API's?
  3. If Win32 API's are projectable via this project, does that mean that UWP API's are projectable as well? And, is that something that might happen in the future?

@Sunbreak I currently use quick_blue in my project and it works well, but it crashes occasionally and when it does it doesn't produce usable errors. Android Studio just says "Lost connection to device" and nothing is logged that I could even create a GitHub issue with. I've cloned quick_blue and attached it to the running app but I've not been able to work out why my crash is happening or what to do about it.

Some disclosure: I'm a C#/.NET developer and I understand that C++ is a totally different beast. But I really want to understand it so I can contribute to BLE functionality with Flutter on Windows.

@Sunbreak
Copy link
Contributor

  1. When we talk about UWP API's, I take it the are different to win32 API's? So, we can't leverage the BLE UWP API's from this project anyway, because they're not part of the win32 API?

2. Following on from above, we can technically use win32 for BLE, but it's much more complicated and involved than just using the UWP API's?

  • Technically yes. But not worth. UWP APIs (or WinRT APIs) are much better

3. If Win32 API's are projectable via this project, does that mean that UWP API's are projectable as well? And, is that something that might happen in the future?

@Sunbreak I currently use quick_blue in my project and it works well, but it crashes occasionally and when it does it doesn't produce usable errors. Android Studio just says "Lost connection to device" and nothing is logged that I could even create a GitHub issue with. I've cloned quick_blue and attached it to the running app but I've not been able to work out why my crash is happening or what to do about it.

https://github.com/woodemi/quick_breakpad may help. We'd better open another issue on quick_blue repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements to documentation / samples
Projects
None yet
Development

No branches or pull requests

3 participants