aioble init/connection reliability on RP2040 #13254
Unanswered
lievenleroy
asked this question in
RP2040 / Pico
Replies: 1 comment
-
For (1) see my response here to your other thread https://github.com/orgs/micropython/discussions/13326#discussioncomment-8042850 I have a Nano Connect here somewhere, I might need to try and repro this myself. For (2) I don't know much about the Arduino IDE, but is it doing a soft reset when running your code? One workaround would be to add import aioble
aioble.stop() somewhere in your program startup. This will force an HCI reset of the BLE controller on the next command (e.g. registering services). |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running a lightly modified version of the temp server example. on an Arduino Nano RP 2040 Connect.
My device shows up on nRF Connect, and I get regular updates from it. However, a number of things can happen which are only resolved by a reset of the device.
(1) If I connect from nRF, then close my phone and come back later, nRF shows itself as no longer connected. If I then scan for devices, my device is not found. From my debug, I believe
aioble.advertise()
is waiting to hear an explicit disconnect from the client, since the advertising task is structured as:No such disconnect occurs in this case. So the device never starts advertising again, and cannot be found by a client (until I reset the device).
Is there a way to e.g. set an activity timeout, in addition to waiting for an explicit disconnect?
(2) Often when I stop and restart my code (running in the Arduino Lab IDE), the call to
aioble.register_services()
during initialization fails.(The referenced line 325 is simply:
aioble.register_services(service)
, and works fine on every first run. The service setup is the same as the temp sensor example, except that I have a write characteristic as well.)Nothing except a cold start seems to fix this. From working with ublupy on the Nano 33 BLE (and docs in the ubluetooth lib), there was a warning to stop advertising before reinitializing, so I've tried adding an explicit
aioble.advertise(0, ...)
before callingregister_services()
, guessing that would cause a stop. But it didn't help.My suspicion is there's some persistent state in the BLE chip itself (so it is still initialized from the last time I ran my code, and the next run finds it in this state and something goes wrong during init). Is there an explicit reset option to clear the BLE state?
More broadly, is there an example of a robust catch-all-such-issues implementation? I appreciated the simple examples to get an aioble implementation running. But I could also use an example I can run for days and will reset itself cleanly if something goes wrong.
Beta Was this translation helpful? Give feedback.
All reactions