[LilyGo_TBeam_1W]
extends = esp32_base
board = t_beam_1w
build_flags =
  ${esp32_base.build_flags}
  -I variants/lilygo_tbeam_1w
  -D TBEAM_1W

  ; Radio - SX1262 with high-power PA (32dBm max output)
  ; Note: Set SX1262 output to 22dBm max, external PA provides additional gain
  -D RADIO_CLASS=CustomSX1262
  -D WRAPPER_CLASS=CustomSX1262Wrapper
  -D P_LORA_DIO_1=1
  -D P_LORA_NSS=15
  -D P_LORA_RESET=3
  -D P_LORA_BUSY=38
  -D P_LORA_SCLK=13
  -D P_LORA_MISO=12
  -D P_LORA_MOSI=11

  ; RF switch configuration:
  ;   DIO2 controls TX path (PA enable) via SX126X_DIO2_AS_RF_SWITCH
  ;   GPIO21 controls RX path (LNA enable) via SX126X_RXEN
  ; Truth table: DIO2=1,RXEN=0 → TX | DIO2=0,RXEN=1 → RX
  -D SX126X_DIO2_AS_RF_SWITCH=true
  -D SX126X_RXEN=21
  -D SX126X_DIO3_TCXO_VOLTAGE=3.0
  -D SX126X_CURRENT_LIMIT=140
  -D SX126X_RX_BOOSTED_GAIN=1

  ; TX power: 22dBm to SX1262, PA module adds ~10dB for 32dBm total
  -D LORA_TX_POWER=22

  ; Battery - 2S 7.4V LiPo (6.0V min, 8.4V max)
  -D BATT_MIN_MILLIVOLTS=6000
  -D BATT_MAX_MILLIVOLTS=8400

  ; Display - SH1106 OLED at 0x3C
  -D DISPLAY_CLASS=SH1106Display

  ; I2C pins
  -D PIN_BOARD_SDA=8
  -D PIN_BOARD_SCL=9

  ; GPS - L76K module
  ; GNSS_TXD (IO5) = GPS transmits → MCU RX
  ; GNSS_RXD (IO6) = GPS receives → MCU TX
  -D PIN_GPS_TX=5
  -D PIN_GPS_RX=6
  -D PIN_GPS_EN=16
  -D ENV_INCLUDE_GPS=1

  ; User interface
  -D PIN_USER_BTN=17

build_src_filter = ${esp32_base.build_src_filter}
  +<../variants/lilygo_tbeam_1w>
  +<helpers/ui/SH1106Display.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<helpers/sensors>

lib_deps =
  ${esp32_base.lib_deps}
  adafruit/Adafruit SH110X @ ~2.1.13
  stevemarple/MicroNMEA @ ~2.0.6

; === LILYGO T-Beam 1W Repeater ===
[env:LilyGo_TBeam_1W_repeater]
extends = LilyGo_TBeam_1W
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -D ADVERT_NAME='"T-Beam 1W Repeater"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D MAX_NEIGHBOURS=50
  -D PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<../examples/simple_repeater>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  ${esp32_ota.lib_deps}

; === LILYGO T-Beam 1W Room Server ===
[env:LilyGo_TBeam_1W_room_server]
extends = LilyGo_TBeam_1W
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -D ADVERT_NAME='"T-Beam 1W Room"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D ROOM_PASSWORD='"hello"'
  -D PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<../examples/simple_room_server>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  ${esp32_ota.lib_deps}

; === LILYGO T-Beam 1W Companion Radio (USB) ===
[env:LilyGo_TBeam_1W_companion_radio_usb]
extends = LilyGo_TBeam_1W
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=350
  -D MAX_GROUP_CHANNELS=40
  -D PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  densaugeo/base64 @ ~1.4.0

; === LILYGO T-Beam 1W Companion Radio (BLE) ===
[env:LilyGo_TBeam_1W_companion_radio_ble]
extends = LilyGo_TBeam_1W
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=350
  -D MAX_GROUP_CHANNELS=40
  -D BLE_PIN_CODE=123456
  -D OFFLINE_QUEUE_SIZE=256
  -D PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
