Commit 040e398
committed
pbio/drv/bluetooth_btstack: Make peripheral scan/connect robust.
This replaces the state machine logic of the scan and connect task with placing logic synchronously in a protothread. At every stage, we can detect, report and return errors, and handle cancellation correctly.
This fixes a longstanding issue where the Xbox Controller would sometimes not pair to a SPIKE Prime Hub, even though a second attempt usually worked. Now we can catch the return codes from the security manager and re-try pairing within the task, or retry the whole task a second time. We also allow re-encryption now rather than disconnecting when this is attempted.
Extensive USB logging is added to catch issues and flow of the connection process.1 parent 3f714f5 commit 040e398
File tree
5 files changed
+335
-216
lines changed- lib/pbio
- drv/bluetooth
- src
- pybricks/iodevices
5 files changed
+335
-216
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
| |||
311 | 316 | | |
312 | 317 | | |
313 | 318 | | |
| 319 | + | |
314 | 320 | | |
315 | 321 | | |
316 | 322 | | |
| |||
645 | 651 | | |
646 | 652 | | |
647 | 653 | | |
| 654 | + | |
648 | 655 | | |
649 | 656 | | |
650 | 657 | | |
| |||
0 commit comments