[platformio]
default_envs = arduino-2, arduino-3, esp8266, raspberrypi
lib_dir = .
; src_dir = examples/AsyncResponseStream
; src_dir = examples/AsyncTunnel
; src_dir = examples/Auth
; src_dir = examples/CaptivePortal
; src_dir = examples/CatchAllHandler
; src_dir = examples/ChunkResponse
; src_dir = examples/ChunkRetryResponse
; src_dir = examples/CORS
; src_dir = examples/EndBegin
; src_dir = examples/Filters
; src_dir = examples/FlashResponse
; src_dir = examples/HeaderManipulation
; src_dir = examples/Json
; src_dir = examples/LargeResponse
; src_dir = examples/Logging
; src_dir = examples/MessagePack
; src_dir = examples/Middleware
; src_dir = examples/Params
; src_dir = examples/PartitionDownloader
src_dir = examples/PerfTests
; src_dir = examples/RateLimit
; src_dir = examples/Redirect
; src_dir = examples/RequestContinuation
; src_dir = examples/RequestContinuationComplete
; src_dir = examples/ResumableDownload
; src_dir = examples/Rewrite
; src_dir = examples/ServerSentEvents
; src_dir = examples/ServerState
; src_dir = examples/SkipServerMiddleware
; src_dir = examples/SlowChunkResponse
; src_dir = examples/StaticFile
; src_dir = examples/Templates
; src_dir = examples/Upload
; src_dir = examples/UploadFlash
; src_dir = examples/URIMatcher
; src_dir = examples/URIMatcherTest
; src_dir = examples/WebSocket
; src_dir = examples/WebSocketEasy

[env]
framework = arduino
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.34/platform-espressif32.zip
board = esp32dev
build_flags =
  -Og
  -Wall -Wextra
  -Wno-unused-parameter
  ; -D CONFIG_ARDUHAL_LOG_COLORS
  -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
  -D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000
  -D CONFIG_ASYNC_TCP_PRIORITY=10
  -D CONFIG_ASYNC_TCP_QUEUE_SIZE=64
  -D CONFIG_ASYNC_TCP_RUNNING_CORE=1
  -D CONFIG_ASYNC_TCP_STACK_SIZE=4096
  ; -D ASYNCWEBSERVER_REGEX=1
  ; -D CONFIG_ASYNC_TCP_USE_WDT=0
  ; -D CONFIG_ARDUHAL_LOG_COLORS
  ; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
  ; -D USE_ESP_IDF_LOG=1
  ; -D TAG=\"core\"
  ; -D LOG_LOCAL_LEVEL=ESP_LOG_VERBOSE
  ; -D ASYNCWEBSERVER_LOG_DEBUG
upload_protocol = esptool
monitor_speed = 115200
monitor_filters = esp32_exception_decoder, log2file
; monitor_filters = esp8266_exception_decoder, log2file
lib_compat_mode = strict
lib_ldf_mode = chain
lib_deps =
  bblanchon/ArduinoJson @ 7.4.2
  ; bblanchon/ArduinoJson @ 6.21.5
  ; bblanchon/ArduinoJson @ 5.13.4
  ESP32Async/AsyncTCP @ 3.4.9
board_build.partitions = partitions-4MB.csv
board_build.filesystem = littlefs

; PLATFORMS (ESP32, ESP8266, Raspberry, LibreTiny)

[env:arduino-2]
platform = espressif32@6.12.0

[env:arduino-3]
; board = esp32-p4
; board = esp32-h2-devkitm-1

[env:esp8266]
platform = espressif8266
; board = huzzah
board = d1_mini
lib_deps =
  bblanchon/ArduinoJson @ 7.4.2
  ESP32Async/ESPAsyncTCP @ 2.0.0

[env:raspberrypi]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#c7502925e3b08af70e9f924d54ab9d00a7e64781
board = rpipicow
board_build.core = earlephilhower
lib_deps =
  bblanchon/ArduinoJson @ 7.3.0
  ayushsharma82/RPAsyncTCP@^1.3.2
