Set peer address of client when creating the instance.

* Adds new client connect method that will connect to the address already set.

Co-authored-by: wakwak-koba <wakwak-koba@users.noreply.github.com>
This commit is contained in:
h2zero
2020-08-03 22:13:57 -06:00
committed by h2zero
co-authored by wakwak-koba
parent f3e0d66853
commit 33d0a732a6
4 changed files with 28 additions and 3 deletions
+4 -1
View File
@@ -140,13 +140,16 @@ void NimBLEDevice::stopAdvertising() {
* @return A reference to the new client object.
*/
#if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
/* STATIC */ NimBLEClient* NimBLEDevice::createClient() {
/* STATIC */ NimBLEClient* NimBLEDevice::createClient(NimBLEAddress peerAddress) {
if(m_cList.size() >= NIMBLE_MAX_CONNECTIONS) {
NIMBLE_LOGW("Number of clients exceeds Max connections. Max=(%d)",
NIMBLE_MAX_CONNECTIONS);
}
NimBLEClient* pClient = new NimBLEClient();
if(peerAddress != NimBLEAddress("")) {
pClient->setPeerAddress(peerAddress);
}
m_cList.push_back(pClient);
return pClient;