-
Notifications
You must be signed in to change notification settings - Fork 178
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
Add ble gatt server #247
Add ble gatt server #247
Conversation
Added IDF 5.0 changes.
7db231f
to
0c46856
Compare
@svenstaro Asked me to summarize what still needs to be done in this PR, so here it comes: In a nutshell, the following 4 things should be addressed:
Now, I get it that it is a lot of work, but: |
Answering part of question B: I’m the author of the original library, and even if I had more development plans for it (new features and an architectural refactoring), unfortunately I don’t have time to maintain it due to some academic projects going on right now. Code quality is extremely low in most parts of that crate, as it was my first Rust project, and I agree that a full refactoring might be necessary, and I don’t know whether it would be even worth it before creating a solid high-level API (or trait set). |
@persello Thanks for reaching out. Well, we do not necessarily need trait-based APIs (ala Also, you might be underestimating the quality of your code. I still believe that the changes I'm suggesting above might be a good (enough) set to get something merged. But they are also a requirement, i.e. I'm not willing to merge anything without this minimal cleanup. So I guess until/if somebody is willing to implement these changes, and commit some support behind this driver, this PR will rot. :) |
We'll set someone to clean this up soon. Just gotta make a delivery first. :) |
@svenstaro Any luck finding some time to work on this? |
As per Matrix, we're currently out of capacity due to problems outside our control - We'll schedule someone onto this ASAP. |
8a8adba
to
5ccb542
Compare
Some updates: I've only invested an hour or so, mainly in re-assembling the event callbacks which were scattered in many files, as well as moving some minor stuff from using type alises in The thing is the following: getting rid of the These seem to come from the fact that the Bluedroid stack seems to spin its own event loop in a separate thread and user gets events via a user-provided callback on that separate thread (need to confirm this hypothesis but seems very likely). While So that's one big change. The other is that I'm not sure that splitting the giant gatt server event callback into sub-functions of Once we have this in place, we can think about exposing more convenient API on top of the callback based one. An async API would be an obvious choice as this is the way to linearise in Rust a callback hell into something which uses regular control flow. Especially appealing if I find a way to schedule a piece of work (delayed execution) on the Bluedroid event thread. Usually, libraries which spin their own event loop (Matter C++ SDK; gstreamer / glib and so on) provide such facilities. It would be quite a blow if Bluedroid doesn't. That - in turn - would allow the implementation of a very trivial async executor that lives on the Bluedroid thread and would be the natural choice to run async work on that thread. And sync can be further layered on top of async somehow too maybe. With all of the above said, I can't help but give BIG kudos to @persello for properly documenting the code and properly instrumenting it - thanks so much! A joy to read and comprehend! |
Hmm, on a second thought, integrating a custom async executor into the event loop of Bluedroid might be more difficult than I thought. I was thinking of |
Yeah. Integrating async with the Bluedroid event loop won't be so easy. The rest of the simplifications still apply though, I think. |
@pyaillet got a much terser code by giving up (I think) on associating the Rust structures for The other thing I noticed is that it is apparently OK to call Bluedroid functions on the main thread. It is just that you receive event callbacks in another thread. |
Closing in favor of #290 If you guys want to work on adding BLE support, please work on the currently commented out module |
I recently came across bluedroid GATT server implementation, which was done by @persello, and I believe it is a solid foundation for future improvements. With your permission, we would like to integrate the code with esp-idf-svc to make it more accessible to the wider community. This would enable more people to contribute to the project and help it evolve over time.
#55