Skip to content

Commit 85e500d

Browse files
finger563h2zero
authored andcommitted
Fix crash that could occur when server reconnects
* Update to not change services if they have not actually changed when starting the server Closes #270
1 parent f849485 commit 85e500d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/NimBLEService.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ void NimBLEService::dump() const {
9191
*/
9292
bool NimBLEService::start() {
9393
NIMBLE_LOGD(LOG_TAG, ">> start(): Starting service: %s", toString().c_str());
94+
95+
// If started previously and no characteristics have been added or removed,
96+
// then we can skip the service registration process.
97+
if (m_pSvcDef->characteristics && !getServer()->m_svcChanged) {
98+
return true;
99+
}
100+
94101
// If started previously, clear everything and start over
95102
if (m_pSvcDef->characteristics) {
96103
if (m_pSvcDef->characteristics->descriptors) {

0 commit comments

Comments
 (0)