mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-21 20:50:55 +01:00
NimBLEAdvertising::reset check if the stack is initialized before stop.
This prevents an exception when initializing a NimBLEAdvertising instance before calling NimBLEDevice::init(). The constructor calls reset() which calls stop(), if the stack was not yet initialized it will cause an exception.
This commit is contained in:
parent
dff5122ce2
commit
28d6492ea4
1 changed files with 3 additions and 1 deletions
|
@ -41,7 +41,9 @@ NimBLEAdvertising::NimBLEAdvertising() {
|
|||
* @brief Stops the current advertising and resets the advertising data to the default values.
|
||||
*/
|
||||
void NimBLEAdvertising::reset() {
|
||||
stop();
|
||||
if(NimBLEDevice::getInitialized() && isAdvertising()) {
|
||||
stop();
|
||||
}
|
||||
memset(&m_advData, 0, sizeof m_advData);
|
||||
memset(&m_scanData, 0, sizeof m_scanData);
|
||||
memset(&m_advParams, 0, sizeof m_advParams);
|
||||
|
|
Loading…
Reference in a new issue