forked from h2zero/esp-nimble-cpp
Add asyncronous client connect and MTU exchange.
* Adds parameters `asyncConnect` and `exchangeMTU` to `NimBLEClient::connect`, default values work as the original connect method. * * `asyncConnect`; if true, will send the connect command and return immediately with a true value for successfully sending the command, else false. * * `exchangeMTU`; if true will send the exchange MTU command upon connection, otherwise not and the application can choose to do this later via the `exchangeMTU` method. * Adds `onMTUChange` callback to `NimBLEClientCallbacks` * Add `NimBLEDevice::getConnectedClients()` which returns a vector of pointers to the currently connected client instances. * Calling `NimBLEClient::connect` will no longer cancel already in progress connections.
This commit is contained in:
+16
-1
@@ -405,7 +405,7 @@ NimBLEClient* NimBLEDevice::getClientByPeerAddress(const NimBLEAddress& addr) {
|
||||
} // getClientPeerAddress
|
||||
|
||||
/**
|
||||
* @brief Finds the first disconnected client in the list.
|
||||
* @brief Finds the first disconnected client available.
|
||||
* @return A pointer to the first client object that is not connected to a peer or nullptr.
|
||||
*/
|
||||
NimBLEClient* NimBLEDevice::getDisconnectedClient() {
|
||||
@@ -418,6 +418,21 @@ NimBLEClient* NimBLEDevice::getDisconnectedClient() {
|
||||
return nullptr;
|
||||
} // getDisconnectedClient
|
||||
|
||||
/**
|
||||
* @brief Get a list of connected clients.
|
||||
* @return A vector of connected client objects.
|
||||
*/
|
||||
std::vector<NimBLEClient*> NimBLEDevice::getConnectedClients() {
|
||||
std::vector<NimBLEClient*> clients;
|
||||
for (const auto clt : m_pClients) {
|
||||
if (clt != nullptr && clt->isConnected()) {
|
||||
clients.push_back(clt);
|
||||
}
|
||||
}
|
||||
|
||||
return clients;
|
||||
} // getConnectedClients
|
||||
|
||||
# endif // #if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user