mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-20 16:57:29 +00:00
Compare commits
1 Commits
evicted-ag
...
fix-bme
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e545897d4e |
@@ -445,18 +445,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#endif
|
#endif
|
||||||
#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 <bsec2.h>
|
|
||||||
#else
|
|
||||||
#define MESHTASTIC_BME680_BSEC2_SUPPORTED 0
|
|
||||||
#define MESHTASTIC_BME680_HEADER <Adafruit_BME680.h>
|
|
||||||
#endif // defined(RAK_4631)
|
|
||||||
#endif // !defined(MESHTASTIC_BME680_BSEC2_SUPPORTED)
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Global switches to turn off features for a minimized build
|
// Global switches to turn off features for a minimized build
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2029,7 +2029,6 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
|||||||
}
|
}
|
||||||
// if we found a "boring" node, evict it
|
// if we found a "boring" node, evict it
|
||||||
if (oldestBoringIndex != -1) {
|
if (oldestBoringIndex != -1) {
|
||||||
evictedAge = sinceLastSeen(&meshNodes->at(oldestBoringIndex));
|
|
||||||
oldestIndex = oldestBoringIndex;
|
oldestIndex = oldestBoringIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2041,7 +2040,6 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
|||||||
(numMeshNodes)--;
|
(numMeshNodes)--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_WARN("Evicted node %u secs old", evictedAge);
|
|
||||||
// add the node at the end
|
// add the node at the end
|
||||||
lite = &meshNodes->at((numMeshNodes)++);
|
lite = &meshNodes->at((numMeshNodes)++);
|
||||||
|
|
||||||
|
|||||||
@@ -307,10 +307,7 @@ class NodeDB
|
|||||||
newStatus.notifyObservers(&status);
|
newStatus.notifyObservers(&status);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_evicted_age() { return evictedAge; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t evictedAge = UINT32_MAX;
|
|
||||||
bool duplicateWarned = false;
|
bool duplicateWarned = false;
|
||||||
bool localPositionUpdatedSinceBoot = false;
|
bool localPositionUpdatedSinceBoot = false;
|
||||||
uint32_t lastNodeDbSave = 0; // when we last saved our db to flash
|
uint32_t lastNodeDbSave = 0; // when we last saved our db to flash
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ extern void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const c
|
|||||||
#include "Sensor/LTR390UVSensor.h"
|
#include "Sensor/LTR390UVSensor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __has_include(MESHTASTIC_BME680_HEADER)
|
#if __has_include(<bsec2.h>) || __has_include(<Adafruit_BME680.h>)
|
||||||
#include "Sensor/BME680Sensor.h"
|
#include "Sensor/BME680Sensor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ void EnvironmentTelemetryModule::i2cScanFinished(ScanI2C *i2cScanner)
|
|||||||
#if __has_include(<Adafruit_LTR390.h>)
|
#if __has_include(<Adafruit_LTR390.h>)
|
||||||
addSensor<LTR390UVSensor>(i2cScanner, ScanI2C::DeviceType::LTR390UV);
|
addSensor<LTR390UVSensor>(i2cScanner, ScanI2C::DeviceType::LTR390UV);
|
||||||
#endif
|
#endif
|
||||||
#if __has_include(MESHTASTIC_BME680_HEADER)
|
#if __has_include(<bsec2.h>) || __has_include(<Adafruit_BME680.h>)
|
||||||
addSensor<BME680Sensor>(i2cScanner, ScanI2C::DeviceType::BME_680);
|
addSensor<BME680Sensor>(i2cScanner, ScanI2C::DeviceType::BME_680);
|
||||||
#endif
|
#endif
|
||||||
#if __has_include(<Adafruit_BMP280.h>)
|
#if __has_include(<Adafruit_BMP280.h>)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(MESHTASTIC_BME680_HEADER)
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && (__has_include(<bsec2.h>) || __has_include(<Adafruit_BME680.h>))
|
||||||
|
|
||||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||||
#include "BME680Sensor.h"
|
#include "BME680Sensor.h"
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {}
|
BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {}
|
||||||
|
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
int32_t BME680Sensor::runOnce()
|
int32_t BME680Sensor::runOnce()
|
||||||
{
|
{
|
||||||
if (!bme680.run()) {
|
if (!bme680.run()) {
|
||||||
@@ -18,13 +18,13 @@ int32_t BME680Sensor::runOnce()
|
|||||||
}
|
}
|
||||||
return 35;
|
return 35;
|
||||||
}
|
}
|
||||||
#endif // defined(MESHTASTIC_BME680_BSEC2_SUPPORTED)
|
#endif
|
||||||
|
|
||||||
bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
||||||
{
|
{
|
||||||
status = 0;
|
status = 0;
|
||||||
|
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
if (!bme680.begin(dev->address.address, *bus))
|
if (!bme680.begin(dev->address.address, *bus))
|
||||||
checkStatus("begin");
|
checkStatus("begin");
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
|||||||
|
|
||||||
status = 1;
|
status = 1;
|
||||||
|
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
|
|
||||||
initI2CSensor();
|
initI2CSensor();
|
||||||
return status;
|
return status;
|
||||||
@@ -64,7 +64,7 @@ bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
|||||||
|
|
||||||
bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||||
{
|
{
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
if (bme680.getData(BSEC_OUTPUT_RAW_PRESSURE).signal == 0)
|
if (bme680.getData(BSEC_OUTPUT_RAW_PRESSURE).signal == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -98,11 +98,11 @@ bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
|||||||
measurement->variant.environment_metrics.barometric_pressure = bme680->readPressure() / 100.0F;
|
measurement->variant.environment_metrics.barometric_pressure = bme680->readPressure() / 100.0F;
|
||||||
measurement->variant.environment_metrics.gas_resistance = bme680->readGas() / 1000.0;
|
measurement->variant.environment_metrics.gas_resistance = bme680->readGas() / 1000.0;
|
||||||
|
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
void BME680Sensor::loadState()
|
void BME680Sensor::loadState()
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
@@ -179,6 +179,6 @@ void BME680Sensor::checkStatus(const char *functionName)
|
|||||||
else if (bme680.sensor.status > BME68X_OK)
|
else if (bme680.sensor.status > BME68X_OK)
|
||||||
LOG_WARN("%s BME68X code: %d", functionName, bme680.sensor.status);
|
LOG_WARN("%s BME68X code: %d", functionName, bme680.sensor.status);
|
||||||
}
|
}
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(MESHTASTIC_BME680_HEADER)
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && (__has_include(<bsec2.h>) || __has_include(<Adafruit_BME680.h>))
|
||||||
|
|
||||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||||
#include "TelemetrySensor.h"
|
#include "TelemetrySensor.h"
|
||||||
|
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
#include <bme68xLibrary.h>
|
#include <bme68xLibrary.h>
|
||||||
#include <bsec2.h>
|
#include <bsec2.h>
|
||||||
#else
|
#else
|
||||||
#include <Adafruit_BME680.h>
|
#include <Adafruit_BME680.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
|
|
||||||
#define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // That's 6 hours worth of millis()
|
#define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // That's 6 hours worth of millis()
|
||||||
|
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
const uint8_t bsec_config[] = {
|
const uint8_t bsec_config[] = {
|
||||||
#include "config/bme680/bme680_iaq_33v_3s_4d/bsec_iaq.txt"
|
#include "config/bme680/bme680_iaq_33v_3s_4d/bsec_iaq.txt"
|
||||||
};
|
};
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
class BME680Sensor : public TelemetrySensor
|
class BME680Sensor : public TelemetrySensor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
Bsec2 bme680;
|
Bsec2 bme680;
|
||||||
#else
|
#else
|
||||||
using BME680Ptr = std::unique_ptr<Adafruit_BME680>;
|
using BME680Ptr = std::unique_ptr<Adafruit_BME680>;
|
||||||
@@ -31,10 +31,10 @@ class BME680Sensor : public TelemetrySensor
|
|||||||
static BME680Ptr makeBME680(TwoWire *bus) { return std::make_unique<Adafruit_BME680>(bus); }
|
static BME680Ptr makeBME680(TwoWire *bus) { return std::make_unique<Adafruit_BME680>(bus); }
|
||||||
|
|
||||||
BME680Ptr bme680;
|
BME680Ptr bme680;
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
const char *bsecConfigFileName = "/prefs/bsec.dat";
|
const char *bsecConfigFileName = "/prefs/bsec.dat";
|
||||||
uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
|
uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
|
||||||
uint8_t accuracy = 0;
|
uint8_t accuracy = 0;
|
||||||
@@ -51,13 +51,13 @@ class BME680Sensor : public TelemetrySensor
|
|||||||
void loadState();
|
void loadState();
|
||||||
void updateState();
|
void updateState();
|
||||||
void checkStatus(const char *functionName);
|
void checkStatus(const char *functionName);
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BME680Sensor();
|
BME680Sensor();
|
||||||
#if MESHTASTIC_BME680_BSEC2_SUPPORTED == 1
|
#if __has_include(<bsec2.h>)
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
#endif // MESHTASTIC_BME680_BSEC2_SUPPORTED
|
#endif
|
||||||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||||
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
|
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user