; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
;extra_configs = secrets.ini
extra_configs = secrets.default.ini
core_dir = .pio

[env]
version = 1.5.3
framework = arduino
lib_deps = 
	bblanchon/ArduinoJson@^7.3.0
	;ihormelnyk/OpenTherm Library@^1.1.5
	https://github.com/ihormelnyk/opentherm_library#master
	arduino-libraries/ArduinoMqttClient@^0.1.8
	lennarthennigs/ESP Telnet@^2.2
	gyverlibs/FileData@^1.0.2
	gyverlibs/GyverPID@^3.3.2
	gyverlibs/GyverBlinker@^1.1.1
	https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
	laxilef/TinyLogger@^1.1.1
build_type = ${secrets.build_type}
build_flags = 
	-mtext-section-literals
	-D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1
	;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial
	-D BUILD_VERSION='"${this.version}"'
	-D BUILD_ENV='"$PIOENV"'
	-D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
	-D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
	-D DEFAULT_TELNET_ENABLED=${secrets.telnet_enabled}
	-D DEFAULT_TELNET_PORT=${secrets.telnet_port}
	-D DEFAULT_LOG_LEVEL=${secrets.log_level}
	-D DEFAULT_HOSTNAME='"${secrets.hostname}"'
	-D DEFAULT_AP_SSID='"${secrets.ap_ssid}"'
	-D DEFAULT_AP_PASSWORD='"${secrets.ap_password}"'
	-D DEFAULT_STA_SSID='"${secrets.sta_ssid}"'
	-D DEFAULT_STA_PASSWORD='"${secrets.sta_password}"'
	-D DEFAULT_PORTAL_LOGIN='"${secrets.portal_login}"'
	-D DEFAULT_PORTAL_PASSWORD='"${secrets.portal_password}"'
	-D DEFAULT_MQTT_ENABLED=${secrets.mqtt_enabled}
	-D DEFAULT_MQTT_SERVER='"${secrets.mqtt_server}"'
	-D DEFAULT_MQTT_PORT=${secrets.mqtt_port}
	-D DEFAULT_MQTT_USER='"${secrets.mqtt_user}"'
	-D DEFAULT_MQTT_PASSWORD='"${secrets.mqtt_password}"'
	-D DEFAULT_MQTT_PREFIX='"${secrets.mqtt_prefix}"'
upload_speed = 921600
monitor_speed = 115200
;monitor_filters = direct
monitor_filters = 
	esp32_exception_decoder
	esp8266_exception_decoder
board_build.flash_mode = dio
board_build.filesystem = littlefs

; Defaults
[esp8266_defaults]
platform = espressif8266@^4.2.1
lib_deps = 
	${env.lib_deps}
	nrwiersma/ESP8266Scheduler@^1.2
lib_ignore = 
extra_scripts = 
	post:tools/build.py
build_type = ${env.build_type}
build_flags = 
	${env.build_flags}
	-D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
	;-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
	-D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
board_build.ldscript = eagle.flash.4m1m.ld

[esp32_defaults]
;platform = espressif32@^6.7
;platform = https://github.com/platformio/platform-espressif32.git
;platform_packages = 
;  framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5
;  framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.1/esp32-arduino-libs-idf-release_v5.1-33fbade6.zip
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.13/platform-espressif32.zip
platform_packages =
board_build.partitions = esp32_partitions.csv
lib_deps =
	${env.lib_deps}
	laxilef/ESP32Scheduler@^1.0.1
nimble_lib = h2zero/NimBLE-Arduino@^2.1.0
lib_ignore = 
extra_scripts = 
	post:tools/esp32.py
	post:tools/build.py
build_type = ${env.build_type}
build_flags = 
	${env.build_flags}
	-D CORE_DEBUG_LEVEL=0
	-Wl,--wrap=esp_panic_handler


