toit
toit copied to clipboard
Add support for BLE server
Just writing to see if a BLE server implementation is being worked on. Specifically, what I'd like to see is turning the ESP32 into a server that other devices connect to, that creates characteristics and updates their values.
I have taken a look through ble.toit and it looks like some of the primitives are already there.
- [x] Device
- [x] Characteristic
- [ ] Security
- [ ] Server
- [ ] Service
Toit is using the NimBLE implementation, if I'm looking at this correctly?
Yes, you're right. We are using NimBLE. We are not actively working on adding the last parts of the BLE implementation right now (as in the coming week), but we'd love to explore this with you.
For reference, the resources/ble_esp32.cc and event_sources/ble_esp32.cc files contain the implementation of the primitives used by ble.toit.
I've taken the liberty of turning your question into a feature request :)
I'm interested in the platform and am currently writing a few I2C drivers to get familiar with it.
A BLE server isn't on my short list either, but I have found it very useful to have for provisioning and interacting with the device through an app (web BLE maybe since you are already using web serial).
If I start playing around with it and make some progress, I will get in touch here.
Thanks, @justind000!
I am currently giving the ble server/peripheral some attention. The idea is to let the user build a service descriptor with toit objects to be passed to the server constructor. The library would then enable advertising the services. It will contain some sensible defaults for attribute types and allow callbacks to executed in user code when an attribute is written to, enable reading an attribute and provide a default mechanism to handle notifications.
Mikkel's work just landed. Please take a look, @justind000!
With a good chunk of help from @mikkeldamsgaard, the BLE implementation is in a much better shape now. Do you know what we're still missing, @justind000?
How is this looking by now, @mikkeldamsgaard?
Still missing security. The rest is done.
Security finally added in https://github.com/toitlang/toit/pull/1470. @kasperl please update when approved.