@@ -134,7 +134,7 @@ size_t NimBLEClient::deleteService(const NimBLEUUID &uuid) {
134134 * @return True on success.
135135 */
136136bool NimBLEClient::connect (bool deleteAttibutes) {
137- return connect (m_peerAddress, 0 , deleteAttibutes);
137+ return connect (m_peerAddress, deleteAttibutes);
138138}
139139
140140/* *
@@ -146,7 +146,7 @@ bool NimBLEClient::connect(bool deleteAttibutes) {
146146 */
147147bool NimBLEClient::connect (NimBLEAdvertisedDevice* device, bool deleteAttibutes) {
148148 NimBLEAddress address (device->getAddress ());
149- return connect (address, 0 , deleteAttibutes);
149+ return connect (address, deleteAttibutes);
150150}
151151
152152
@@ -158,7 +158,7 @@ bool NimBLEClient::connect(NimBLEAdvertisedDevice* device, bool deleteAttibutes)
158158 * have created and clears the vectors after successful connection.
159159 * @return True on success.
160160 */
161- bool NimBLEClient::connect (const NimBLEAddress &address, uint8_t type, bool deleteAttibutes) {
161+ bool NimBLEClient::connect (const NimBLEAddress &address, bool deleteAttibutes) {
162162 NIMBLE_LOGD (LOG_TAG, " >> connect(%s)" , address.toString ().c_str ());
163163
164164 if (!NimBLEDevice::m_synced) {
@@ -175,16 +175,22 @@ bool NimBLEClient::connect(const NimBLEAddress &address, uint8_t type, bool dele
175175 return false ;
176176 }
177177
178- int rc = 0 ;
179- m_peerAddress = address;
178+ if (address == NimBLEAddress (" " )) {
179+ NIMBLE_LOGE (LOG_TAG, " Invalid peer address;(NULL)" );
180+ return false ;
181+ } else if (m_peerAddress != address) {
182+ m_peerAddress = address;
183+ }
180184
181185 ble_addr_t peerAddrt;
182- memcpy (&peerAddrt.val , address .getNative (),6 );
183- peerAddrt.type = address .getType ();
186+ memcpy (&peerAddrt.val , m_peerAddress .getNative (),6 );
187+ peerAddrt.type = m_peerAddress .getType ();
184188
185189 ble_task_data_t taskData = {this , xTaskGetCurrentTaskHandle (), 0 , nullptr };
186190 m_pTaskData = &taskData;
187191
192+ int rc = 0 ;
193+
188194 /* Try to connect the the advertiser. Allow 30 seconds (30000 ms) for
189195 * timeout (default value of m_connectTimeout).
190196 * Loop on BLE_HS_EBUSY if the scan hasn't stopped yet.
0 commit comments