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 h2zero
parent 275def333c
commit fd0187bfc9

View file

@ -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) {