; PlatformIO Project Configuration File
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = tbeam

extra_configs =
	variants/*/*.ini
	variants/*/*/platformio.ini
	variants/*/diy/*/platformio.ini
	src/graphics/niche/InkHUD/PlatformioConfig.ini

description = Meshtastic

[env]
test_build_src = true
extra_scripts =
	pre:bin/platformio-pre.py
	bin/platformio-custom.py
; note: we add src to our include search path so that lmic_project_config can override
; note: TINYGPS_OPTION_NO_CUSTOM_FIELDS is VERY important.  We don't use custom fields and somewhere in that pile
; of code is a heap corruption bug!
; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc
; The Radiolib stuff will speed up building considerably. Exclud all the stuff we dont need.
build_flags = -Wno-missing-field-initializers

	-Wno-format
	-Isrc -Isrc/mesh -Isrc/mesh/generated -Isrc/gps -Isrc/buzz -Wl,-Map,"${platformio.build_dir}"/output.map
	-DUSE_THREAD_NAMES
	-DTINYGPS_OPTION_NO_CUSTOM_FIELDS
	-DPB_ENABLE_MALLOC=1
	-DPB_VALIDATE_UTF8=1
	-DRADIOLIB_EXCLUDE_CC1101=1
	-DRADIOLIB_EXCLUDE_NRF24=1
	-DRADIOLIB_EXCLUDE_RF69=1
	-DRADIOLIB_EXCLUDE_SX1231=1
	-DRADIOLIB_EXCLUDE_SX1233=1
	-DRADIOLIB_EXCLUDE_SI443X=1
	-DRADIOLIB_EXCLUDE_RFM2X=1
	-DRADIOLIB_EXCLUDE_AFSK=1
	-DRADIOLIB_EXCLUDE_BELL=1
	-DRADIOLIB_EXCLUDE_HELLSCHREIBER=1
	-DRADIOLIB_EXCLUDE_MORSE=1
	-DRADIOLIB_EXCLUDE_RTTY=1
	-DRADIOLIB_EXCLUDE_SSTV=1
	-DRADIOLIB_EXCLUDE_AX25=1
	-DRADIOLIB_EXCLUDE_DIRECT_RECEIVE=1
	-DRADIOLIB_EXCLUDE_BELL=1
	-DRADIOLIB_EXCLUDE_PAGER=1
	-DRADIOLIB_EXCLUDE_FSK4=1
	-DRADIOLIB_EXCLUDE_APRS=1
	-DRADIOLIB_EXCLUDE_LORAWAN=1
	-DMESHTASTIC_EXCLUDE_DROPZONE=1
	-DMESHTASTIC_EXCLUDE_REPLYBOT=1
	-DMESHTASTIC_EXCLUDE_REMOTEHARDWARE=1
	-DMESHTASTIC_EXCLUDE_HEALTH_TELEMETRY=1
	-DMESHTASTIC_EXCLUDE_POWERSTRESS=1 ; exclude power stress test module from main firmware
	-DMESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE=1
	-DMESHTASTIC_EXCLUDE_POWERMON=1
	-DMESHTASTIC_EXCLUDE_STATUS=1
	-D MAX_THREADS=40 ; As we've split modules, we have more threads to manage
	#-DBUILD_EPOCH=$UNIX_TIME ; set in platformio-custom.py now
	#-D OLED_PL=1
	#-D DEBUG_HEAP=1 ; uncomment to add free heap space / memory leak debugging logs
	#-D DEBUG_LOOP_TIMING=1 ; uncomment to add main loop timing logs

