Skip to content

Commit 90ab225

Browse files
authored
Set service handle in getHandle function if not set already. (#544)
If a service has been created and started but not yet added to the gatt server then the call to getHandle will result in an invalid handle. This adds a call to set the handle value in the getHandle function.
1 parent ebfe4bc commit 90ab225

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/NimBLEService.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ bool NimBLEService::start() {
247247
* @return The handle associated with this service.
248248
*/
249249
uint16_t NimBLEService::getHandle() {
250+
if (m_handle == NULL_HANDLE) {
251+
ble_gatts_find_svc(&getUUID().getNative()->u, &m_handle);
252+
}
250253
return m_handle;
251254
} // getHandle
252255

0 commit comments

Comments
 (0)