Modify limited to Portduino and RAK4631 only

This commit is contained in:
JaeHwan Jin
2025-11-14 16:41:05 +09:00
parent 52eb9c9f82
commit d88640a134
7 changed files with 39 additions and 35 deletions

View File

@@ -30,8 +30,6 @@ lib_deps=
${radiolib_base.lib_deps}
# renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto
rweather/Crypto@0.4.0
# renovate: datasource=custom.pio depName=Bosch BME68x packageName=boschsensortec/library/BME68x Sensor Library
boschsensortec/BME68x Sensor Library@1.3.40408
lib_ignore =
BluetoothOTA

View File

@@ -136,6 +136,8 @@ lib_deps =
adafruit/Adafruit BMP085 Library@1.2.4
# renovate: datasource=custom.pio depName=Adafruit BME280 packageName=adafruit/library/Adafruit BME280 Library
adafruit/Adafruit BME280 Library@2.3.0
# renovate: datasource=custom.pio depName=Adafruit SHTC3 packageName=adafruit/library/Adafruit SHTC3 Library
adafruit/Adafruit SHTC3 Library@1.0.2
# renovate: datasource=custom.pio depName=Adafruit DPS310 packageName=adafruit/library/Adafruit DPS310
adafruit/Adafruit DPS310@1.1.5
# renovate: datasource=custom.pio depName=Adafruit MCP9808 packageName=adafruit/library/Adafruit MCP9808 Library
@@ -160,8 +162,6 @@ lib_deps =
emotibit/EmotiBit MLX90632@1.0.8
# renovate: datasource=custom.pio depName=Adafruit MLX90614 packageName=adafruit/library/Adafruit MLX90614 Library
adafruit/Adafruit MLX90614 Library@2.1.5
# renovate: datasource=custom.pio depName=Adafruit SHTC3 packageName=adafruit/library/Adafruit SHTC3 Library
adafruit/Adafruit SHTC3 Library@1.0.2
# renovate: datasource=github-tags depName=INA3221 packageName=sgtwilko/INA3221
https://github.com/sgtwilko/INA3221#bb03d7e9bfcc74fc798838a54f4f99738f29fc6a
# renovate: datasource=custom.pio depName=QMC5883L Compass packageName=mprograms/library/QMC5883LCompass

View File

@@ -1,9 +1,11 @@
#include "configuration.h"
#ifndef BME680_HEADER
#if defined(ARCH_PORTDUINO)
#define BME680_HEADER <Adafruit_BME680.h>
#else
#if !defined(BME680_BSEC2_SUPPORTED)
#if defined(RAK_4631)
#define BME680_BSEC2_SUPPORTED 1
#define BME680_HEADER <bsec2.h>
#endif
#endif
#else
#define BME680_BSEC2_SUPPORTED 0
#define BME680_HEADER <Adafruit_BME680.h>
#endif // defined(RAK_4631)
#endif // !defined(BME680_BSEC2_SUPPORTED)

View File

@@ -12,7 +12,7 @@
BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {}
#if !defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
int32_t BME680Sensor::runOnce()
{
if (!bme680.run()) {
@@ -20,13 +20,13 @@ int32_t BME680Sensor::runOnce()
}
return 35;
}
#endif // !defined(ARCH_PORTDUINO)
#endif // defined(BME680_BSEC2_SUPPORTED)
bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{
status = 0;
#if !defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
if (!bme680.begin(dev->address.address, *bus))
checkStatus("begin");
@@ -58,7 +58,7 @@ bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
status = 1;
#endif // !defined(ARCH_PORTDUINO)
#endif // BME680_BSEC2_SUPPORTED
initI2CSensor();
return status;
@@ -66,7 +66,7 @@ bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement)
{
#if !defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
if (bme680.getData(BSEC_OUTPUT_RAW_PRESSURE).signal == 0)
return false;
@@ -100,11 +100,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
#endif // BME680_BSEC2_SUPPORTED
return true;
}
#if !defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
void BME680Sensor::loadState()
{
#ifdef FSCom
@@ -181,6 +181,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 // !defined(ARCH_PORTDUINO)
#endif // BME680_BSEC2_SUPPORTED
#endif

View File

@@ -7,37 +7,36 @@
#include "../mesh/generated/meshtastic/telemetry.pb.h"
#include "TelemetrySensor.h"
#if defined(ARCH_PORTDUINO)
#include <Adafruit_BME680.h>
#include <memory>
#else // defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
#include <bme68xLibrary.h>
#include <bsec2.h>
#endif // defined(ARCH_PORTDUINO)
#else
#include <Adafruit_BME680.h>
#include <memory>
#endif // BME680_BSEC2_SUPPORTED
#define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // That's 6 hours worth of millis()
#if !defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
const uint8_t bsec_config[] = {
#include "config/bme680/bme680_iaq_33v_3s_4d/bsec_iaq.txt"
};
#endif // !defined(ARCH_PORTDUINO)
#endif // BME680_BSEC2_SUPPORTED
class BME680Sensor : public TelemetrySensor
{
private:
#if defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
Bsec2 bme680;
#else
using BME680Ptr = std::unique_ptr<Adafruit_BME680>;
static BME680Ptr makeBME680(TwoWire *bus) { return std::make_unique<Adafruit_BME680>(bus); }
BME680Ptr bme680;
#else
Bsec2 bme680;
#endif // defined(ARCH_PORTDUINO)
#endif // BME680_BSEC2_SUPPORTED
protected:
#if !defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
const char *bsecConfigFileName = "/prefs/bsec.dat";
uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
uint8_t accuracy = 0;
@@ -54,13 +53,13 @@ class BME680Sensor : public TelemetrySensor
void loadState();
void updateState();
void checkStatus(const char *functionName);
#endif // !defined(ARCH_PORTDUINO)
#endif // BME680_BSEC2_SUPPORTED
public:
BME680Sensor();
#if !defined(ARCH_PORTDUINO)
#if BME680_BSEC2_SUPPORTED == 1
virtual int32_t runOnce() override;
#endif // !defined(ARCH_PORTDUINO)
#endif // BME680_BSEC2_SUPPORTED
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
};

View File

@@ -487,8 +487,11 @@ bool MQTT::publish(const char *topic, const uint8_t *payload, size_t length, boo
{
if (moduleConfig.mqtt.proxy_to_client_enabled) {
meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed();
size_t topic_len = strlen(topic);
msg->which_payload_variant = meshtastic_MqttClientProxyMessage_data_tag;
strlcpy(msg->topic, topic, sizeof(msg->topic));
if (strncpy(msg->topic, topic, topic_len) == nullptr) {
msg->topic[sizeof(msg->topic) - 1] = 0;
}
if (length > sizeof(msg->payload_variant.data.bytes))
length = sizeof(msg->payload_variant.data.bytes);
msg->payload_variant.data.size = length;

View File

@@ -24,6 +24,8 @@ lib_deps =
beegee-tokyo/RAK12035_SoilMoisture@^1.0.4
# renovate: datasource=git-refs depName=RAK12034-BMX160 packageName=https://github.com/RAKWireless/RAK12034-BMX160 gitBranch=main
https://github.com/RAKWireless/RAK12034-BMX160/archive/dcead07ffa267d3c906e9ca4a1330ab989e957e2.zip
# renovate: datasource=custom.pio depName=Bosch BME68x packageName=boschsensortec/library/BME68x Sensor Library
boschsensortec/BME68x Sensor Library@1.3.40408
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
; Note: as of 6/2013 the serial/bootloader based programming takes approximately 30 seconds