From 4706d75adc4bf09e3a7616c90911e8ff2ffb8dfd Mon Sep 17 00:00:00 2001 From: h2zero <32826625+h2zero@users.noreply.github.com> Date: Sun, 16 May 2021 20:07:21 -0600 Subject: [PATCH] Remove unsubscribe and disconnect calls in BLEconnect. (#948) These calls were unecessary as the client object swill be deleted when finished with the connection. --- main/ZgatewayBT.ino | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index 9e22cfa..0029d31 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -701,8 +701,6 @@ void notifyCB( } else { Log.trace(F("Callback process canceled by processLock" CR)); } - - pBLERemoteCharacteristic->unsubscribe(); } /** @@ -721,12 +719,10 @@ void BLEconnect() { BLEAddress sensorAddress(p->macAdr); if (!pClient->connect(sensorAddress)) { Log.notice(F("Failed to find client: %s" CR), p->macAdr); - NimBLEDevice::deleteClient(pClient); } else { BLERemoteService* pRemoteService = pClient->getService(serviceUUID); if (!pRemoteService) { Log.notice(F("Failed to find service UUID: %s" CR), serviceUUID.toString().c_str()); - pClient->disconnect(); } else { Log.trace(F("Found service: %s" CR), serviceUUID.toString().c_str()); // Obtain a reference to the characteristic in the service of the remote BLE server. @@ -735,21 +731,19 @@ void BLEconnect() { BLERemoteCharacteristic* pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID); if (!pRemoteCharacteristic) { Log.notice(F("Failed to find characteristic UUID: %s" CR), charUUID.toString().c_str()); - pClient->disconnect(); } else { if (pRemoteCharacteristic->canNotify()) { Log.trace(F("Registering notification" CR)); pRemoteCharacteristic->subscribe(true, notifyCB); delay(BLE_CNCT_TIMEOUT); - pClient->disconnect(); } else { Log.notice(F("Failed registering notification" CR)); - pClient->disconnect(); } } } } } + NimBLEDevice::deleteClient(pClient); } } Log.notice(F("BLE Connect end" CR));