;  -D BLE_DEBUG_LOGGING=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<helpers/esp32/*.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  densaugeo/base64 @ ~1.4.0

; === LILYGO T-Beam 1W Companion Radio PS (BLE PS) ===
[env:LilyGo_TBeam_1W_companion_radio_ble_ps]
extends = env:LilyGo_TBeam_1W_companion_radio_ble

; === LILYGO T-Beam 1W Companion Radio (WiFi) ===
[env:LilyGo_TBeam_1W_companion_radio_wifi]
extends = LilyGo_TBeam_1W
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -I examples/companion_radio/ui-new
  -D MAX_CONTACTS=350
  -D MAX_GROUP_CHANNELS=40
  -D OFFLINE_QUEUE_SIZE=256
  -D WIFI_DEBUG_LOGGING=1
  -D WIFI_SSID='"myssid"'
  -D WIFI_PWD='"mypwd"'
  -D PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<helpers/esp32/*.cpp>
  +<../examples/companion_radio/*.cpp>
  +<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  densaugeo/base64 @ ~1.4.0

; === LILYGO T-Beam 1W Repeater with ESPNow Bridge ===
[env:LilyGo_TBeam_1W_repeater_bridge_espnow]
extends = LilyGo_TBeam_1W
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -D ADVERT_NAME='"T-Beam 1W 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 PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
;  -D BRIDGE_DEBUG=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<helpers/bridges/ESPNowBridge.cpp>
  +<../examples/simple_repeater>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  ${esp32_ota.lib_deps}

; === LILYGO T-Beam 1W Repeater MQTT Observer ===
[env:LilyGo_TBeam_1W_repeater_observer_mqtt]
extends = LilyGo_TBeam_1W
extra_scripts =
  ${esp32_base.extra_scripts}
  pre:scripts/generate_cert_bundle.py
board_ssl_cert_source = adafruit-full
board_build.embed_files = src/certs/x509_crt_bundle.bin
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -D ADVERT_NAME='"T-Beam 1W MQTT Observer"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D MAX_NEIGHBOURS=50
  -D WITH_MQTT_BRIDGE=1
  -D OTA_MANIFEST_BASE='"https://observer.gessaman.com/v"'
  -D MAX_MQTT_BROKERS=3
  -D MQTT_MAX_PACKET_SIZE=1024
  -D PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
;  -D MQTT_DEBUG=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
  -D CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
  -D ESP32_CPU_FREQ=160
#  -D WIFI_SSID='"ssid"'
#  -D WIFI_PWD='"password"'
#  -D MQTT_SERVER='"your-mqtt-broker.com"'
#  -D MQTT_PORT=1883
#  -D MQTT_USERNAME='"your-username"'
#  -D MQTT_PASSWORD='"your-password"'
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<helpers/bridges/MQTTBridge.cpp>
  +<helpers/MQTTMessageBuilder.cpp>
  +<helpers/JWTHelper.cpp>
  +<helpers/ui/SH1106Display.cpp>
  +<../examples/simple_repeater>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  ${esp32_ota.lib_deps}
  elims/PsychicMqttClient@^0.2.4
  bblanchon/ArduinoJson
  arduino-libraries/NTPClient
  JChristensen/Timezone
  paulstoffregen/Time@1.6.1

; === LILYGO T-Beam 1W Room Server MQTT Observer ===
[env:LilyGo_TBeam_1W_room_server_observer_mqtt]
extends = LilyGo_TBeam_1W
extra_scripts =
  ${esp32_base.extra_scripts}
  pre:scripts/generate_cert_bundle.py
board_ssl_cert_source = adafruit-full
board_build.embed_files = src/certs/x509_crt_bundle.bin
build_flags =
  ${LilyGo_TBeam_1W.build_flags}
  -D ADVERT_NAME='"T-Beam 1W Room Observer"'
  -D ADVERT_LAT=0.0
  -D ADVERT_LON=0.0
  -D ADMIN_PASSWORD='"password"'
  -D ROOM_PASSWORD='"hello"'
  -D WITH_MQTT_BRIDGE=1
  -D OTA_MANIFEST_BASE='"https://observer.gessaman.com/v"'
  -D MAX_MQTT_BROKERS=3
  -D MQTT_MAX_PACKET_SIZE=1024
  -D PERSISTANT_GPS=1
  -D ENV_SKIP_GPS_DETECT=1
  -D MQTT_DEBUG=1
;  -D MESH_PACKET_LOGGING=1
;  -D MESH_DEBUG=1
  -D CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
  -D ESP32_CPU_FREQ=160
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
  +<helpers/bridges/MQTTBridge.cpp>
  +<helpers/MQTTMessageBuilder.cpp>
  +<helpers/JWTHelper.cpp>
  +<helpers/ui/SH1106Display.cpp>
  +<../examples/simple_room_server>
lib_deps =
  ${LilyGo_TBeam_1W.lib_deps}
  ${esp32_ota.lib_deps}
  elims/PsychicMqttClient@^0.2.4
  bblanchon/ArduinoJson
  arduino-libraries/NTPClient
  JChristensen/Timezone
  paulstoffregen/Time@1.6.1

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