Use USE_BLE flag to enable/disable BLE temp sensors

This commit is contained in:
Menno de Graaf
2023-12-10 14:17:13 +01:00
parent 3ed2b22d06
commit 84c3859c5d
3 changed files with 10 additions and 3 deletions

View File

@@ -58,6 +58,7 @@ extra_scripts =
build_flags =
${env.build_flags}
-D CORE_DEBUG_LEVEL=0
-D USE_BLE=1
; Boards

View File

@@ -1,7 +1,7 @@
#include <OneWire.h>
#include <DallasTemperature.h>
#if defined(ESP32)
#if USE_BLE
#include <NimBLEDevice.h>
// BLE services and characterstics that we are interested in
@@ -37,7 +37,7 @@ protected:
float filteredIndoorTemp = 0;
bool emptyIndoorTemp = true;
#if defined(ESP32)
#if USE_BLE
BLEClient* pBleClient = nullptr;
BLERemoteService* pBleServiceBattery = nullptr;
BLERemoteService* pBleServiceEnvironment = nullptr;
@@ -64,12 +64,14 @@ protected:
if (settings.sensors.indoor.type == 2 && settings.sensors.indoor.pin) {
indoorTemperatureSensor();
}
#if defined(ESP32)
#if USE_BLE
else if (settings.sensors.indoor.type == 3 && strlen(settings.sensors.indoor.bleAddresss)) {
bluetoothSensor();
}
#endif
}
#if USE_BLE
void bluetoothSensor() {
if (!initBleSensor && millis() > 5000) {
Log.sinfoln(FPSTR(S_SENSORS_BLE), "Init BLE. Free heap %u bytes", ESP.getFreeHeap());

View File

@@ -34,6 +34,10 @@
#define USE_TELNET true
#endif
#ifndef USE_BLE
#define USE_BLE false
#endif
#ifndef DEBUG_BY_DEFAULT
#define DEBUG_BY_DEFAULT false
#endif