[LilyGo_TLora_V2_1_1_6]
extends = esp32_base
board = ttgo-lora32-v1  ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276
build_unflags = -Os
build_type = release  ; Set build type to release
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
build_flags =
  ${esp32_base.build_flags}
  ${sensor_base.build_flags}
  -UENV_INCLUDE_GPS
  -I variants/lilygo_tlora_v2_1
  -Os -ffunction-sections -fdata-sections  ; Optimize for size
  -D LILYGO_TLORA  ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276
  -D P_LORA_DIO_0=26    ; SX1276 DIO0 interrupt pin
  -D P_LORA_DIO_1=33    ; SX1276 DIO1 interrupt pin
  -D P_LORA_NSS=18      ; Chip select - SS pin
  -D P_LORA_RESET=14    ; Reset pin
  -D P_LORA_SCLK=5      ; SPI clock
  -D P_LORA_MISO=19     ; SPI MISO
  -D P_LORA_MOSI=27     ; SPI MOSI
  -D P_LORA_TX_LED=25    ; LED pin for TX indication
  -D PIN_BOARD_SDA=21
  -D PIN_BOARD_SCL=22
  -D PIN_VBAT_READ=35   ; Battery voltage reading (analog pin)
  -D PIN_USER_BTN=0
  -D ARDUINO_LOOP_STACK_SIZE=16384
  -D DISPLAY_CLASS=SSD1306Display
  -D RADIO_CLASS=CustomSX1276
  -D WRAPPER_CLASS=CustomSX1276Wrapper
  -D SX127X_CURRENT_LIMIT=120
  -D LORA_TX_POWER=20
build_src_filter = ${esp32_base.build_src_filter}
  +<helpers/ui/SSD1306Display.cpp>
  +<../variants/lilygo_tlora_v2_1>
  +<helpers/sensors>
lib_deps =
  ${esp32_base.lib_deps}
  ${sensor_base.lib_deps}

; === LILYGO T-LoRa V2.1-1.6 with SX1276 environments ===
[env:LilyGo_TLora_V2_1_1_6_repeater]
extends = LilyGo_TLora_V2_1_1_6
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<../examples/simple_repeater>
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -D ADVERT_NAME='"TLora-V2.1-1.6 Repeater"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D MAX_NEIGHBOURS=50
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
;  -D CORE_DEBUG_LEVEL=3
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  ${esp32_ota.lib_deps}

[env:LilyGo_TLora_V2_1_1_6_terminal_chat]
extends = LilyGo_TLora_V2_1_1_6
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -D MAX_CONTACTS=160
  -D MAX_GROUP_CHANNELS=8
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<../examples/simple_secure_chat/main.cpp>
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  densaugeo/base64 @ ~1.4.0

[env:LilyGo_TLora_V2_1_1_6_companion_radio_usb]
extends = LilyGo_TLora_V2_1_1_6
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=160
  -D MAX_GROUP_CHANNELS=8
; NOTE: DO NOT ENABLE -->  -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE -->  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  densaugeo/base64 @ ~1.4.0

[env:LilyGo_TLora_V2_1_1_6_companion_radio_ble]
extends = LilyGo_TLora_V2_1_1_6
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=160
  -D MAX_GROUP_CHANNELS=8
  -D BLE_PIN_CODE=123456
  -D OFFLINE_QUEUE_SIZE=256
;  -D BLE_DEBUG_LOGGING=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<helpers/esp32/*.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  densaugeo/base64 @ ~1.4.0

[env:LilyGo_TLora_V2_1_1_6_room_server]
extends = LilyGo_TLora_V2_1_1_6
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<helpers/ui/SSD1306Display.cpp>
  +<../examples/simple_room_server>
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -D ADVERT_NAME='"TLora-V2.1-1.6 Room"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D ROOM_PASSWORD='"hello"'
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  ${esp32_ota.lib_deps}

[env:LilyGo_TLora_V2_1_1_6_companion_radio_wifi]
extends = LilyGo_TLora_V2_1_1_6
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=100
  -D MAX_GROUP_CHANNELS=8
  -D WIFI_SSID='"ssid"'
  -D WIFI_PWD='"password"'
  -D WIFI_DEBUG_LOGGING=1
  -D OFFLINE_QUEUE_SIZE=256  
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<helpers/esp32/*.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  densaugeo/base64 @ ~1.4.0

;
; Repeater Bridges
;
[env:LilyGo_TLora_V2_1_1_6_repeater_bridge_rs232]
extends = LilyGo_TLora_V2_1_1_6
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<helpers/bridges/RS232Bridge.cpp>
  +<../examples/simple_repeater>
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -D ADVERT_NAME='"RS232 Bridge"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D MAX_NEIGHBOURS=50
  -D WITH_RS232_BRIDGE=Serial2
  -D WITH_RS232_BRIDGE_RX=34
  -D WITH_RS232_BRIDGE_TX=25
;  -D BRIDGE_DEBUG=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
;  -D CORE_DEBUG_LEVEL=3
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  ${esp32_ota.lib_deps}

[env:LilyGo_TLora_V2_1_1_6_repeater_bridge_espnow]
extends = LilyGo_TLora_V2_1_1_6
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<helpers/bridges/ESPNowBridge.cpp>
  +<../examples/simple_repeater>
build_flags =
  ${LilyGo_TLora_V2_1_1_6.build_flags}
  -D ADVERT_NAME='"ESPNow Bridge"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D MAX_NEIGHBOURS=50
  -D WITH_ESPNOW_BRIDGE=1
;  -D BRIDGE_DEBUG=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
;  -D CORE_DEBUG_LEVEL=3
lib_deps =
  ${LilyGo_TLora_V2_1_1_6.lib_deps}
  ${esp32_ota.lib_deps}

[env:LilyGo_TLora_V2_1_1_6_kiss_modem]
extends = LilyGo_TLora_V2_1_1_6
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
  +<../examples/kiss_modem/>
