mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2025-02-22 14:08:54 +01:00
feat(AdvDevice): Add convenience operator to NimBLEAddress
This commit is contained in:
parent
784e6f30fa
commit
052c0a0455
4 changed files with 11 additions and 20 deletions
|
@ -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.
|
||||
|
|
|
@ -93,6 +93,7 @@ class NimBLEAdvertisedDevice {
|
|||
uint8_t getSecondaryPhy() const;
|
||||
uint16_t getPeriodicInterval() const;
|
||||
# endif
|
||||
operator NimBLEAddress() const;
|
||||
|
||||
const std::vector<uint8_t>& getPayload() const;
|
||||
const std::vector<uint8_t>::const_iterator begin() const;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue