-
Notifications
You must be signed in to change notification settings - Fork 216
esp32 resets to bootloader when calling BLE.end() before BLE.begin() #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you provide a use case where you would need to call end() before begin()? If used correctly it doesn't reset the device if that is your concern. |
Hi Dominsch,
Thanks for your reply.
Perhaps I am interpreting some functionality incorrectly.
I envisioned a scenario like this:
BLE setup with BLE.begin()
Regular activity
Something goes wrong or user (soft) resets device
BLE needs to be reset: BLE.end()
I had BLE.end() in an init state function to start with a clean slate
regardless of previous initialization.
Since there is (as far as I could find) no way to determine the BLE status
after BLE.begin(), this was a bit of an ugly hack.
I've solved it now by maintaining a status variable.
I mostly filed this, because it was surprising behavior to me that the
whole device was reset (in the ESP32 case).
I hope this helps a bit.
Best,
Martijn
…On Thu, Nov 17, 2022 at 12:03 PM dominsch ***@***.***> wrote:
Can you provide a use case where you would need to call end() before
begin()? If used correctly it doesn't reset the device if that is your
concern.
—
Reply to this email directly, view it on GitHub
<#273 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUI4NLGZBHGVRBDTDG7AH7DWIYGH3ANCNFSM6AAAAAARVBLQLE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This is the void HCIVirtualTransportClass::end()
{
vStreamBufferDelete(rec_buffer);
vStreamBufferDelete(send_buffer);
esp_bt_controller_disable();
esp_bt_controller_deinit();
vTaskDelete(bleHandle);
} If you call it before begin it is trying to delete things that haven't been created yet and your program will crash. All memory is freed after a reset so no need to clean up manually. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for adding ESP32 support! There seems to be one quirk: When calling BLE.end() before BLE.begin(), the whole device resets and starts the bootloader. Tested on a Beetle-ESP2-C3 from DF-Robot.
On an Arduino this does not seem to cause any issues and BLE gets reset (when BLE.begin() had been called before)/or nothing noticeable happens (when BLE.begin()).
I do not know if BLE.end() also resets the device when BLE.end() is called after BLE.begin(), since I loose the USB Serial connection after BLE has been initialized.
Thanks for looking into this.
The text was updated successfully, but these errors were encountered: