Files
firmware/variants/esp32/esp32.ini
Ben Meadors b565a07a83 Remove proprietary Bosch BSEC blob; open in-tree IAQ estimator for BME680 (#11381)
* Remove proprietary Bosch BSEC blob; open in-tree IAQ estimator for BME680

BSEC2 cost ~37-39 KB flash and ~4-5 KB static RAM on ~190 of ~240 build
targets, linked whether or not a BME680 was attached, and was a no-source
proprietary archive inside GPLv3 release binaries. The firmware consumed
exactly one BSEC-exclusive output: the IAQ value.

- New BME680IaqEstimator: clean-room log-domain baseline tracker
  (humidity-compensated gas resistance vs a rise-fast/decay-slow ceiling,
  0-500 scale matching the existing UI bands), pure math, unit-tested on
  native (test_bme680_iaq, 15 tests incl. a deep-sleep reboot simulation).
  Warm-up/burn-in progress persists to /prefs/bme680.dat via SafeFile so
  one-sample-per-wake SENSOR nodes converge across reboots; stale
  /prefs/bsec.dat is removed once.
- BME680Sensor: single-path rewrite on Adafruit_BME680 with async
  once-per-minute sampling (~20x lower heater duty than BSEC LP mode),
  a hard 2-minute publish-freshness bound (a dead sensor stops reporting
  instead of freezing its last reading on the wire), and suppression of
  bogus gas_resistance=0 points from heater-unstable cycles.
- platformio.ini: environmental_extra_common/_extra/_no_bsec collapsed
  into one section; Bosch BSEC2 + BME68x deps deleted; per-variant BSEC
  link-path hacks and the TEMPORARY promicro lib_ignore removed.
  nrf52_promicro_diy_tcxo regains BME680 support at 36 KB clear of the
  warm-store cap; rak4631 lands at 75 KB clear.
- EnvironmentTelemetry: iaq rendering gates on has_iaq (a genuine IAQ of
  0 now displays); stale BSEC comments rewritten.
- rak4631 size budgets tightened (113000->108000 RAM, 786000->746000
  flash) to lock in the reclaimed headroom.
- bin/bme680_iaq_replay.cpp: host-side replay harness for tuning the
  estimator against captured BSEC traces (mean abs error + band
  agreement), no reflashing needed.

Measured (develop -> this branch): rak4631 -38.8 KB flash / -4.9 KB RAM;
heltec-v3 -36.4 KB / -4.0 KB; tlora-v2-1-1_6 +1.3 KB (its IAQ
approximation had been dead code since #9663 due to an inverted isfinite
check and now actually runs).

Note: gas_resistance stays kOhm on the wire for fleet compatibility; the
proto comment claiming MOhm gets a separate meshtastic/protobufs docs PR.

* Address CodeRabbit review feedback

- Use Throttle::isWithinTimespanMs for all elapsed-time predicates in
  BME680Sensor per coding guidelines (deadline math for the async reading
  completion stays raw, as it targets an absolute timestamp)
- Make the state file name members static constexpr
- Replay tool: cast uint16_t before %u (default argument promotion), report
  malformed input lines instead of silently skipping, and fail non-zero on
  stream read errors

* Address CodeRabbit nitpicks

- Replace the local clampf helper with std::clamp (meshUtils.h's clamp drags
  in Arduino.h, which would break the estimator's standalone host build that
  the replay harness depends on)
- Trim the replay tool's file header to a two-line summary; the full build,
  capture, and tuning workflow moves to docs/bme680_iaq_replay.md
2026-08-13 13:21:16 -04:00

62 lines
3.0 KiB
INI

; Common settings for ESP32 OG (without suffix)
; See 'esp32_common' for common ESP32-family settings
[esp32_base]
extends = esp32_common
custom_esp32_kind = esp32
build_src_filter =
${esp32_common.build_src_filter}
-<modules/esp32/PaxcounterModule.cpp>
-<mesh/http/>
build_flags =
${esp32_common.build_flags}
-mtext-section-literals
-D ESP32_FORCE_IRAM_MEMSET
-Wl,--wrap=memset
-Wl,--wrap=memcpy
-DMESHTASTIC_EXCLUDE_AUDIO=1
-DMESHTASTIC_EXCLUDE_ACCELEROMETER=1
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
-DMESHTASTIC_EXCLUDE_WEBSERVER=1
; HACK HACK HACK Original ESP32+NimBLE
; These includes need to be done properly somehow.
; Sourced from ~/.platformio/packages/framework-espidf/components/bt/host/nimble/CMakeLists.txt
; Quotes keep Windows packages_dir backslashes intact through POSIX flag parsing
-I"${platformio.packages_dir}/framework-espidf/components/bt/porting/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/porting/nimble/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/port/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/porting/npl/freertos/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/transport/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/services/gap/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/esp-hci/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/services/gatt/include"
-I"${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/util/include"
custom_sdkconfig =
${esp32_common.custom_sdkconfig}
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
'# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set'
'# CONFIG_BTDM_CTRL_MODE_BTDM is not set'
'# CONFIG_BT_BLUEDROID_ENABLED is not set'
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=y
; Overrides esp32_common's lib_deps: adds networking_extra and omits
; esp32_https_server (mesh/http is excluded from this target's build_src_filter)
lib_deps =
${arduino_base.lib_deps}
${networking_base.lib_deps}
${networking_extra.lib_deps}
${radiolib_base.lib_deps}
${environmental_base.lib_deps}
${environmental_extra.lib_deps}
# TODO renovate
https://github.com/mverch67/libpax/archive/6f52ee989301cdabaeef00bcbf93bff55708ce2f.zip
# renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib
lewisxhe/XPowersLib@0.3.3
# renovate: datasource=git-refs depName=meshtastic/Crypto packageName=https://github.com/meshtastic/Crypto gitBranch=main
https://github.com/meshtastic/Crypto/archive/591ff9a690e8168ccb7a36abde8d7783e448d395.zip