Skip to content

Commit d6013fd

Browse files
committed
Partially revert Commit 9397a49 to restore client connect with device parameter.
1 parent 57db938 commit d6013fd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/NimBLEClient.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ size_t NimBLEClient::deleteService(const NimBLEUUID& uuid) {
126126
return m_svcVec.size();
127127
} // deleteService
128128

129+
/**
130+
* @brief Connect to an advertising device.
131+
* @param [in] pDevice A pointer to the advertised device instance to connect to.
132+
* @param [in] deleteAttributes If true this will delete any attribute objects this client may already\n
133+
* have created when last connected.
134+
* @param [in] asyncConnect If true, the connection will be made asynchronously and this function will return immediately.\n
135+
* If false, this function will block until the connection is established or the connection attempt times out.
136+
* @param [in] exchangeMTU If true, the client will attempt to exchange MTU with the server after connection.\n
137+
* If false, the client will use the default MTU size and the application will need to call exchangeMTU() later.
138+
* @return true on success.
139+
*/
140+
bool NimBLEClient::connect(const NimBLEAdvertisedDevice* pDevice, bool deleteAttributes, bool asyncConnect, bool exchangeMTU) {
141+
NimBLEAddress address(pDevice->getAddress());
142+
return connect(address, deleteAttributes, asyncConnect, exchangeMTU);
143+
} // connect
144+
129145
/**
130146
* @brief Connect to the BLE Server using the address of the last connected device, or the address\n
131147
* passed to the constructor.

src/NimBLEClient.h

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ struct NimBLETaskData;
4848
*/
4949
class NimBLEClient {
5050
public:
51+
bool connect(const NimBLEAdvertisedDevice* device,
52+
bool deleteAttributes = true,
53+
bool asyncConnect = false,
54+
bool exchangeMTU = true);
5155
bool connect(const NimBLEAddress& address, bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
5256
bool connect(bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
5357
bool disconnect(uint8_t reason = BLE_ERR_REM_USER_CONN_TERM);

0 commit comments

Comments
 (0)