; Boards
[env:d1_mini]
platform = ${esp8266_defaults.platform}
board = d1_mini
lib_deps = ${esp8266_defaults.lib_deps}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags = 
	${esp8266_defaults.build_flags}
	-D DEFAULT_OT_IN_GPIO=4
	-D DEFAULT_OT_OUT_GPIO=5
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
	-D DEFAULT_SENSOR_INDOOR_GPIO=14
	-D DEFAULT_STATUS_LED_GPIO=13
	-D DEFAULT_OT_RX_LED_GPIO=15

[env:d1_mini_lite]
platform = ${esp8266_defaults.platform}
board = d1_mini_lite
lib_deps = ${esp8266_defaults.lib_deps}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags = 
	${esp8266_defaults.build_flags}
	-D DEFAULT_OT_IN_GPIO=4
	-D DEFAULT_OT_OUT_GPIO=5
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
	-D DEFAULT_SENSOR_INDOOR_GPIO=14
	-D DEFAULT_STATUS_LED_GPIO=13
	-D DEFAULT_OT_RX_LED_GPIO=15

[env:d1_mini_pro]
platform = ${esp8266_defaults.platform}
board = d1_mini_pro
lib_deps = ${esp8266_defaults.lib_deps}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags = 
	${esp8266_defaults.build_flags}
	-D DEFAULT_OT_IN_GPIO=4
	-D DEFAULT_OT_OUT_GPIO=5
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
	-D DEFAULT_SENSOR_INDOOR_GPIO=14
	-D DEFAULT_STATUS_LED_GPIO=13
	-D DEFAULT_OT_RX_LED_GPIO=15

[env:nodemcu_8266]
platform = ${esp8266_defaults.platform}
board = nodemcuv2
lib_deps = ${esp8266_defaults.lib_deps}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags = 
	${esp8266_defaults.build_flags}
	-D DEFAULT_OT_IN_GPIO=13
	-D DEFAULT_OT_OUT_GPIO=15
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
	-D DEFAULT_SENSOR_INDOOR_GPIO=4
	-D DEFAULT_STATUS_LED_GPIO=2
	-D DEFAULT_OT_RX_LED_GPIO=16

