[LilyGo_TDeck_Pro]
extends = esp32_base
extra_scripts = post:merge_firmware.py
board = t-deck_pro
board_build.flash_mode = qio
board_build.f_flash = 80000000L
board_build.arduino.memory_type = qio_qspi
board_upload.flash_size = 16MB
build_flags =
  ${esp32_base.build_flags}
  ${sensor_base.build_flags}
  -I variants/LilyGo_TDeck_Pro
  -D LilyGo_TDeck_Pro
  -D HAS_GPS=1
  -D BOARD_HAS_PSRAM=1
  -D CORE_DEBUG_LEVEL=1
  -D FORMAT_SPIFFS_IF_FAILED=1
  -D FORMAT_LITTLEFS_IF_FAILED=1
  -D ARDUINO_USB_CDC_ON_BOOT=1
  -D RADIO_CLASS=CustomSX1262
  -D WRAPPER_CLASS=CustomSX1262Wrapper
  -D LORA_TX_POWER=22
  -D SX126X_DIO2_AS_RF_SWITCH
  -D SX126X_CURRENT_LIMIT=140
  -D SX126X_RX_BOOSTED_GAIN=1
  -D SX126X_DIO3_TCXO_VOLTAGE=2.4f
  -D P_LORA_DIO_1=5
  -D P_LORA_NSS=3
  -D P_LORA_RESET=4
  -D P_LORA_BUSY=6
  -D P_LORA_SCLK=36
  -D P_LORA_MISO=47
  -D P_LORA_MOSI=33
  -D P_LORA_EN=46
  -D ENV_INCLUDE_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
  -D PIN_GPS_RX=44
  -D PIN_GPS_TX=43
  -D GPS_BAUD_RATE=38400
  -D ENV_INCLUDE_AHTX0=0
  -D ENV_INCLUDE_BME280=0
  -D ENV_INCLUDE_BMP280=0
  -D ENV_INCLUDE_SHTC3=0
  -D ENV_INCLUDE_SHT4X=0
  -D ENV_INCLUDE_LPS22HB=0
  -D ENV_INCLUDE_INA3221=0
  -D ENV_INCLUDE_INA219=0
  -D ENV_INCLUDE_INA226=0
  -D ENV_INCLUDE_INA260=0
  -D ENV_INCLUDE_MLX90614=0
  -D ENV_INCLUDE_VL53L0X=0
  -D ENV_INCLUDE_BME680=0
  -D ENV_INCLUDE_BMP085=0
  -D USE_EINK
  -D DISPLAY_CLASS=GxEPDDisplay
  -D EINK_DISPLAY_MODEL=GxEPD2_310_GDEQ031T10
  -D EINK_WIDTH=240
  -D EINK_HEIGHT=320
  -D EINK_CS=34
  -D EINK_DC=35
  -D EINK_RST=16
  -D EINK_BUSY=37
  -D EINK_SCLK=36
  -D EINK_MOSI=33
  -D EINK_BL=45
  -D EINK_NOT_HIBERNATE=1
  -D HAS_BQ27220=1
  -D AUTO_SHUTDOWN_MILLIVOLTS=2800
  -D EINK_LIMIT_FASTREFRESH=10
  -D EINK_LIMIT_GHOSTING_PX=2000
  -D DISPLAY_ROTATION=0
  -D EINK_ROTATION=0
  -D EINK_SCALE_X=1.875f
  -D EINK_SCALE_Y=2.5f
  -D EINK_X_OFFSET=0
  -D EINK_Y_OFFSET=5
  -D PIN_DISPLAY_CS=34
  -D PIN_DISPLAY_DC=35
  -D PIN_DISPLAY_RST=16
  -D PIN_DISPLAY_BUSY=37
  -D PIN_DISPLAY_SCLK=36
  -D PIN_DISPLAY_MISO=-1
  -D PIN_DISPLAY_MOSI=33
  -D PIN_DISPLAY_BL=45
  -D PIN_USER_BTN=0
  -D HAS_TOUCHSCREEN=1
  -D CST328_PIN_INT=12
  -D CST328_PIN_RST=38
  -D ARDUINO_LOOP_STACK_SIZE=32768
  -D HAS_MECK_FONTS
