diff --git a/src/NimBLEAdvertisedDevice.cpp b/src/NimBLEAdvertisedDevice.cpp index cf6cf71..71007ba 100644 --- a/src/NimBLEAdvertisedDevice.cpp +++ b/src/NimBLEAdvertisedDevice.cpp @@ -780,6 +780,16 @@ bool NimBLEAdvertisedDevice::isLegacyAdvertisement() const { # endif } // isLegacyAdvertisement +/** + * @brief Convenience operator to convert this NimBLEAdvertisedDevice to NimBLEAddress representation. + * @details This allows passing NimBLEAdvertisedDevice to functions + * that accept NimBLEAddress and/or or it's methods as a parameter. + */ +NimBLEAdvertisedDevice::operator NimBLEAddress() const { + NimBLEAddress address(getAddress()); + return address; +} // operator NimBLEAddress + /** * @brief Get the payload advertised by the device. * @return The advertisement payload. diff --git a/src/NimBLEAdvertisedDevice.h b/src/NimBLEAdvertisedDevice.h index e8d3a77..4b7da39 100644 --- a/src/NimBLEAdvertisedDevice.h +++ b/src/NimBLEAdvertisedDevice.h @@ -93,6 +93,7 @@ class NimBLEAdvertisedDevice { uint8_t getSecondaryPhy() const; uint16_t getPeriodicInterval() const; # endif + operator NimBLEAddress() const; const std::vector& getPayload() const; const std::vector::const_iterator begin() const; diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index e5b1383..301ef79 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -141,22 +141,6 @@ bool NimBLEClient::connect(bool deleteAttributes, bool asyncConnect, bool exchan return connect(m_peerAddress, deleteAttributes, asyncConnect, exchangeMTU); } // connect -/** - * @brief Connect to an advertising device. - * @param [in] device The device to connect to. - * @param [in] deleteAttributes If true this will delete any attribute objects this client may already\n - * have created when last connected. - * @param [in] asyncConnect If true, the connection will be made asynchronously and this function will return immediately.\n - * If false, this function will block until the connection is established or the connection attempt times out. - * @param [in] exchangeMTU If true, the client will attempt to exchange MTU with the server after connection.\n - * 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(const NimBLEAdvertisedDevice* device, bool deleteAttributes, bool asyncConnect, bool exchangeMTU) { - NimBLEAddress address(device->getAddress()); - return connect(address, deleteAttributes, asyncConnect, exchangeMTU); -} // connect - /** * @brief Connect to a BLE Server by address. * @param [in] address The address of the server. diff --git a/src/NimBLEClient.h b/src/NimBLEClient.h index eba7165..d193f7d 100644 --- a/src/NimBLEClient.h +++ b/src/NimBLEClient.h @@ -48,10 +48,6 @@ struct NimBLETaskData; */ class NimBLEClient { public: - 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);