Skip to content

Commit 100edee

Browse files
h2zerowakwak-koba
andcommitted
Initialize peerAddress in client constructor.
Co-authored-by: wakwak-koba <[email protected]>
1 parent 95466c6 commit 100edee

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

src/NimBLEClient.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ static NimBLEClientCallbacks defaultCallbacks;
5353
* @brief Constructor, private - only callable by NimBLEDevice::createClient
5454
* to ensure proper handling of the list of client objects.
5555
*/
56-
NimBLEClient::NimBLEClient()
57-
{
56+
NimBLEClient::NimBLEClient(const NimBLEAddress &peerAddress) : m_peerAddress(peerAddress) {
5857
m_pClientCallbacks = &defaultCallbacks;
5958
m_conn_id = BLE_HS_CONN_HANDLE_NONE;
6059
m_isConnected = false;

src/NimBLEClient.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class NimBLEClient {
7171
void discoverAttributes();
7272

7373
private:
74-
NimBLEClient();
74+
NimBLEClient(const NimBLEAddress &peerAddress);
7575
~NimBLEClient();
7676

7777
friend class NimBLEDevice;
@@ -84,7 +84,7 @@ class NimBLEClient {
8484
void *arg);
8585
bool retrieveServices(const NimBLEUUID *uuid_filter = nullptr);
8686

87-
NimBLEAddress m_peerAddress = NimBLEAddress("");
87+
NimBLEAddress m_peerAddress;
8888
uint16_t m_conn_id;
8989
bool m_isConnected;
9090
bool m_waitingToConnect;

src/NimBLEDevice.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ void NimBLEDevice::stopAdvertising() {
148148
NIMBLE_MAX_CONNECTIONS);
149149
}
150150

151-
NimBLEClient* pClient = new NimBLEClient();
152-
if(peerAddress != NimBLEAddress("")) {
153-
pClient->setPeerAddress(peerAddress);
154-
}
151+
NimBLEClient* pClient = new NimBLEClient(peerAddress);
155152
m_cList.push_back(pClient);
156153

157154
return pClient;

0 commit comments

Comments
 (0)