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

[env]
version                 = 1.6.0-passiveble
framework               = arduino
lib_deps                = ESP32Async/AsyncTCP@^3.4.10
                          ESP32Async/ESPAsyncWebServer@^3.9.4
                          mathieucarbou/MycilaWebSerial@^8.2.0
                          bblanchon/ArduinoJson@^7.4.2
                          ;ihormelnyk/OpenTherm Library@^1.1.5
                          https://github.com/Laxilef/opentherm_library#esp32_timer
                          arduino-libraries/ArduinoMqttClient@^0.1.8
                          gyverlibs/FileData@^1.0.3
                          gyverlibs/GyverPID@^3.3.2
                          gyverlibs/GyverBlinker@^1.1.1
                          pstolarz/OneWireNg@^0.14.1
                          ;milesburton/DallasTemperature@^4.0.5
                          https://github.com/Laxilef/Arduino-Temperature-Control-Library#fix_85c
                          ;laxilef/TinyLogger@^1.1.1
                          https://github.com/Laxilef/TinyLogger#custom_handlers
lib_ignore              = paulstoffregen/OneWire
build_type              = ${secrets.build_type}
build_flags             = -mtext-section-literals
                          -Wno-deprecated-declarations
                          -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 CONFIG_ASYNC_TCP_STACK_SIZE=4096
                          -D ARDUINOJSON_USE_DOUBLE=0
                          -D ARDUINOJSON_USE_LONG_LONG=0
                          -D TINYLOGGER_GLOBAL
                          -D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
                          -D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
                          -D DEFAULT_WEBSERIAL_ENABLED=${secrets.webserial_enabled}
                          -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
board_build.flash_mode  = dio
board_build.filesystem  = littlefs
check_tool              = ;pvs-studio
check_flags             = ;pvs-studio: --analysis-mode=4 --exclude-path=./.pio/libdeps

; Defaults
[esp32_defaults]
platform                = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
platform_packages       = ${env.platform_packages}
board_build.partitions  = esp32_partitions.csv
lib_deps                = ${env.lib_deps}
                          laxilef/ESP32Scheduler@^1.0.1
nimble_lib              = https://github.com/h2zero/NimBLE-Arduino
lib_ignore              = ${env.lib_ignore}
                          BluetoothSerial
                          SimpleBLE
                          ESP RainMaker
                          RainMaker
                          ESP Insights
                          Insights
                          Zigbee
                          Matter
                          OpenThread
                          dsp
custom_component_remove = espressif/esp_hosted
                          espressif/esp_wifi_remote
                          espressif/esp-dsp
                          espressif/esp_modem
                          espressif/esp_rainmaker
                          espressif/rmaker_common
                          espressif/esp_insights
                          espressif/esp_diag_data_store
                          espressif/esp_diagnostics
                          espressif/libsodium
                          espressif/esp-modbus
                          espressif/esp-cbor
                          espressif/esp-sr
                          espressif/esp32-camera
                          espressif/qrcode
                          espressif/esp-zboss-lib
                          espressif/esp-zigbee-lib
                          chmorgan/esp-libhelix-mp3
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
check_tool              = ${env.check_tool}
check_flags             = ${env.check_flags}


; Boards
[env:s2_mini]
extends                 = esp32_defaults
board                   = lolin_s2_mini
build_unflags           = -DARDUINO_USB_MODE=1
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]
extends                 = esp32_defaults
board                   = lolin_s3_mini
lib_deps                = ${esp32_defaults.lib_deps}
                          ${esp32_defaults.nimble_lib}
build_unflags           = -DARDUINO_USB_MODE=1
build_flags             = ${esp32_defaults.build_flags}
                          -D ARDUINO_USB_MODE=0
                          -D ARDUINO_USB_CDC_ON_BOOT=1
                          -D MYNEWT_VAL_BLE_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]
extends                 = esp32_defaults
board                   = lolin_c3_mini
lib_deps                = ${esp32_defaults.lib_deps}
                          ${esp32_defaults.nimble_lib}
build_unflags           = -mtext-section-literals
build_flags             = ${esp32_defaults.build_flags}
                          -D MYNEWT_VAL_BLE_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]
extends                 = esp32_defaults
board                   = nodemcu-32s
lib_deps                = ${esp32_defaults.lib_deps}
                          ${esp32_defaults.nimble_lib}
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:nodemcu_32_160mhz]
extends                 = env:nodemcu_32 
board_build.f_cpu       = 160000000L ; set frequency to 160MHz

[env:d1_mini32]
extends                 = esp32_defaults
board                   = wemos_d1_mini32
lib_deps                = ${esp32_defaults.lib_deps}
                          ${esp32_defaults.nimble_lib}
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]
extends                 = esp32_defaults
board                   = esp32-c6-devkitc-1
lib_deps                = ${esp32_defaults.lib_deps}
                          ${esp32_defaults.nimble_lib}
build_unflags           = -mtext-section-literals
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]
extends                 = esp32_defaults
board                   = lolin_c3_mini
lib_deps                = ${esp32_defaults.lib_deps}
                          ${esp32_defaults.nimble_lib}
build_unflags           = -mtext-section-literals
build_flags             = ${esp32_defaults.build_flags}
                          -D MYNEWT_VAL_BLE_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