monitor_speed = 115200
monitor_filters = direct
lib_deps =
	# renovate: datasource=git-refs depName=meshtastic-esp8266-oled-ssd1306 packageName=https://github.com/meshtastic/esp8266-oled-ssd1306 gitBranch=master
	https://github.com/meshtastic/esp8266-oled-ssd1306/archive/2e26010040e028baee72e2093402fa7b3c59e430.zip
	# renovate: datasource=git-refs depName=meshtastic-OneButton packageName=https://github.com/meshtastic/OneButton gitBranch=master
	https://github.com/meshtastic/OneButton/archive/fa352d668c53f290cfa480a5f79ad422cd828c70.zip
	# renovate: datasource=git-refs depName=meshtastic-arduino-fsm packageName=https://github.com/meshtastic/arduino-fsm gitBranch=master
	https://github.com/meshtastic/arduino-fsm/archive/7db3702bf0cfe97b783d6c72595e3f38e0b19159.zip
	# renovate: datasource=git-refs depName=meshtastic-TinyGPSPlus packageName=https://github.com/meshtastic/TinyGPSPlus gitBranch=master
	https://github.com/meshtastic/TinyGPSPlus/archive/71a82db35f3b973440044c476d4bcdc673b104f4.zip
	# renovate: datasource=git-refs depName=meshtastic-ArduinoThread packageName=https://github.com/meshtastic/ArduinoThread gitBranch=master
	https://github.com/meshtastic/ArduinoThread/archive/b841b0415721f1341ea41cccfb4adccfaf951567.zip
	# renovate: datasource=github-tags depName=Nanopb packageName=nanopb/nanopb
	https://github.com/nanopb/nanopb/archive/refs/tags/nanopb-0.4.9.1.zip
	# renovate: datasource=github-tags depName=ErriezCRC32 packageName=Erriez/ErriezCRC32
	https://github.com/Erriez/ErriezCRC32/archive/refs/tags/1.0.1.zip

; Used for the code analysis in PIO Home / Inspect
check_tool = cppcheck
check_skip_packages = yes
check_flags =
	-DAPP_VERSION=1.0.0
	--suppressions-list=suppressions.txt
	--inline-suppr

; Common settings for conventional (non Portduino) Arduino targets
[arduino_base]
framework = arduino
lib_deps =
	${env.lib_deps}
	# renovate: datasource=github-tags depName=NonBlockingRTTTL packageName=end2endzone/NonBlockingRTTTL
	https://github.com/end2endzone/NonBlockingRTTTL/archive/refs/tags/1.4.0.zip
build_unflags =
	-std=c++11
	-std=gnu++11
build_flags = ${env.build_flags} -Os
	-std=gnu++17
build_src_filter = ${env.build_src_filter} -<platform/portduino/> -<graphics/niche/>

; Common libs for communicating over TCP/IP networks such as MQTT
[networking_base]
lib_deps =
	# renovate: datasource=github-tags depName=TBPubSubClient packageName=thingsboard/pubsubclient
	https://github.com/thingsboard/pubsubclient/archive/refs/tags/v2.12.1.zip
	# renovate: datasource=github-tags depName=NTPClient packageName=arduino-libraries/NTPClient
	https://github.com/arduino-libraries/NTPClient/archive/refs/tags/3.2.1.zip

; Extra TCP/IP networking libs for supported devices
[networking_extra]
lib_deps =
	# renovate: datasource=github-tags depName=Syslog packageName=arcao/Syslog
	https://github.com/arcao/Syslog/archive/refs/tags/v2.0.zip

[radiolib_base]
lib_deps =
	# renovate: datasource=github-tags depName=RadioLib packageName=jgromes/RadioLib
	https://github.com/jgromes/RadioLib/archive/refs/tags/7.6.0.zip

[device-ui_base]
lib_deps =
	# renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master
	https://github.com/meshtastic/device-ui/archive/34e96d298e78ddf28b7c7e0e82b7bea503abafc3.zip

; Common libs for environmental measurements in telemetry module
[environmental_base]
lib_deps =
	# renovate: datasource=github-tags depName=Adafruit BusIO packageName=adafruit/Adafruit_BusIO
	https://github.com/adafruit/Adafruit_BusIO/archive/refs/tags/1.17.4.zip
	# renovate: datasource=github-tags depName=Adafruit Unified Sensor packageName=adafruit/Adafruit_Sensor
	https://github.com/adafruit/Adafruit_Sensor/archive/refs/tags/1.1.15.zip
	# renovate: datasource=github-tags depName=Adafruit GFX packageName=adafruit/Adafruit-GFX-Library
	https://github.com/adafruit/Adafruit-GFX-Library/archive/refs/tags/1.12.6.zip
	# renovate: datasource=github-tags depName=NeoPixel packageName=adafruit/Adafruit_NeoPixel
	https://github.com/adafruit/Adafruit_NeoPixel/archive/1.15.5.zip
	# renovate: datasource=github-tags depName=Adafruit SSD1306 packageName=adafruit/Adafruit_SSD1306
	https://github.com/adafruit/Adafruit_SSD1306/archive/2.5.17.zip
	# renovate: datasource=github-tags depName=Adafruit BMP280 packageName=adafruit/Adafruit_BMP280_Library
	https://github.com/adafruit/Adafruit_BMP280_Library/archive/refs/tags/3.0.0.zip
	# renovate: datasource=github-tags depName=Adafruit BMP085 packageName=adafruit/Adafruit-BMP085-Library
	https://github.com/adafruit/Adafruit-BMP085-Library/archive/refs/tags/1.2.4.zip
	# renovate: datasource=github-tags depName=Adafruit BME280 packageName=adafruit/Adafruit_BME280_Library
	https://github.com/adafruit/Adafruit_BME280_Library/archive/refs/tags/2.3.0.zip
	# renovate: datasource=github-tags depName=Adafruit DPS310 packageName=adafruit/Adafruit_DPS310
	https://github.com/adafruit/Adafruit_DPS310/archive/refs/tags/1.1.6.zip
	# renovate: datasource=github-tags depName=Adafruit SH110x packageName=adafruit/Adafruit_SH110x
	https://github.com/adafruit/Adafruit_SH110x/archive/refs/tags/2.1.14.zip
	# renovate: datasource=github-tags depName=Adafruit MCP9808 packageName=adafruit/Adafruit_MCP9808_Library
	https://github.com/adafruit/Adafruit_MCP9808_Library/archive/refs/tags/2.0.2.zip
	# renovate: datasource=github-tags depName=Adafruit INA260 packageName=adafruit/Adafruit_INA260
	https://github.com/adafruit/Adafruit_INA260/archive/refs/tags/1.5.3.zip
	# renovate: datasource=github-tags depName=Adafruit INA219 packageName=adafruit/Adafruit_INA219
	https://github.com/adafruit/Adafruit_INA219/archive/refs/tags/1.2.3.zip
	# renovate: datasource=github-tags depName=Adafruit MPU6050 packageName=adafruit/Adafruit_MPU6050
	https://github.com/adafruit/Adafruit_MPU6050/archive/refs/tags/2.2.9.zip
	# renovate: datasource=github-tags depName=Adafruit LIS3DH packageName=adafruit/Adafruit_LIS3DH
	https://github.com/adafruit/Adafruit_LIS3DH/archive/refs/tags/1.3.0.zip
	# renovate: datasource=github-tags depName=Adafruit AHTX0 packageName=adafruit/Adafruit_AHTX0
	https://github.com/adafruit/Adafruit_AHTX0/archive/refs/tags/2.0.6.zip
	# renovate: datasource=github-tags depName=Adafruit LSM6DS packageName=adafruit/Adafruit_LSM6DS
	https://github.com/adafruit/Adafruit_LSM6DS/archive/refs/tags/4.7.4.zip
	# renovate: datasource=github-tags depName=Adafruit TSL2591 packageName=adafruit/Adafruit_TSL2591_Library
	https://github.com/adafruit/Adafruit_TSL2591_Library/archive/refs/tags/1.4.5.zip
	# renovate: datasource=github-tags depName=EmotiBit MLX90632 packageName=emotibit/EmotiBit_MLX90632
	https://github.com/EmotiBit/EmotiBit_MLX90632/archive/refs/tags/v1.0.8.zip
	# renovate: datasource=github-tags depName=Adafruit MLX90614 packageName=adafruit/Adafruit_MLX90614
	https://github.com/adafruit/Adafruit-MLX90614-Library/archive/refs/tags/2.1.6.zip
	# renovate: datasource=git-refs depName=INA3221 packageName=https://github.com/sgtwilko/INA3221 gitBranch=FixOverflow
	https://github.com/sgtwilko/INA3221/archive/bb03d7e9bfcc74fc798838a54f4f99738f29fc6a.zip
	# renovate: datasource=github-tags depName=QMC5883L Compass packageName=mprograms/QMC5883LCompass
	https://github.com/mprograms/QMC5883LCompass/archive/refs/tags/v1.2.3.zip
	# renovate: datasource=github-tags depName=DFRobot_RTU packageName=dfrobot/DFRobot_RTU
	https://github.com/DFRobot/DFRobot_RTU/archive/refs/tags/V1.0.6.zip
	# renovate: datasource=git-refs depName=DFRobot_RainfallSensor packageName=https://github.com/DFRobot/DFRobot_RainfallSensor gitBranch=master
	https://github.com/DFRobot/DFRobot_RainfallSensor/archive/38fea5e02b40a5430be6dab39a99a6f6347d667e.zip
	# renovate: datasource=github-tags depName=INA226 packageName=robtillaart/INA226
	https://github.com/RobTillaart/INA226/archive/refs/tags/0.6.6.zip
	# renovate: datasource=github-tags depName=SparkFun MAX3010x packageName=sparkfun/SparkFun_MAX3010x_Sensor_Library
	https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library/archive/refs/tags/v1.1.2.zip
	# renovate: datasource=github-tags depName=SparkFun 9DoF IMU Breakout ICM 20948 packageName=sparkfun/SparkFun_ICM-20948_ArduinoLibrary
	https://github.com/sparkfun/SparkFun_ICM-20948_ArduinoLibrary/archive/refs/tags/v1.3.2.zip
	# renovate: datasource=github-tags depName=TDK InvenSense ICM42670P packageName=tdk-invn-oss/motion.arduino.ICM42670P
	https://github.com/tdk-invn-oss/motion.arduino.ICM42670P/archive/refs/tags/1.0.8.zip
	# renovate: datasource=github-tags depName=Adafruit LTR390 Library packageName=adafruit/Adafruit_LTR390
	https://github.com/adafruit/Adafruit_LTR390/archive/refs/tags/1.1.2.zip
	# renovate: datasource=github-tags depName=Adafruit PCT2075 packageName=adafruit/Adafruit_PCT2075
	https://github.com/adafruit/Adafruit_PCT2075/archive/refs/tags/1.0.6.zip
	# renovate: datasource=github-tags depName=DFRobot_BMM150 packageName=dfrobot/DFRobot_BMM150
	https://github.com/DFRobot/DFRobot_BMM150/archive/refs/tags/V1.0.0.zip
	# renovate: datasource=github-tags depName=SparkFun MMC5983MA Magnetometer packageName=sparkfun/SparkFun_MMC5983MA_Magnetometer_Arduino_Library
	https://github.com/sparkfun/SparkFun_MMC5983MA_Magnetometer_Arduino_Library/archive/v1.1.5.zip
	# renovate: datasource=github-tags depName=Adafruit_TSL2561 packageName=adafruit/Adafruit_TSL2561
	https://github.com/adafruit/Adafruit_TSL2561/archive/refs/tags/1.1.3.zip
	# renovate: datasource=github-tags depName=BH1750_WE packageName=wollewald/BH1750_WE
	https://github.com/wollewald/BH1750_WE/archive/refs/tags/1.1.10.zip

; Common environmental sensor libraries (not included in native / portduino)
[environmental_extra_common]
lib_deps =
	# renovate: datasource=github-tags depName=Adafruit BMP3XX packageName=adafruit/Adafruit_BMP3XX
	https://github.com/adafruit/Adafruit_BMP3XX/archive/refs/tags/2.1.6.zip
	# renovate: datasource=github-tags depName=Adafruit MAX1704X packageName=adafruit/Adafruit_MAX1704X
	https://github.com/adafruit/Adafruit_MAX1704X/archive/refs/tags/1.0.3.zip
	# renovate: datasource=github-tags depName=Adafruit SHTC3 packageName=adafruit/Adafruit_SHTC3
	https://github.com/adafruit/Adafruit_SHTC3/archive/refs/tags/1.0.2.zip
	# renovate: datasource=github-tags depName=Adafruit LPS2X packageName=adafruit/Adafruit_LPS2X
	https://github.com/adafruit/Adafruit_LPS2X/archive/refs/tags/2.0.6.zip
	# renovate: datasource=github-tags depName=Adafruit SHT31 packageName=adafruit/Adafruit_SHT31
	https://github.com/adafruit/Adafruit_SHT31/archive/refs/tags/2.2.2.zip
	# renovate: datasource=github-tags depName=Adafruit VEML7700 packageName=adafruit/Adafruit_VEML7700
	https://github.com/adafruit/Adafruit_VEML7700/archive/refs/tags/2.1.6.zip
	# renovate: datasource=github-tags depName=Adafruit SHT4x packageName=adafruit/Adafruit_SHT4X
	https://github.com/adafruit/Adafruit_SHT4X/archive/refs/tags/1.0.5.zip
	# renovate: datasource=github-tags depName=SparkFun Qwiic Scale NAU7802 packageName=sparkfun/SparkFun_Qwiic_Scale_NAU7802_Arduino_Library
	https://github.com/sparkfun/SparkFun_Qwiic_Scale_NAU7802_Arduino_Library/archive/refs/tags/v1.0.6.zip
	# renovate: datasource=custom.pio depName=ClosedCube OPT3001 packageName=closedcube/library/ClosedCube OPT3001
	closedcube/ClosedCube OPT3001@1.1.2
	# renovate: datasource=git-refs depName=meshtastic-DFRobot_LarkWeatherStation packageName=https://github.com/meshtastic/DFRobot_LarkWeatherStation gitBranch=master
	https://github.com/meshtastic/DFRobot_LarkWeatherStation/archive/4de3a9cadef0f6a5220a8a906cf9775b02b0040d.zip
	# renovate: datasource=github-tags depName=Sensirion Core packageName=sensirion/arduino-core
	https://github.com/Sensirion/arduino-core/archive/refs/tags/0.7.3.zip
	# renovate: datasource=github-tags depName=Sensirion I2C SCD4x packageName=sensirion/arduino-i2c-scd4x
	https://github.com/Sensirion/arduino-i2c-scd4x/archive/refs/tags/1.1.0.zip
	# renovate: datasource=github-tags depName=Sensirion I2C SFA3x packageName=sensirion/arduino-i2c-sfa3x
	https://github.com/Sensirion/arduino-i2c-sfa3x/archive/refs/tags/1.0.0.zip
	# renovate: datasource=github-tags depName=Sensirion I2C SCD30 packageName=sensirion/arduino-i2c-scd30
	https://github.com/Sensirion/arduino-i2c-scd30/archive/refs/tags/1.0.0.zip

; Environmental sensors with BSEC2 (Bosch proprietary IAQ)
[environmental_extra]
lib_deps =
	${environmental_extra_common.lib_deps}
	# renovate: datasource=github-tags depName=Bosch BSEC2 packageName=boschsensortec/Bosch-BSEC2-Library
	https://github.com/boschsensortec/Bosch-BSEC2-Library/archive/refs/tags/1.10.2610.zip
	# renovate: datasource=github-tags depName=Bosch BME68x packageName=boschsensortec/Bosch-BME68x-Library
	https://github.com/boschsensortec/Bosch-BME68x-Library/archive/refs/tags/v1.3.40408.zip

; Environmental sensors without BSEC (saves ~3.5KB DRAM for original ESP32 targets)
[environmental_extra_no_bsec]
lib_deps =
	${environmental_extra_common.lib_deps}
	# renovate: datasource=github-tags depName=Adafruit_BME680 packageName=adafruit/Adafruit_BME680
	https://github.com/adafruit/Adafruit_BME680/archive/refs/tags/2.0.6.zip
