diff --git a/BLE.ino b/BLE.ino index f21d1b7..339a798 100644 --- a/BLE.ino +++ b/BLE.ino @@ -54,15 +54,11 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks{ Serial.println(advertisedDevice.toString().c_str()); } - - - // Check if found device is the one we are looking for - if( - strcmp(advertisedDevice.getName().c_str(), BLE_NAME)==0 && - strcmp(advertisedDevice.getAddress().toString().c_str(), BLE_ADDRESS)==0 && - advertisedDevice.haveServiceUUID() && - advertisedDevice.isAdvertisingService(serviceUUID) - ){ + // Check if device is advertising the specific service UUID + if (!advertisedDevice.isAdvertisingService(serviceUUID)) { + debug("Device does not advertise the specified service UUID."); + return; + } if(BLE_CALLBACK_DEBUG){ debug("BLE: target device found"); @@ -70,8 +66,6 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks{ pBLEScan->stop(); - if(advertisedDevice.getRSSI() >= BLE_MIN_RSSI){ - // delete old remote device, create new one if(pRemoteDevice != nullptr){ delete pRemoteDevice; @@ -79,12 +73,6 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks{ pRemoteDevice = new BLEAdvertisedDevice(advertisedDevice); doConnect = true; - }else{ - if(BLE_CALLBACK_DEBUG){ - debug("BLE: RSSI of target device below minimum"); - } - } - } } }; diff --git a/ESPBMS.ino b/ESPBMS.ino index d464072..1c799d8 100644 --- a/ESPBMS.ino +++ b/ESPBMS.ino @@ -52,10 +52,6 @@ #define BLE_CALLBACK_DEBUG true // send debug messages via MQTT & serial in callbacks (handy for finding your BMS address, name, RSSI, etc) -// watchdog timeout -#define WATCHDOG_TIMEOUT (BLE_TIMEOUT+10*1000) // go to sleep after x seconds - - // ==== MAIN CODE ==== #include "datatypes.h" // for brevity the BMS stuff is in this file #include // for BLE