Set service handle in getHandle function if not set already.

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.
This commit is contained in:
h2zero 2023-05-14 15:40:51 -06:00 committed by h2zero
parent bf956b9cdf
commit e93f943cc4

View file

@ -248,6 +248,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