Skip to content

Commit 402be9a

Browse files
committed
Clear service started flag on error
1 parent 5a00235 commit 402be9a

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+
m_pSvcDef->type = 0; // Clear the type to indicate the service is not started/registered.
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+
m_pSvcDef->type = 0; // Clear the type to indicate the service is not started/registered.
164166
return false;
165167
}
166168

0 commit comments

Comments
 (0)