Skip to content

Commit

Permalink
Set service handle in getHandle function if not set already. (#544)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
h2zero committed May 14, 2023
1 parent ebfe4bc commit 90ab225
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/NimBLEService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ bool NimBLEService::start() {
* @return The handle associated with this service.
*/
uint16_t NimBLEService::getHandle() {
if (m_handle == NULL_HANDLE) {
ble_gatts_find_svc(&getUUID().getNative()->u, &m_handle);
}
return m_handle;
} // getHandle

Expand Down

0 comments on commit 90ab225

Please sign in to comment.