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));