This commit is contained in:
James 2024-04-23 21:46:06 +01:00
parent 7dbdf8a27b
commit 8b9f384e47
2 changed files with 5 additions and 21 deletions

22
BLE.ino
View File

@ -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");
}
}
}
}
};

View File

@ -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 <BLEDevice.h> // for BLE