Skip to content

Commit 28d6492

Browse files
committed
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.
1 parent dff5122 commit 28d6492

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/NimBLEAdvertising.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ NimBLEAdvertising::NimBLEAdvertising() {
4141
* @brief Stops the current advertising and resets the advertising data to the default values.
4242
*/
4343
void NimBLEAdvertising::reset() {
44-
stop();
44+
if(NimBLEDevice::getInitialized() && isAdvertising()) {
45+
stop();
46+
}
4547
memset(&m_advData, 0, sizeof m_advData);
4648
memset(&m_scanData, 0, sizeof m_scanData);
4749
memset(&m_advParams, 0, sizeof m_advParams);

0 commit comments

Comments
 (0)