build_src_filter = ${esp32_base.build_src_filter}
  +<../variants/LilyGo_TDeck_Pro>
  +<helpers/sensors/*.cpp>
lib_deps =
  ${esp32_base.lib_deps}
  ${sensor_base.lib_deps}
  zinggjm/GxEPD2@^1.5.9
  adafruit/Adafruit GFX Library@^1.11.0
  bitbank2/PNGdec@^1.0.1
  WebServer
  DNSServer
  Update

; ---------------------------------------------------------------------------
; Meck unified builds — one codebase, six variants via build flags
; ---------------------------------------------------------------------------

; Audio + BLE companion (audio-player hardware with BLE phone bridging)
; MAX_CONTACTS=2000 — protocol v11+ sends true capacity in extended DEVICE_INFO field.
; Older apps see 510 (sentinel 0xFF in legacy byte) and still work correctly.
; Contact + sort arrays allocated in PSRAM via BaseChatMesh::initContacts().
[env:meck_audio_ble]
extends = LilyGo_TDeck_Pro
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=2000
  -D MAX_GROUP_CHANNELS=20
  -D BLE_PIN_CODE=123456
  -D OFFLINE_QUEUE_SIZE=256
  -D MECK_AUDIO_VARIANT
  -D MECK_WEB_READER=1
  -D MECK_OTA_UPDATE=1
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
  densaugeo/base64 @ ~1.4.0
  https://github.com/schreibfaul1/ESP32-audioI2S.git#2.0.6
  bitbank2/JPEGDEC
  https://github.com/sh123/esp32_codec2_arduino.git
lib_ignore =
  AsyncTCP
  ESPAsyncWebServer

; Audio + WiFi companion (audio-player hardware with WiFi app bridging)
; No BLE — WiFi companion uses SerialWifiInterface (TCP socket on port 5000).
; Connect via MeshCore web app, meshcore.js, or Python CLI over local network.
; No BLE protocol ceiling on contacts; bumped to 1500 (PSRAM-backed).
; WiFi always on from boot — web reader works without teardown, extra free heap.
; WiFi credentials loaded from SD card at runtime (/web/wifi.cfg).
; Configure via Settings > WiFi Setup, or through the web reader.
[env:meck_audio_wifi]
extends = LilyGo_TDeck_Pro
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=2000
  -D MAX_GROUP_CHANNELS=20
  -D MECK_WIFI_COMPANION=1
  -D TCP_PORT=5000
  -D WIFI_DEBUG_LOGGING=1
  -D OFFLINE_QUEUE_SIZE=256
  -D MECK_AUDIO_VARIANT
  -D MECK_WEB_READER=1
  -D MECK_OTA_UPDATE=1
  -D FIRMWARE_VERSION='"Meck v1.7.WiFi"'
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
  densaugeo/base64 @ ~1.4.0
  https://github.com/schreibfaul1/ESP32-audioI2S.git#2.0.6
  bitbank2/JPEGDEC
  https://github.com/sh123/esp32_codec2_arduino.git
lib_ignore =
  AsyncTCP
  ESPAsyncWebServer
  ESP32 BLE Arduino

; Audio standalone (audio-player hardware, no BLE/WiFi — maximum battery life)
; No MECK_WEB_READER: WiFi power draw conflicts with zero-radio-power design.
; OTA enabled: WiFi AP activates only during user-initiated firmware updates.
; Contacts and sort arrays allocated in PSRAM — 1500 contacts uses ~290KB of 8MB.
[env:meck_audio_standalone]
extends = LilyGo_TDeck_Pro
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=2000
  -D MAX_GROUP_CHANNELS=20
  -D OFFLINE_QUEUE_SIZE=1
  -D MECK_AUDIO_VARIANT
  -D MECK_OTA_UPDATE=1
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
  densaugeo/base64 @ ~1.4.0
  https://github.com/schreibfaul1/ESP32-audioI2S.git#2.0.6
  bitbank2/JPEGDEC
  https://github.com/sh123/esp32_codec2_arduino.git
lib_ignore =
  AsyncTCP
  ESPAsyncWebServer
  ESP32 BLE Arduino

; 4G + BLE companion (4G modem hardware, no audio — GPIO conflict with PCM5102A)
; MAX_CONTACTS=2000 — protocol v11+ sends true capacity in extended DEVICE_INFO field.
; Older apps see 510 (sentinel 0xFF in legacy byte) and still work correctly.
; Contact + sort arrays allocated in PSRAM via BaseChatMesh::initContacts().
[env:meck_4g_ble]
extends = LilyGo_TDeck_Pro
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=2000
  -D MAX_GROUP_CHANNELS=20
  -D BLE_PIN_CODE=123456
  -D OFFLINE_QUEUE_SIZE=256
  -D HAS_4G_MODEM=1
  -D MECK_WEB_READER=1
  -D MECK_OTA_UPDATE=1
  -D FIRMWARE_VERSION='"Meck v1.7.4G"'
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
  densaugeo/base64 @ ~1.4.0
lib_ignore =
  AsyncTCP
  ESPAsyncWebServer
  ESP32-audioI2S
  esp32_codec2_arduinov

; 4G + WiFi companion (4G modem hardware with WiFi app bridging, no audio)
; No BLE — WiFi companion uses SerialWifiInterface (TCP socket on port 5000).
; Connect via MeshCore web app, meshcore.js, or Python CLI over local network.
; WiFi credentials loaded from SD card at runtime (/web/wifi.cfg).
; Configure via Settings > WiFi Setup, or through the web reader.
; Contacts and sort arrays allocated in PSRAM — 1500 contacts uses ~290KB of 8MB.
[env:meck_4g_wifi]
extends = LilyGo_TDeck_Pro
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=2000
  -D MAX_GROUP_CHANNELS=20
  -D MECK_WIFI_COMPANION=1
  -D TCP_PORT=5000
  -D WIFI_DEBUG_LOGGING=1
  -D OFFLINE_QUEUE_SIZE=256
  -D HAS_4G_MODEM=1
  -D MECK_WEB_READER=1
  -D MECK_OTA_UPDATE=1
  -D FIRMWARE_VERSION='"Meck v1.7.4G.WiFi"'
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
  densaugeo/base64 @ ~1.4.0
lib_ignore =
  AsyncTCP
  ESPAsyncWebServer
  ESP32-audioI2S
  esp32_codec2_arduino
  ESP32 BLE Arduino

; 4G standalone (4G modem hardware, no BLE — maximum battery + cellular features)
; No BLE_PIN_CODE: BLE never initializes, saving ~30KB heap + radio power.
; MECK_WEB_READER enabled: works better without BLE (no teardown dance needed,
; more free heap from boot). WiFi-first with cellular PPP fallback (future).
; Contacts and sort arrays allocated in PSRAM — 1500 contacts uses ~290KB of 8MB.
[env:meck_4g_standalone]
extends = LilyGo_TDeck_Pro
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=2000
  -D MAX_GROUP_CHANNELS=20
  -D OFFLINE_QUEUE_SIZE=1
  -D HAS_4G_MODEM=1
  -D MECK_WEB_READER=1
  -D MECK_OTA_UPDATE=1
  -D FIRMWARE_VERSION='"Meck v1.7.4G.SA"'
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
  densaugeo/base64 @ ~1.4.0
lib_ignore =
  AsyncTCP
  ESPAsyncWebServer
  ESP32-audioI2S
  esp32_codec2_arduino
  ESP32 BLE Arduino

  ; ---------------------------------------------------------------------------
; Remote Repeater (T-Deck Pro 4G, cellular MQTT remote management)
;
; MeshCore repeater firmware + A7682E cellular MQTT for remote admin.
; No BLE, no SMS/calls, no companion protocol. All management via MQTT
; or USB serial CLI.
;
; SD card config required: /remote/mqtt.cfg (broker, port, user, pass)
; Optional: /remote/apn.cfg (APN override)
;
; Add this block to the bottom of platformio.ini
; Flash with: pio run -e meck_remote_repeater
; ---------------------------------------------------------------------------
[env:meck_remote_repeater]
extends = LilyGo_TDeck_Pro
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -I examples/simple_repeater
  -D ADMIN_PASSWORD='"admin"'
  -D HAS_4G_MODEM=1
  -D DISABLE_WIFI_OTA=1
  -D MECK_REMOTE_REPEATER=1
  -D MAX_NEIGHBOURS=50
  -D FIRMWARE_VERSION='"Meck RemRptr v0.3"'
  -D FIRMWARE_BUILD_DATE='"5 April 2026"'
  -D RADIOLIB_EXCLUDE_CC1101=1
  -D RADIOLIB_EXCLUDE_NRF24=1
  -D RADIOLIB_EXCLUDE_RF69=1
  -D RADIOLIB_EXCLUDE_SX1231=1
  -D RADIOLIB_EXCLUDE_SX1233=1
  -D RADIOLIB_EXCLUDE_SI443X=1
  -D RADIOLIB_EXCLUDE_RFM2X=1
  -D RADIOLIB_EXCLUDE_SX127X=1
  -D RADIOLIB_EXCLUDE_SX1272=1
  -D RADIOLIB_EXCLUDE_SX1278=1
  -D RADIOLIB_EXCLUDE_STM32WLX=1
  -D RADIOLIB_EXCLUDE_LR11X0=1
  -D RADIOLIB_EXCLUDE_LLCC68=1
  -D RADIOLIB_EXCLUDE_SX128X=1
  -D RADIOLIB_EXCLUDE_AFSK=1
  -D RADIOLIB_EXCLUDE_AX25=1
  -D RADIOLIB_EXCLUDE_HELLSCHREIBER=1
  -D RADIOLIB_EXCLUDE_MORSE=1
  -D RADIOLIB_EXCLUDE_RTTY=1
  -D RADIOLIB_EXCLUDE_SSTV=1
  -D RADIOLIB_EXCLUDE_APRS=1
  -D RADIOLIB_EXCLUDE_LORAWAN=1
  -D RADIOLIB_EXCLUDE_PAGER=1
  -D RADIOLIB_EXCLUDE_FSK4=1
  -D RADIOLIB_EXCLUDE_BELL=1
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
  +<../examples/simple_repeater/*.cpp>
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
lib_ignore =
  ESP32 BLE Arduino
  NimBLE-Arduino
  AsyncTCP
  ESPAsyncWebServer
  AsyncElegantOTA
  ESP32-audioI2S
  esp32_codec2_arduino

[env:meck_wifi_repeater]
extends = LilyGo_TDeck_Pro
build_src_filter = ${LilyGo_TDeck_Pro.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<helpers/ui/GxEPDDisplay.cpp>
  +<../examples/simple_repeater/*.cpp>
build_flags =
  ${LilyGo_TDeck_Pro.build_flags}
  -D FIRMWARE_VERSION='"Meck WiFi Rptr v0.3"'
  -D FIRMWARE_BUILD_DATE='"5 April 2026"'
  -D MAX_NEIGHBOURS=50
  -D MECK_WIFI_REMOTE
  -D MECK_REMOTE_REPEATER=1
  -D DISABLE_WIFI_OTA=1
  -D RADIOLIB_EXCLUDE_CC1101=1
  -D RADIOLIB_EXCLUDE_NRF24=1
  -D RADIOLIB_EXCLUDE_RF69=1
  -D RADIOLIB_EXCLUDE_SX1231=1
  -D RADIOLIB_EXCLUDE_SX1233=1
  -D RADIOLIB_EXCLUDE_SI443X=1
  -D RADIOLIB_EXCLUDE_RFM2X=1
  -D RADIOLIB_EXCLUDE_SX127X=1
  -D RADIOLIB_EXCLUDE_SX1272=1
  -D RADIOLIB_EXCLUDE_SX1278=1
  -D RADIOLIB_EXCLUDE_STM32WLX=1
  -D RADIOLIB_EXCLUDE_LR11X0=1
  -D RADIOLIB_EXCLUDE_LLCC68=1
  -D RADIOLIB_EXCLUDE_SX128X=1
  -D RADIOLIB_EXCLUDE_AFSK=1
  -D RADIOLIB_EXCLUDE_AX25=1
  -D RADIOLIB_EXCLUDE_HELLSCHREIBER=1
  -D RADIOLIB_EXCLUDE_MORSE=1
  -D RADIOLIB_EXCLUDE_RTTY=1
  -D RADIOLIB_EXCLUDE_SSTV=1
  -D RADIOLIB_EXCLUDE_APRS=1
  -D RADIOLIB_EXCLUDE_LORAWAN=1
  -D RADIOLIB_EXCLUDE_PAGER=1
  -D RADIOLIB_EXCLUDE_FSK4=1
  -D RADIOLIB_EXCLUDE_BELL=1
lib_deps =
  ${LilyGo_TDeck_Pro.lib_deps}
  knolleary/PubSubClient@^2.8
lib_ignore =
 ESP32 BLE Arduino
 AsyncTCP
 RPAsyncTCP
 ESPAsyncWebServer
 AsyncElegantOTA
 ESP32-audioI2S
 esp32_codec2_arduino