Skip to content

Commit 6034b1c

Browse files
committed
Clear service started flag on error
1 parent 5a00235 commit 6034b1c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/NimBLEService.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ bool NimBLEService::start_internal() {
155155
int rc = ble_gatts_count_cfg(m_pSvcDef);
156156
if (rc != 0) {
157157
NIMBLE_LOGE(LOG_TAG, "ble_gatts_count_cfg failed, rc= %d, %s", rc, NimBLEUtils::returnCodeToString(rc));
158+
clearServiceDefinitions(); // Clear the definitions to free memory and reset the service for re-registration.
158159
return false;
159160
}
160161

161162
rc = ble_gatts_add_svcs(m_pSvcDef);
162163
if (rc != 0) {
163164
NIMBLE_LOGE(LOG_TAG, "ble_gatts_add_svcs, rc= %d, %s", rc, NimBLEUtils::returnCodeToString(rc));
165+
clearServiceDefinitions(); // Clear the definitions to free memory and reset the service for re-registration.
164166
return false;
165167
}
166168

0 commit comments

Comments
 (0)