[Heltec_lora32_v4]
extends = esp32_base
board = heltec_v4
build_flags =
  ${esp32_base.build_flags}
  ${sensor_base.build_flags}
  -I variants/heltec_v4
  -D HELTEC_LORA_V4
  -D USE_SX1262
  -D ESP32_CPU_FREQ=80
  -D RADIO_CLASS=CustomSX1262
  -D WRAPPER_CLASS=CustomSX1262Wrapper
  -D P_LORA_TX_LED=35
  -D P_LORA_DIO_1=14
  -D P_LORA_NSS=8
  -D P_LORA_RESET=12
  -D P_LORA_BUSY=13
  -D P_LORA_SCLK=9
  -D P_LORA_MISO=11
  -D P_LORA_MOSI=10
  -D P_LORA_PA_POWER=7   ; VFEM_Ctrl - Power on GC1109
  -D P_LORA_PA_EN=2      ; PA CSD - Enable GC1109
  -D P_LORA_PA_TX_EN=46  ; PA CPS - GC1109 TX PA full(High) / bypass(Low)
  -D PIN_USER_BTN=0
  -D PIN_VEXT_EN=36
  -D PIN_VEXT_EN_ACTIVE=HIGH
  -D LORA_TX_POWER=10 ;If it is configured as 10 here, the final output will be 22 dbm.
  -D MAX_LORA_TX_POWER=22 ; Max SX1262 output
  -D SX126X_REGISTER_PATCH=1       ; Patch register 0x8B5 for improved RX
  -D SX126X_DIO2_AS_RF_SWITCH=true ; GC1109 CTX is controlled by SX1262 DIO2
  -D SX126X_DIO3_TCXO_VOLTAGE=1.8
  -D SX126X_CURRENT_LIMIT=140
  -D SX126X_RX_BOOSTED_GAIN=1      ; In some cases, commenting this out will improve RX
  -D PIN_GPS_RX=38
  -D PIN_GPS_TX=39
  -D PIN_GPS_RESET=42
  -D PIN_GPS_RESET_ACTIVE=LOW
  -D PIN_GPS_EN=34
  -D PIN_GPS_EN_ACTIVE=LOW
  -D ENV_INCLUDE_GPS=1
  -D PIN_ADC_CTRL=37
  -D PIN_VBAT_READ=1
build_src_filter = ${esp32_base.build_src_filter}
  +<../variants/heltec_v4>
  +<helpers/sensors>
lib_deps =
  ${esp32_base.lib_deps}
  ${sensor_base.lib_deps}

[heltec_v4_oled]
extends = Heltec_lora32_v4
build_flags =
  ${Heltec_lora32_v4.build_flags}
  -D HELTEC_LORA_V4_OLED
  -D PIN_BOARD_SDA=17
  -D PIN_BOARD_SCL=18
  -D PIN_OLED_RESET=21
build_src_filter= ${Heltec_lora32_v4.build_src_filter}
lib_deps = ${Heltec_lora32_v4.lib_deps}

[heltec_v4_tft]
extends = Heltec_lora32_v4
build_flags =
  ${Heltec_lora32_v4.build_flags}
  -D HELTEC_LORA_V4_TFT
  -D PIN_BOARD_SDA=4
  -D PIN_BOARD_SCL=3
  -D DISPLAY_SCALE_X=2.5
  -D DISPLAY_SCALE_Y=3.75
  -D PIN_TFT_RST=18
  -D PIN_TFT_VDD_CTL=-1
  -D PIN_TFT_LEDA_CTL=21
  -D PIN_TFT_LEDA_CTL_ACTIVE=HIGH
  -D PIN_TFT_CS=15
  -D PIN_TFT_DC=16
  -D PIN_TFT_SCL=17
  -D PIN_TFT_SDA=33
build_src_filter= ${Heltec_lora32_v4.build_src_filter}
lib_deps = 
  ${Heltec_lora32_v4.lib_deps}
  adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0

; ---------------------------------------------------------------------------
; Heltec V4 WiFi Remote Repeater — WiFi MQTT backhaul, remote management
; No SD card — config files stored in SPIFFS.
; Upload config: create data/remote/ folder with wifi.cfg and mqtt.cfg,
;                then run: pio run -e meck_wifi_repeater_heltec_v4 -t uploadfs
; OLED display shows status (optional — works headless too)
; Flash: pio run -e meck_wifi_repeater_heltec_v4 -t upload
; ---------------------------------------------------------------------------
[env:meck_wifi_repeater_heltec_v4]
extends = heltec_v4_oled
upload_port = /dev/cu.usbmodem101
build_src_filter = ${heltec_v4_oled.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<helpers/ui/SSD1306Display.cpp>
  +<helpers/ui/MomentaryButton.cpp>
  +<../examples/simple_repeater/*.cpp>
build_flags =
  ${heltec_v4_oled.build_flags}
  -D FIRMWARE_VERSION='"Meck HV4 WiFi Rptr v0.1"'
  -D FIRMWARE_BUILD_DATE='"5 Apr 2026"'
  -D DISPLAY_CLASS=SSD1306Display
  -D ADVERT_NAME='"Heltec Repeater"'
  -D ADMIN_PASSWORD='"password"'
  -D MECK_WIFI_REMOTE
  -D MECK_REMOTE_REPEATER=1
  -D DISABLE_WIFI_OTA=1
  -D MAX_NEIGHBOURS=50
  -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 =
  ${heltec_v4_oled.lib_deps}
  knolleary/PubSubClient@^2.8
lib_ignore =
  ESP32 BLE Arduino
  AsyncTCP
  RPAsyncTCP
  ESPAsyncWebServer
  AsyncElegantOTA
  ESP32-audioI2S
  esp32_codec2_arduino
board_build.partitions = default_16MB.csv
board_build.filesystem = spiffs

; ---------------------------------------------------------------------------
; Heltec V4 WiFi Remote Repeater — HEADLESS (no display)
; ---------------------------------------------------------------------------
[env:meck_wifi_repeater_heltec_v4_headless]
extends = Heltec_lora32_v4
upload_port = /dev/cu.usbmodem101
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
  +<helpers/esp32/*.cpp>
  -<helpers/esp32/SerialBLEInterface.cpp>
  +<../examples/simple_repeater/*.cpp>
build_flags =
  ${Heltec_lora32_v4.build_flags}
  -D ESP32_CPU_FREQ=240
  -D FIRMWARE_VERSION='"Meck HV4 WiFi Rptr v0.1"'
  -D FIRMWARE_BUILD_DATE='"5 Apr 2026"'
  -D ADVERT_NAME='"Heltec Repeater"'
  -D ADMIN_PASSWORD='"password"'
  -D MECK_WIFI_REMOTE
  -D MECK_REMOTE_REPEATER=1
  -D DISABLE_WIFI_OTA=1
  -D MAX_NEIGHBOURS=50
  -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 =
  ${Heltec_lora32_v4.lib_deps}
  knolleary/PubSubClient@^2.8
lib_ignore =
  ESP32 BLE Arduino
  AsyncTCP
  RPAsyncTCP
  ESPAsyncWebServer
  AsyncElegantOTA
  ESP32-audioI2S
  esp32_codec2_arduino
board_build.partitions = default_16MB.csv
board_build.filesystem = spiffs