From 7f6959c92e844c0dd5f7814889dd0a8af57d8bcc Mon Sep 17 00:00:00 2001 From: h2zero Date: Fri, 14 Jun 2024 14:10:37 -0600 Subject: [PATCH] Add service isStarted method, remove abort in NimBLEServer::start. --- src/NimBLEServer.cpp | 4 +++- src/NimBLEService.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NimBLEServer.cpp b/src/NimBLEServer.cpp index 82fbc7a0..6ee06453 100644 --- a/src/NimBLEServer.cpp +++ b/src/NimBLEServer.cpp @@ -215,7 +215,9 @@ void NimBLEServer::start() { if(svc->m_removed == 0) { rc = ble_gatts_find_svc(&svc->getUUID().getNative()->u, &svc->m_handle); if(rc != 0) { - abort(); + NIMBLE_LOGW(LOG_TAG, "GATT Server started without service: %s, Service %s", + svc->getUUID().toString().c_str(), svc->isStarted() ? "missing" : "not started"); + continue; // Skip this service as it was not started } } diff --git a/src/NimBLEService.h b/src/NimBLEService.h index 21ec1af7..6f330168 100644 --- a/src/NimBLEService.h +++ b/src/NimBLEService.h @@ -44,7 +44,7 @@ class NimBLEService { uint16_t getHandle(); std::string toString(); void dump(); - + bool isStarted() { return m_pSvcDef != nullptr; } bool start(); NimBLECharacteristic* createCharacteristic(const char* uuid,