From 1ac74cefc44ce0e1e586acc2667a85ec09bf50d2 Mon Sep 17 00:00:00 2001 From: JaeHwan Jin Date: Mon, 17 Nov 2025 21:20:07 +0900 Subject: [PATCH] Fix for esp32 CI --- src/configuration.h | 12 ++++++++++ .../Telemetry/EnvironmentTelemetry.cpp | 6 ++--- src/modules/Telemetry/Sensor/BME680Generic.h | 11 --------- src/modules/Telemetry/Sensor/BME680Sensor.cpp | 20 +++++++--------- src/modules/Telemetry/Sensor/BME680Sensor.h | 24 +++++++++---------- 5 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 src/modules/Telemetry/Sensor/BME680Generic.h diff --git a/src/configuration.h b/src/configuration.h index 8ec3b2211..d58fcef58 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -410,6 +410,18 @@ along with this program. If not, see . #endif #endif +// BME680 BSEC2 support detection +#if !defined(MESHTASTIC_BME680_BSEC2_SUPPORTED) +#if defined(RAK_4631) || defined(TBEAM_V10) + +#define MESHTASTIC_BME680_BSEC2_SUPPORTED 1 +#define MESHTASTIC_BME680_HEADER +#else +#define MESHTASTIC_BME680_BSEC2_SUPPORTED 0 +#define MESHTASTIC_BME680_HEADER +#endif // defined(RAK_4631) +#endif // !defined(MESHTASTIC_BME680_BSEC2_SUPPORTED) + // ----------------------------------------------------------------------------- // Global switches to turn off features for a minimized build // ----------------------------------------------------------------------------- diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 6a2dcfe47..6c6b0a7c2 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -53,9 +53,7 @@ extern void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const c #include "Sensor/LTR390UVSensor.h" #endif -#include "Sensor/BME680Generic.h" - -#if __has_include(BME680_HEADER) +#if __has_include(MESHTASTIC_BME680_HEADER) #include "Sensor/BME680Sensor.h" #endif @@ -216,7 +214,7 @@ void EnvironmentTelemetryModule::i2cScanFinished(ScanI2C *i2cScanner) #if __has_include() addSensor(i2cScanner, ScanI2C::DeviceType::LTR390UV); #endif -#if __has_include(BME680_HEADER) +#if __has_include(MESHTASTIC_BME680_HEADER) addSensor(i2cScanner, ScanI2C::DeviceType::BME_680); #endif #if __has_include() diff --git a/src/modules/Telemetry/Sensor/BME680Generic.h b/src/modules/Telemetry/Sensor/BME680Generic.h deleted file mode 100644 index f7a37884d..000000000 --- a/src/modules/Telemetry/Sensor/BME680Generic.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "configuration.h" - -#if !defined(BME680_BSEC2_SUPPORTED) -#if defined(RAK_4631) -#define BME680_BSEC2_SUPPORTED 1 -#define BME680_HEADER -#else -#define BME680_BSEC2_SUPPORTED 0 -#define BME680_HEADER -#endif // defined(RAK_4631) -#endif // !defined(BME680_BSEC2_SUPPORTED) diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index d3955d4cf..22330ca75 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -1,8 +1,6 @@ #include "configuration.h" -#include "BME680Generic.h" - -#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(BME680_HEADER) +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(MESHTASTIC_BME680_HEADER) #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "BME680Sensor.h" @@ -12,7 +10,7 @@ BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {} -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 int32_t BME680Sensor::runOnce() { if (!bme680.run()) { @@ -20,13 +18,13 @@ int32_t BME680Sensor::runOnce() } return 35; } -#endif // defined(BME680_BSEC2_SUPPORTED) +#endif // defined(MESHTASTIC_BME680_BSEC2_SUPPORTED) bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) { status = 0; -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 if (!bme680.begin(dev->address.address, *bus)) checkStatus("begin"); @@ -58,7 +56,7 @@ bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) status = 1; -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED initI2CSensor(); return status; @@ -66,7 +64,7 @@ bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement) { -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 if (bme680.getData(BSEC_OUTPUT_RAW_PRESSURE).signal == 0) return false; @@ -100,11 +98,11 @@ bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.barometric_pressure = bme680->readPressure() / 100.0F; measurement->variant.environment_metrics.gas_resistance = bme680->readGas() / 1000.0; -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED return true; } -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 void BME680Sensor::loadState() { #ifdef FSCom @@ -181,6 +179,6 @@ void BME680Sensor::checkStatus(const char *functionName) else if (bme680.sensor.status > BME68X_OK) LOG_WARN("%s BME68X code: %d", functionName, bme680.sensor.status); } -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED #endif diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.h b/src/modules/Telemetry/Sensor/BME680Sensor.h index 560bdefc4..9bef56e1e 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.h +++ b/src/modules/Telemetry/Sensor/BME680Sensor.h @@ -1,31 +1,29 @@ #include "configuration.h" -#include "BME680Generic.h" - -#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(BME680_HEADER) +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(MESHTASTIC_BME680_HEADER) #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 #include #include #else #include #include -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED #define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // That's 6 hours worth of millis() -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 const uint8_t bsec_config[] = { #include "config/bme680/bme680_iaq_33v_3s_4d/bsec_iaq.txt" }; -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED class BME680Sensor : public TelemetrySensor { private: -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 Bsec2 bme680; #else using BME680Ptr = std::unique_ptr; @@ -33,10 +31,10 @@ class BME680Sensor : public TelemetrySensor static BME680Ptr makeBME680(TwoWire *bus) { return std::make_unique(bus); } BME680Ptr bme680; -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED protected: -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 const char *bsecConfigFileName = "/prefs/bsec.dat"; uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0}; uint8_t accuracy = 0; @@ -53,13 +51,13 @@ class BME680Sensor : public TelemetrySensor void loadState(); void updateState(); void checkStatus(const char *functionName); -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED public: BME680Sensor(); -#if BME680_BSEC2_SUPPORTED == 1 +#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1 virtual int32_t runOnce() override; -#endif // BME680_BSEC2_SUPPORTED +#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override; };