; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921
[env:rak4631]
custom_meshtastic_hw_model = 9
custom_meshtastic_hw_model_slug = RAK4631
custom_meshtastic_architecture = nrf52840
custom_meshtastic_actively_supported = true
custom_meshtastic_support_level = 1
custom_meshtastic_display_name = RAK WisBlock 4631
custom_meshtastic_images = rak4631.svg, rak4631_case.svg
custom_meshtastic_tags = RAK

extends = nrf52840_base
board = wiscore_rak4631
board_level = pr
board_check = true
build_type = release
build_flags = ${nrf52840_base.build_flags}
  -I variants/nrf52840/rak4631
  -D RAK_4631
  -DMESHTASTIC_USE_EINK_UI=0
  -DRADIOLIB_EXCLUDE_SX128X=1
  -DRADIOLIB_EXCLUDE_SX127X=1
  -DRADIOLIB_EXCLUDE_LR11X0=1
  -DRADIOLIB_EXCLUDE_LR2021=1
build_src_filter = ${nrf52_base.build_src_filter} \
  +<../variants/nrf52840/rak4631> \
  +<mesh/eth/> \
  +<mesh/api/> \
  +<mqtt/> \
  -<graphics/EInkDisplay2.cpp> \
  -<graphics/EInkDynamicDisplay.cpp> \
  -<graphics/fonts/EinkDisplayFonts.cpp>
lib_deps = 
  ${nrf52840_base.lib_deps}
  ${networking_base.lib_deps}
  # renovate: datasource=custom.pio depName=Melopero RV3028 packageName=melopero/library/Melopero RV3028
  melopero/Melopero RV3028@1.2.0
  # renovate: datasource=github-tags depName=RAK13800-W5100S packageName=RAKWireless/RAK13800-W5100S
  https://github.com/RAKWireless/RAK13800-W5100S/archive/1.0.2.zip
  # renovate: datasource=custom.pio depName=RAK NCP5623 RGB LED packageName=rakwireless/library/RAKwireless NCP5623 RGB LED library
  rakwireless/RAKwireless NCP5623 RGB LED library@1.0.3
  # renovate: datasource=custom.pio depName=RAK12035_SoilMoisture packageName=beegee-tokyo/library/RAK12035_SoilMoisture
  beegee-tokyo/RAK12035_SoilMoisture@1.0.4
  # renovate: datasource=git-refs depName=RAK12034-BMX160 packageName=https://github.com/RAKWireless/RAK12034-BMX160 gitBranch=main
  https://github.com/RAKWireless/RAK12034-BMX160/archive/dcead07ffa267d3c906e9ca4a1330ab989e957e2.zip

; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
; Note: as of 6/2013 the serial/bootloader based programming takes approximately 30 seconds
;upload_protocol = jlink

; Allows programming and debug via the RAK NanoDAP as the default debugger tool for the RAK4631 (it is only $10!)
; programming time is about the same as the bootloader version.
; For information on this see the meshtastic developers documentation for "Development on the NRF52"
[env:rak4631_dbg]
extends = env:rak4631
board_level = extra

; if the builtin version of openocd has a buggy version of semihosting, so use the external version
; platform_packages = platformio/tool-openocd@3.1200.0

build_flags =
  ${env:rak4631.build_flags}
  -D USE_SEMIHOSTING

lib_deps =
  ${env:rak4631.lib_deps}
  # TODO renovate
  https://github.com/geeksville/Armduino-Semihosting/archive/35b538fdf208c3530c1434cd099a08e486672ee4.zip

; NOTE: the pyocd support for semihosting is buggy.  So I switched to using the builtin platformio support for the stlink adapter which worked much better.
; However the built in openocd version in platformio has buggy support for TCP to semihosting. 
;
; So I'm now trying the external openocd - but the openocd scripts for nrf52.cfg assume you are using a DAP adapter not an STLINK adapter.
; In theory I could change those scripts.  But for now I'm trying going back to a DAP adapter but with the external openocd.

upload_protocol = stlink
; eventually use platformio/tool-pyocd@2.3600.0 instad
;upload_protocol = custom
;upload_command = pyocd flash -t nrf52840 $UPLOADERFLAGS $SOURCE
