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
This commit is contained in:
William Emfinger 2024-12-20 13:16:27 -06:00 committed by Ryan Powell
parent 0d13044703
commit e843c6811c

View file

@ -91,6 +91,13 @@ void NimBLEService::dump() const {
*/ */
bool NimBLEService::start() { bool NimBLEService::start() {
NIMBLE_LOGD(LOG_TAG, ">> start(): Starting service: %s", toString().c_str()); 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 started previously, clear everything and start over
if (m_pSvcDef->characteristics) { if (m_pSvcDef->characteristics) {
if (m_pSvcDef->characteristics->descriptors) { if (m_pSvcDef->characteristics->descriptors) {