[env:s2_mini]
platform = ${esp32_defaults.platform}
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_s2_mini
board_build.partitions = ${esp32_defaults.board_build.partitions}
lib_deps = ${esp32_defaults.lib_deps}
lib_ignore = ${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_unflags =
	-DARDUINO_USB_MODE=1
build_type = ${esp32_defaults.build_type}
build_flags = 
	${esp32_defaults.build_flags}
	-D ARDUINO_USB_MODE=0
	-D ARDUINO_USB_CDC_ON_BOOT=1
	-D DEFAULT_OT_IN_GPIO=33
	-D DEFAULT_OT_OUT_GPIO=35
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=9
	-D DEFAULT_SENSOR_INDOOR_GPIO=7
	-D DEFAULT_STATUS_LED_GPIO=11
	-D DEFAULT_OT_RX_LED_GPIO=12

[env:s3_mini] 
platform = ${esp32_defaults.platform}
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_s3_mini
board_build.partitions = ${esp32_defaults.board_build.partitions}
lib_deps = 
	${esp32_defaults.lib_deps}
	${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_unflags =
	-DARDUINO_USB_MODE=1
build_type = ${esp32_defaults.build_type}
build_flags = 
	${esp32_defaults.build_flags}
	-D ARDUINO_USB_MODE=0
	-D ARDUINO_USB_CDC_ON_BOOT=1
	-D CONFIG_BT_NIMBLE_EXT_ADV=1
	-D USE_BLE=1
	-D DEFAULT_OT_IN_GPIO=35
	-D DEFAULT_OT_OUT_GPIO=36
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=13
	-D DEFAULT_SENSOR_INDOOR_GPIO=12
	-D DEFAULT_STATUS_LED_GPIO=11
	-D DEFAULT_OT_RX_LED_GPIO=10

[env:c3_mini] 
platform = ${esp32_defaults.platform}
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_c3_mini
board_build.partitions = ${esp32_defaults.board_build.partitions}
lib_deps = 
	${esp32_defaults.lib_deps}
	${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_unflags = 
	-mtext-section-literals
build_type = ${esp32_defaults.build_type}
build_flags = 
	${esp32_defaults.build_flags}
	-D CONFIG_BT_NIMBLE_EXT_ADV=1
	-D USE_BLE=1
	-D DEFAULT_OT_IN_GPIO=8
	-D DEFAULT_OT_OUT_GPIO=10
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
	-D DEFAULT_SENSOR_INDOOR_GPIO=1
	-D DEFAULT_STATUS_LED_GPIO=4
	-D DEFAULT_OT_RX_LED_GPIO=5

[env:nodemcu_32]
platform = ${esp32_defaults.platform}
platform_packages = ${esp32_defaults.platform_packages}
board = nodemcu-32s
board_build.partitions = ${esp32_defaults.board_build.partitions}
lib_deps = 
	${esp32_defaults.lib_deps}
	${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_type = ${esp32_defaults.build_type}
build_flags = 
	${esp32_defaults.build_flags}
	-D USE_BLE=1
	-D DEFAULT_OT_IN_GPIO=16
	-D DEFAULT_OT_OUT_GPIO=4
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=15
	-D DEFAULT_SENSOR_INDOOR_GPIO=26
	-D DEFAULT_STATUS_LED_GPIO=2
	-D DEFAULT_OT_RX_LED_GPIO=19

[env:d1_mini32]
platform = ${esp32_defaults.platform}
platform_packages = ${esp32_defaults.platform_packages}
board = wemos_d1_mini32
board_build.partitions = ${esp32_defaults.board_build.partitions}
lib_deps = 
	${esp32_defaults.lib_deps}
	${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_type = ${esp32_defaults.build_type}
build_flags = 
	${esp32_defaults.build_flags}
	-D USE_BLE=1
	-D DEFAULT_OT_IN_GPIO=21
	-D DEFAULT_OT_OUT_GPIO=22
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
	-D DEFAULT_SENSOR_INDOOR_GPIO=18
	-D DEFAULT_STATUS_LED_GPIO=2
	-D DEFAULT_OT_RX_LED_GPIO=19

[env:esp32_c6]
platform = ${esp32_defaults.platform}
framework = arduino, espidf
platform_packages = ${esp32_defaults.platform_packages}
board = esp32-c6-devkitm-1
board_build.partitions = ${esp32_defaults.board_build.partitions}
lib_deps = ${esp32_defaults.lib_deps}
lib_ignore = 
	${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_unflags = 
	-mtext-section-literals
build_type = ${esp32_defaults.build_type}
build_flags = 
	${esp32_defaults.build_flags}
	-D USE_BLE=1
	-D DEFAULT_OT_IN_GPIO=15
	-D DEFAULT_OT_OUT_GPIO=23
	-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
	-D DEFAULT_SENSOR_INDOOR_GPIO=0
	-D DEFAULT_STATUS_LED_GPIO=11
	-D DEFAULT_OT_RX_LED_GPIO=10

[env:otthing] 
platform = ${esp32_defaults.platform}
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_c3_mini
board_build.partitions = ${esp32_defaults.board_build.partitions}
lib_deps = 
	${esp32_defaults.lib_deps}
	${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_unflags = 
	-mtext-section-literals
build_type = ${esp32_defaults.build_type}
build_flags = 
	${esp32_defaults.build_flags}
	-D CONFIG_BT_NIMBLE_EXT_ADV=1
	-D USE_BLE=1
	-D DEFAULT_OT_IN_GPIO=3
	-D DEFAULT_OT_OUT_GPIO=1
;	-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
;	-D DEFAULT_SENSOR_INDOOR_GPIO=1
	-D DEFAULT_STATUS_LED_GPIO=8
	-D DEFAULT_OT_RX_LED_GPIO=2
	-D OT_BYPASS_RELAY_GPIO=20