lib_ignore =
  lwIP_ESPHost
build_flags = ${env.build_flags}
  -Wno-missing-field-initializers

[env:libretiny]
platform = libretiny @ ^1.9.1
board = generic-bk7231n-qfn32-tuya
; board = generic-rtl8710bn-2mb-788k
lib_compat_mode = off
lib_deps =
  ESP32Async/AsyncTCP @ 3.4.3
; use FreeRTOS v9.0.0 for RTL8710BN
; (BK7231 already uses it)
custom_versions.freertos = 9.0.0

; SPECIFIC ENVS (for testing various configurations)

[env:arduino-2-esp-idf-log]
platform = espressif32@6.12.0
build_flags =
  ${env.build_flags}
  -D USE_ESP_IDF_LOG=1
  -D TAG=\"core\"

[env:arduino-3-esp-idf-log]
build_flags =
  ${env.build_flags}
  -D USE_ESP_IDF_LOG=1

[env:no-json]
lib_deps =
  ESP32Async/AsyncTCP @ 3.4.9

[env:latest-asynctcp]
lib_deps =
  https://github.com/ESP32Async/AsyncTCP

[env:no-chunk-inflight]
build_flags = ${env.build_flags}
  -D ASYNCWEBSERVER_USE_CHUNK_INFLIGHT=0

[env:regex]
build_flags = ${env.build_flags}
  -D ASYNCWEBSERVER_REGEX=1

[env:AsyncTCPSock]
lib_deps =
  https://github.com/ESP32Async/AsyncTCPSock/archive/refs/tags/v1.0.3-dev.zip
build_flags = ${env.build_flags}

;  PLATFORM CI (ESP32, ESP8266, Raspberry, LibreTiny)

[env:ci-arduino-2]
platform = espressif32@6.12.0
board = ${sysenv.PIO_BOARD}

[env:ci-arduino-3]
board = ${sysenv.PIO_BOARD}

[env:ci-esp8266]
platform = espressif8266
board = ${sysenv.PIO_BOARD}
lib_deps =
  bblanchon/ArduinoJson @ 7.4.2
  ESP32Async/ESPAsyncTCP @ 2.0.0

[env:ci-raspberrypi]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#c7502925e3b08af70e9f924d54ab9d00a7e64781
board = ${sysenv.PIO_BOARD}
board_build.core = earlephilhower
lib_deps =
  bblanchon/ArduinoJson @ 7.3.0
  ayushsharma82/RPAsyncTCP@^1.3.2
lib_ignore =
  lwIP_ESPHost
build_flags = ${env.build_flags}
  -Wno-missing-field-initializers

[env:ci-libretiny]
platform = libretiny @ ^1.9.1
board = ${sysenv.PIO_BOARD}
lib_compat_mode = off
lib_deps =
; add DNS server library for LibreTiny
  DNSServer
  ESP32Async/AsyncTCP @ 3.4.3
custom_versions.freertos = 9.0.0

; CI FOR SPECIFIC CONFIGURATIONS

[env:ci-arduino-2-esp-idf-log]
platform = espressif32@6.12.0
build_flags =
  ${env.build_flags}
  -D USE_ESP_IDF_LOG=1
  -D TAG=\"core\"

[env:ci-arduino-3-esp-idf-log]
build_flags =
  ${env.build_flags}
  -D USE_ESP_IDF_LOG=1

[env:ci-no-json]
lib_deps =
  ESP32Async/AsyncTCP @ 3.4.9

[env:ci-latest-asynctcp]
lib_deps =
  https://github.com/ESP32Async/AsyncTCP

[env:ci-no-chunk-inflight]
build_flags = ${env.build_flags}
  -D ASYNCWEBSERVER_USE_CHUNK_INFLIGHT=1

[env:ci-regex]
build_flags = ${env.build_flags}
  -D ASYNCWEBSERVER_REGEX=1
