From 41a7aa8eb5a00ebf02a7b7b90c43ad1f7eb9ace4 Mon Sep 17 00:00:00 2001 From: h2zero Date: Sun, 24 Nov 2024 16:17:01 -0700 Subject: [PATCH] Add const to NimBLEAdvertisedDevice* in NimBLEClient::connect overload Fixes an issue where the wrong connect overload is called if the NimBLEAdvertisedDevice* passed is const. --- src/NimBLEClient.cpp | 2 +- src/NimBLEClient.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 7d9a10e..7054f93 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -147,7 +147,7 @@ bool NimBLEClient::connect(bool deleteAttributes, bool asyncConnect, bool exchan * If false, the client will use the default MTU size and the application will need to call exchangeMTU() later. * @return true on success. */ -bool NimBLEClient::connect(NimBLEAdvertisedDevice* device, bool deleteAttributes, bool asyncConnect, bool exchangeMTU) { +bool NimBLEClient::connect(const NimBLEAdvertisedDevice* device, bool deleteAttributes, bool asyncConnect, bool exchangeMTU) { NimBLEAddress address(device->getAddress()); return connect(address, deleteAttributes, asyncConnect, exchangeMTU); } diff --git a/src/NimBLEClient.h b/src/NimBLEClient.h index d5c3265..430e3c6 100644 --- a/src/NimBLEClient.h +++ b/src/NimBLEClient.h @@ -44,10 +44,10 @@ struct NimBLETaskData; */ class NimBLEClient { public: - bool connect(NimBLEAdvertisedDevice* device, - bool deleteAttributes = true, - bool asyncConnect = false, - bool exchangeMTU = true); + bool connect(const NimBLEAdvertisedDevice* device, + bool deleteAttributes = true, + bool asyncConnect = false, + bool exchangeMTU = true); bool connect(const NimBLEAddress& address, bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true); bool connect(bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true); bool disconnect(uint8_t reason = BLE_ERR_REM_USER_CONN_TERM);