; 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]
default_envs = esp32dev
boards_dir = boards

[env]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.11/platform-espressif32.zip
platform_packages =
framework = arduino, espidf
build_type = release
custom_build = release
board_build.partitions = partitions.csv
build_unflags =
    -DCONFIG_BT_NIMBLE_LOG_LEVEL
    -DCONFIG_BTDM_BLE_SCAN_DUPL
    -Werror=all
    -Wall
build_flags =
	-fexceptions
	-DTLS_CA_MAX_SIZE=2200
	-DTLS_CERT_MAX_SIZE=1500
	-DTLS_KEY_MAX_SIZE=1800
	-DESP_PLATFORM
	-DESP32
	-DARDUINO_ARCH_ESP32
    -DNUKI_NO_WDT_RESET
    -DNUKI_MUTEX_RECURSIVE
    -DCONFIG_BTDM_BLE_SCAN_DUPL=y
    -DCONFIG_ASYNC_TCP_MAX_ACK_TIME=3000
    -DCONFIG_ASYNC_TCP_PRIORITY=10
    -DCONFIG_ASYNC_TCP_QUEUE_SIZE=128
    -DCONFIG_ASYNC_TCP_RUNNING_CORE=0
    -DCONFIG_ASYNC_TCP_STACK_SIZE=4096
    -DWS_MAX_QUEUED_MESSAGES=128
    -Wno-ignored-qualifiers
    -Wno-missing-field-initializers
    -Wno-type-limits
    -Wno-maybe-uninitialized
    -Wno-implicit-fallthrough
    -Wno-unused-result
lib_deps =
    BleScanner=symlink://lib/BleScanner
    esp-nimble-cpp=symlink://lib/esp-nimble-cpp
lib_ignore =
    NimBLE-Arduino
    ESPAsyncTCP-esphome
    AsyncTCP_RP2040W
monitor_speed = 115200
monitor_filters =
	esp32_exception_decoder
	time

[env:esp32dev]
board = esp32dev
extra_scripts = post:pio_package.py
build_flags =
	${env.build_flags}
    -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
	-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
    -DCONFIG_BT_NIMBLE_LOG_LEVEL=0

[env:esp32-c3]
extends = env:esp32dev
board = esp32-c3-devkitc-02

[env:esp32-s3]
extends = env:esp32dev
board = nuki-esp32-s3

[env:esp32-c6]
extends = env:esp32dev
board = esp32-c6-devkitm-1

[env:esp32solo1]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32-2023.10.03.zip
framework = arduino
board = esp32-solo1
extra_scripts = post:pio_package.py
build_flags =
	${env.build_flags}
	-DFRAMEWORK_ARDUINO_SOLO1
    -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
	-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
    -DCONFIG_BT_NIMBLE_LOG_LEVEL=0
lib_deps =
    BleScanner=symlink://lib/BleScanner
lib_ignore =
    esp-nimble-cpp
    NetworkClientSecure
    
[env:esp32dev_dbg]
extends = env:esp32dev
custom_build = debug
build_flags =
	${env.build_flags}
    -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
	-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
    -DCONFIG_BT_NIMBLE_LOG_LEVEL=0
    -DDEBUG_NUKIHUB
	-DDEBUG_SENSE_NUKI
	-DDEBUG_NUKI_COMMAND
	-DDEBUG_NUKI_CONNECT
	-DDEBUG_NUKI_COMMUNICATION
	;-DDEBUG_NUKI_HEX_DATA
	-DDEBUG_NUKI_READABLE_DATA

[env:esp32-c3_dbg]
extends = env:esp32-c3
custom_build = debug
build_flags =
	${env.build_flags}
    -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
	-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
    -DCONFIG_BT_NIMBLE_LOG_LEVEL=0
    -DDEBUG_NUKIHUB
	-DDEBUG_SENSE_NUKI
	-DDEBUG_NUKI_COMMAND
	-DDEBUG_NUKI_CONNECT
	-DDEBUG_NUKI_COMMUNICATION
	;-DDEBUG_NUKI_HEX_DATA
	-DDEBUG_NUKI_READABLE_DATA

[env:esp32-c6_dbg]
extends = env:esp32-c6
custom_build = debug
build_flags =
	${env.build_flags}
    -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
	-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
    -DCONFIG_BT_NIMBLE_LOG_LEVEL=0
    -DDEBUG_NUKIHUB
	-DDEBUG_SENSE_NUKI
	-DDEBUG_NUKI_COMMAND
	-DDEBUG_NUKI_CONNECT
	-DDEBUG_NUKI_COMMUNICATION
	;-DDEBUG_NUKI_HEX_DATA
	-DDEBUG_NUKI_READABLE_DATA

[env:esp32-s3_dbg]
extends = env:esp32-s3
custom_build = debug
build_flags =
	${env.build_flags}
    -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
	-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
    -DCONFIG_BT_NIMBLE_LOG_LEVEL=0
    -DDEBUG_NUKIHUB
	-DDEBUG_SENSE_NUKI
	-DDEBUG_NUKI_COMMAND
	-DDEBUG_NUKI_CONNECT
	-DDEBUG_NUKI_COMMUNICATION
	;-DDEBUG_NUKI_HEX_DATA
	-DDEBUG_NUKI_READABLE_DATA

[env:esp32solo1_dbg]
extends = env:esp32solo1
custom_build = debug
build_flags =
	${env.build_flags}
    -DFRAMEWORK_ARDUINO_SOLO1
    -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
	-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
    -DDEBUG_NUKIHUB
	-DDEBUG_SENSE_NUKI
	-DDEBUG_NUKI_COMMAND
	-DDEBUG_NUKI_CONNECT
	-DDEBUG_NUKI_COMMUNICATION
	;-DDEBUG_NUKI_HEX_DATA
	-DDEBUG_NUKI_READABLE_DATA