Commit 855ea36
committed
pbio/drv/bluetooth: Full overhaul.
This moves the remaining functionality of pbsys/bluetooth to pbdrv/bluetooth to be consistent with the USB drivers. This way, bluetooth and usb don't have to depend on the system status and runtime. This drops one level of abstraction, so that printing with stdout no longer goes through two cascaded processess/
This replaces scheduling arbitrary Bluetooth tasks with dedicated scheduling of stdout/status/peripheral/scan task categories. This allows all categories to be simultaneously scheduled, while also immediately copying configuration data and raising if a conflicting operation is already in progress.
For example, you can now set the remote bluetooth light or broadcasting data without clashes. When the operation is available for scheduling, data is copied right away so we avoid issues with using MicroPython data after free, simplifying the module code.
The pbio_task queue is replaced with a single loop that will go over the above task categories and execute it if something was scheduled. This also gives us deterministic control over the order of operations.
Procedures such as ascan and connect and disconnect are now also awaitable, so a dedicated connect() method could now be added trivially.
Throughput of stdout is improved slightly for short messages as there is no longer a double-buffer in pbsys that would block if a send operation was already queued. Data can now be queued whenever there is room in the buffer, and the main Bluetooth process will drain as much as it can the next time it gets around the loop of Bluetooth tasks.
While we are doing all this, replace the Contiki protothreads with pbio/os protothreads.1 parent 204f5cb commit 855ea36
30 files changed
Lines changed: 2299 additions & 2944 deletions
File tree
- bricks/_common
- lib/pbio
- drv
- bluetooth
- include
- pbdrv
- pbio
- src
- sys
- test
- drv
- src
- sys
- pybricks
- common
- iodevices
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
126 | 127 | | |
127 | | - | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | 232 | | |
234 | 233 | | |
235 | 234 | | |
236 | 235 | | |
237 | | - | |
238 | 236 | | |
239 | 237 | | |
240 | 238 | | |
| |||
0 commit comments