fix
This commit is contained in:
parent
7dbdf8a27b
commit
8b9f384e47
22
BLE.ino
22
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user