Skip to content

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

Open
mvandeg-git opened this issue Nov 2, 2022 · 3 comments
Open

Comments

@mvandeg-git
Copy link

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.

@dominsch
Copy link
Contributor

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.

@mvandeg-git
Copy link
Author

mvandeg-git commented Nov 18, 2022 via email

@dominsch
Copy link
Contributor

This is the end() function:

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants