From 037e7fef86de624364018d0cbb25dbd7a9e706c9 Mon Sep 17 00:00:00 2001 From: h2zero Date: Thu, 30 Oct 2025 15:35:44 -0600 Subject: [PATCH] Add void pointer argument to setCustomGapHandler. --- src/NimBLEDevice.cpp | 5 +++-- src/NimBLEDevice.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp index d87623efd..41da89123 100644 --- a/src/NimBLEDevice.cpp +++ b/src/NimBLEDevice.cpp @@ -1303,10 +1303,11 @@ bool NimBLEDevice::setDeviceName(const std::string& deviceName) { /** * @brief Set a custom callback for gap events. * @param [in] handler The function to call when gap events occur. + * @param [in] arg Argument to pass to the handler. * @returns */ -bool NimBLEDevice::setCustomGapHandler(gap_event_handler handler) { - int rc = ble_gap_event_listener_register(&m_listener, handler, NULL); +bool NimBLEDevice::setCustomGapHandler(gap_event_handler handler, void* arg) { + int rc = ble_gap_event_listener_register(&m_listener, handler, arg); if (rc == BLE_HS_EALREADY) { NIMBLE_LOGI(LOG_TAG, "Already listening to GAP events."); return true; diff --git a/src/NimBLEDevice.h b/src/NimBLEDevice.h index 370750094..26882b899 100644 --- a/src/NimBLEDevice.h +++ b/src/NimBLEDevice.h @@ -133,7 +133,7 @@ class NimBLEDevice { static void setScanDuplicateCacheSize(uint16_t cacheSize); static void setScanFilterMode(uint8_t type); static void setScanDuplicateCacheResetTime(uint16_t time); - static bool setCustomGapHandler(gap_event_handler handler); + static bool setCustomGapHandler(gap_event_handler handler, void* arg = nullptr); static void setSecurityAuth(bool bonding, bool mitm, bool sc); static void setSecurityAuth(uint8_t auth); static void setSecurityIOCap(uint8_t iocap);