Inconsistent behavior between IDEs when stopping and restarting a program #13728
brianreinhold
started this conversation in
General
Replies: 1 comment 3 replies
-
I don't use Thonny so I'm not sure if the issue, but I do know it does run a bunch of "custom" commands on the board to set up its integration. One of those commands might be changing the "current directory" on the device, which would then change where aioble stores / loads the bond data. Before you start BLE at all, you can run:
Then continue to run all your other code the same. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a program which uses Bluetooth on the PICO-W. I have two IDEs, Thonny and VS Code using the Micropico extension. When I power cycle the PICO-W and start the application in either Thonny or VS Code, I can see the Bluetooth stack (port uses btstack) initializes and that IRKs and other keys are properly generated (for any eventual bondings). I can bond with devices (pairing and bonding) and reconnect (encrypt) properly. If I stop the application in VS Code and then restart it (no power cycle) I can continue to to pair with new devices and properly reconnect to those devices I have paired with. However, on Thonny if I stop the application and restart it, I can no longer pair/bond or reconnect. (No problem with unpairable devices however.) I can see in the Thonny case that it tries to re-initialize bluetooth, but it fails to properly setup the pairing and IRK keys.
I am confused as to this behavior. I also have a similar project which after a power cycle in BOTH Thonny and VS Code, the Bluetooth initializes in the same manner as the Thonny application restart and pairing/bonding does not work.
Is the problem incorrect initialization of the Bluetooth? I do the following at the start of the Bluetooth task:
Does this have to be done at a specific time during app spinup? ( I am using the aioble library as source*.) Is there a limit to the nesting of directories? (I am more concerned about understanding the case where the Bluetooth does not come up correctly - pairing doesnt work but everything else does so with non pairable devices no problem.)
Am I missing something in my shutdown of the task(s) upon program exit? I have two approaches, one where I signal the task to cleanup itself before terminating and another one where I do a simple
bt_task.cancel()
. It makes no difference in the behavior.I cannot find much information about the details of Bluetooth startup and shutdown and how that relates to restarting a program without a power cycle. Perhaps Micropython programs are not supposed to be restarted without a power cycle?
Any insight would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions