Skip to content

Commit b28f840

Browse files
committed
Attempt to continue connecting even if MTU isn't negotiated
1 parent c155fa8 commit b28f840

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

src/NimBLEClient.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -152,35 +152,35 @@ size_t NimBLEClient::deleteService(const NimBLEUUID &uuid) {
152152

153153
/**
154154
* @brief Connect to the BLE Server.
155-
* @param [in] deleteAttibutes If true this will delete any attribute objects this client may already\n
155+
* @param [in] deleteAttributes If true this will delete any attribute objects this client may already\n
156156
* have created and clears the vectors after successful connection.
157157
* @return True on success.
158158
*/
159-
bool NimBLEClient::connect(bool deleteAttibutes) {
160-
return connect(m_peerAddress, deleteAttibutes);
159+
bool NimBLEClient::connect(bool deleteAttributes) {
160+
return connect(m_peerAddress, deleteAttributes);
161161
}
162162

163163
/**
164164
* @brief Connect to an advertising device.
165165
* @param [in] device The device to connect to.
166-
* @param [in] deleteAttibutes If true this will delete any attribute objects this client may already\n
166+
* @param [in] deleteAttributes If true this will delete any attribute objects this client may already\n
167167
* have created and clears the vectors after successful connection.
168168
* @return True on success.
169169
*/
170-
bool NimBLEClient::connect(NimBLEAdvertisedDevice* device, bool deleteAttibutes) {
170+
bool NimBLEClient::connect(NimBLEAdvertisedDevice* device, bool deleteAttributes) {
171171
NimBLEAddress address(device->getAddress());
172-
return connect(address, deleteAttibutes);
172+
return connect(address, deleteAttributes);
173173
}
174174

175175

176176
/**
177177
* @brief Connect to the BLE Server.
178178
* @param [in] address The address of the server.
179-
* @param [in] deleteAttibutes If true this will delete any attribute objects this client may already\n
179+
* @param [in] deleteAttributes If true this will delete any attribute objects this client may already\n
180180
* have created and clears the vectors after successful connection.
181181
* @return True on success.
182182
*/
183-
bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttibutes) {
183+
bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttributes) {
184184
NIMBLE_LOGD(LOG_TAG, ">> connect(%s)", address.toString().c_str());
185185

186186
if(!NimBLEDevice::m_synced) {
@@ -271,20 +271,11 @@ bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttibutes) {
271271
// Wait for the connect timeout time +1 second for the connection to complete
272272
if(ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(m_connectTimeout + 1000)) == pdFALSE) {
273273
m_pTaskData = nullptr;
274-
// If a connection was made but no response from MTU exchange; disconnect
275-
if(isConnected()) {
276-
NIMBLE_LOGE(LOG_TAG, "Connect timeout - no response");
277-
disconnect();
278-
} else {
279-
// workaround; if the controller doesn't cancel the connection
280-
// at the timeout, cancel it here.
281-
NIMBLE_LOGE(LOG_TAG, "Connect timeout - cancelling");
282-
ble_gap_conn_cancel();
283-
}
284-
285-
return false;
274+
// If a connection was made but no response from MTU exchange; ignore
275+
NIMBLE_LOGE(LOG_TAG, "Connection was made but no response from MTU exchange");
276+
}
286277

287-
} else if(taskData.rc != 0){
278+
if(taskData.rc != 0){
288279
m_lastErr = taskData.rc;
289280
NIMBLE_LOGE(LOG_TAG, "Connection failed; status=%d %s",
290281
taskData.rc,
@@ -299,7 +290,7 @@ bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttibutes) {
299290
NIMBLE_LOGI(LOG_TAG, "Connection established");
300291
}
301292

302-
if(deleteAttibutes) {
293+
if(deleteAttributes) {
303294
deleteServices();
304295
}
305296

src/NimBLEClient.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class NimBLEAdvertisedDevice;
3838
*/
3939
class NimBLEClient {
4040
public:
41-
bool connect(NimBLEAdvertisedDevice* device, bool deleteAttibutes = true);
42-
bool connect(const NimBLEAddress &address, bool deleteAttibutes = true);
43-
bool connect(bool deleteAttibutes = true);
41+
bool connect(NimBLEAdvertisedDevice* device, bool deleteAttributes = true);
42+
bool connect(const NimBLEAddress &address, bool deleteAttributes = true);
43+
bool connect(bool deleteAttributes = true);
4444
int disconnect(uint8_t reason = BLE_ERR_REM_USER_CONN_TERM);
4545
NimBLEAddress getPeerAddress();
4646
void setPeerAddress(const NimBLEAddress &address);

0 commit comments

Comments
 (0)