Skip to content

Commit

Permalink
Fix crash that could occur when server reconnects
Browse files Browse the repository at this point in the history
* Update to not change services if they have not actually changed when starting the server
Closes #270
  • Loading branch information
finger563 authored and h2zero committed Dec 20, 2024
1 parent 462f918 commit 0d7592a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/NimBLEService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ void NimBLEService::dump() const {
*/
bool NimBLEService::start() {
NIMBLE_LOGD(LOG_TAG, ">> start(): Starting service: %s", toString().c_str());

// If started previously and no characteristics have been added or removed,
// then we can skip the service registration process.
if (m_pSvcDef->characteristics && !getServer()->m_svcChanged) {
return true;
}

// If started previously, clear everything and start over
if (m_pSvcDef->characteristics) {
if (m_pSvcDef->characteristics->descriptors) {
Expand Down

0 comments on commit 0d7592a

Please sign in to comment.