Skip to content
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

fix(NimBLEDevice): clear all before port_deinit to prevent crash #197

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

finger563
Copy link
Contributor

@finger563 finger563 commented Sep 6, 2024

This is an upstream PR matching esp-cpp#3. Relevant info copied below:

Description

Update NimBLEDevice::deinit() to run the clearAll block (if true) before calling nimble_port_deinit()

Motivation and Context

I found that running NimBLEDevice::deinit(true) if I had a client created (as in espp::BleGattServer) would lead to a crash as the ~NimBLEClient() would call ble_npl_callout_deinit(), which would lead to a crash. Moving the clearAll block to before the nimble_port_deinit() call does not result in a crash for the same code.

How has this been tested?

Building and running in a separate project which was crashing before this change.

See example output here: esp-cpp/espp#325

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Small snippet of the coredump:
CleanShot 2024-09-06 at 08 56 36

@h2zero
Copy link
Owner

h2zero commented Sep 15, 2024

Thanks!, LGTM

@h2zero h2zero merged commit 73f0277 into h2zero:master Sep 24, 2024
94 checks passed
@h2zero
Copy link
Owner

h2zero commented Oct 23, 2024

@finger563 Looks like we have a new issue caused by this change, h2zero/NimBLE-Arduino#724.

I may revert this and look for an alternative, thoughts?

h2zero added a commit that referenced this pull request Oct 30, 2024
* General code cleanup
* `NimBLEDevice::getInitialized` renamed to `NimBLEDevice::isInitialized`.
* `NimBLEDevice::setPower` no longer takes the `esp_power_level_t` and `esp_ble_power_type_t`, instead only an integer value in dbm units is accepted.
* `NimBLEDevice::setPower` now returns a bool value, true = success.
* `NimBLEDevice::setMTU` now returns a bool value, true = success.
* `NimBLEDevice::injectConfirmPIN` renamed to `NimBLEDevice::injectConfirmPasskey` to use Bluetooth naming.
* Fixes crash if `NimBLEDevice::deinit` is called when the stack has not been initialized.
* reverts #197 as it would cause a crash if when a NimBLEServer has a connection.
h2zero added a commit that referenced this pull request Oct 30, 2024
* General code cleanup
* `NimBLEDevice::getInitialized` renamed to `NimBLEDevice::isInitialized`.
* `NimBLEDevice::setPower` no longer takes the `esp_power_level_t` and `esp_ble_power_type_t`, instead only an integer value in dbm units is accepted.
* `NimBLEDevice::setPower` now returns a bool value, true = success.
* `NimBLEDevice::setMTU` now returns a bool value, true = success.
* `NimBLEDevice::injectConfirmPIN` renamed to `NimBLEDevice::injectConfirmPasskey` to use Bluetooth naming.
* Fixes crash if `NimBLEDevice::deinit` is called when the stack has not been initialized.
* reverts #197 as it would cause a crash if when a NimBLEServer has a connection.
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

Successfully merging this pull request may close these issues.

2 participants