diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 436341c..e65ced9 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -53,8 +53,7 @@ static NimBLEClientCallbacks defaultCallbacks; * @brief Constructor, private - only callable by NimBLEDevice::createClient * to ensure proper handling of the list of client objects. */ -NimBLEClient::NimBLEClient() -{ +NimBLEClient::NimBLEClient(const NimBLEAddress &peerAddress) : m_peerAddress(peerAddress) { m_pClientCallbacks = &defaultCallbacks; m_conn_id = BLE_HS_CONN_HANDLE_NONE; m_isConnected = false; diff --git a/src/NimBLEClient.h b/src/NimBLEClient.h index 1591cfd..73dfafb 100644 --- a/src/NimBLEClient.h +++ b/src/NimBLEClient.h @@ -71,7 +71,7 @@ public: void discoverAttributes(); private: - NimBLEClient(); + NimBLEClient(const NimBLEAddress &peerAddress); ~NimBLEClient(); friend class NimBLEDevice; @@ -84,7 +84,7 @@ private: void *arg); bool retrieveServices(const NimBLEUUID *uuid_filter = nullptr); - NimBLEAddress m_peerAddress = NimBLEAddress(""); + NimBLEAddress m_peerAddress; uint16_t m_conn_id; bool m_isConnected; bool m_waitingToConnect; diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp index 82a8086..fb36e6e 100644 --- a/src/NimBLEDevice.cpp +++ b/src/NimBLEDevice.cpp @@ -148,10 +148,7 @@ void NimBLEDevice::stopAdvertising() { NIMBLE_MAX_CONNECTIONS); } - NimBLEClient* pClient = new NimBLEClient(); - if(peerAddress != NimBLEAddress("")) { - pClient->setPeerAddress(peerAddress); - } + NimBLEClient* pClient = new NimBLEClient(peerAddress); m_cList.push_back(pClient); return pClient;