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 = build_flags =
${env.build_flags} ${env.build_flags}
-D CORE_DEBUG_LEVEL=0 -D CORE_DEBUG_LEVEL=0
-D USE_BLE=1
; Boards ; Boards

View File

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

View File

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