Skip to content

Commit 48f607f

Browse files
h2zerowakwak-koba
andcommitted
Set default address type to public.
* Cleanup logs Co-authored-by: wakwak-koba <[email protected]>
1 parent d91e1c3 commit 48f607f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/NimBLEClient.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ bool NimBLEClient::connect(bool deleteAttibutes) {
146146
*/
147147
bool NimBLEClient::connect(NimBLEAdvertisedDevice* device, bool deleteAttibutes) {
148148
NimBLEAddress address(device->getAddress());
149-
uint8_t type = device->getAddressType();
150-
return connect(address, type, deleteAttibutes);
149+
return connect(address, 0, deleteAttibutes);
151150
}
152151

153152

@@ -181,7 +180,7 @@ bool NimBLEClient::connect(const NimBLEAddress &address, uint8_t type, bool dele
181180

182181
ble_addr_t peerAddrt;
183182
memcpy(&peerAddrt.val, address.getNative(),6);
184-
peerAddrt.type = type;
183+
peerAddrt.type = address.getType();
185184

186185
ble_task_data_t taskData = {this, xTaskGetCurrentTaskHandle(), 0, nullptr};
187186
m_pTaskData = &taskData;
@@ -199,10 +198,9 @@ bool NimBLEClient::connect(const NimBLEAddress &address, uint8_t type, bool dele
199198
}while(rc == BLE_HS_EBUSY);
200199

201200
if (rc != 0 && rc != BLE_HS_EDONE) {
202-
NIMBLE_LOGE(LOG_TAG, "Error: Failed to connect to device; addr_type=%d "
201+
NIMBLE_LOGE(LOG_TAG, "Error: Failed to connect to device; "
203202
"addr=%s, rc=%d; %s",
204-
type,
205-
m_peerAddress.toString().c_str(),
203+
std::string(m_peerAddress).c_str(),
206204
rc, NimBLEUtils::returnCodeToString(rc));
207205
m_pTaskData = nullptr;
208206
m_waitingToConnect = false;
@@ -219,7 +217,6 @@ bool NimBLEClient::connect(const NimBLEAddress &address, uint8_t type, bool dele
219217
}
220218

221219
if(deleteAttibutes) {
222-
NIMBLE_LOGD(LOG_TAG, "Refreshing Services for: (%s)", address.toString().c_str());
223220
deleteServices();
224221
}
225222

@@ -373,7 +370,7 @@ void NimBLEClient::setPeerAddress(const NimBLEAddress &address) {
373370
}
374371

375372
m_peerAddress = address;
376-
NIMBLE_LOGE(LOG_TAG, "Peer address set: %s", std::string(m_peerAddress).c_str());
373+
NIMBLE_LOGD(LOG_TAG, "Peer address set: %s", std::string(m_peerAddress).c_str());
377374
} // setPeerAddress
378375

379376

src/NimBLEDevice.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ void NimBLEDevice::stopAdvertising() {
137137
/**
138138
* @brief Creates a new client object and maintains a list of all client objects
139139
* each client can connect to 1 peripheral device.
140+
* @param [in] peerAddress An optional peer address that is copied to the new client
141+
* object, allows for calling connect() without providing a device or address.
140142
* @return A reference to the new client object.
141143
*/
142144
#if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)

0 commit comments

Comments
 (0)