# This is a Kconfig fragment which is considered common to all build variants
# and is always used.

# Disable all logging and printing here explicitly so that a Kconfig warning will be generated if it is enabled somewhere else
CONFIG_BOOT_BANNER=n
CONFIG_PRINTK=n
CONFIG_LOG=n

# libc
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_CBPRINTF_FP_SUPPORT=y

# Memory
# Since we are using NVS, any thread that sets settings must have a larger stack
# to support erase operations in the NVS driver.
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=16384
CONFIG_SHELL_STACK_SIZE=4096
CONFIG_BT_RX_STACK_SIZE=4096
CONFIG_APP_EVENT_MANAGER_HEAP_SIZE=16384
CONFIG_USER_SETTINGS_HEAP_SIZE=8192

CONFIG_SIMPLE_SCHEDULE_MAX_NUM=10

# Enable sys reboot
CONFIG_REBOOT=y

# flash and flash map
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# Use Mcuboot as bootloader
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y
CONFIG_DFU_TARGET=y
CONFIG_DFU_TARGET_MCUBOOT=y

# TODO: can we safely set this to y?
CONFIG_DFU_TARGET_STREAM_SAVE_PROGRESS=n

CONFIG_STREAM_FLASH_ERASE=y

# Power management
CONFIG_PM=y
CONFIG_PM_DEVICE=y

# version info lib
CONFIG_VERSION_INFO=y
CONFIG_VERSION_INFO_APP_BUILD_TYPE="release"

# user settings lib
CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y
CONFIG_SETTINGS_NVS=y
CONFIG_SETTINGS_SHELL=n
CONFIG_USER_SETTINGS=y
CONFIG_USER_SETTINGS_SHELL=y
CONFIG_USER_SETTINGS_BT_SERVICE=y

# persistent element storage
CONFIG_PERSISTENT_ELEMENT_STORAGE=y
CONFIG_PES_MAX_NUMBER_OF_BUFFER_INSTANCES=10
CONFIG_PES_MAX_NUMBER_OF_HANDLE_INSTANCES=90

# event manager
CONFIG_APP_EVENT_MANAGER=y
CONFIG_APP_EVENT_MANAGER_MAX_EVENT_CNT=64

# shell
CONFIG_SHELL=y
CONFIG_SHELL_MINIMAL=n
CONFIG_SHELL_ECHO_STATUS=y
CONFIG_SHELL_WILDCARD=n
CONFIG_SHELL_METAKEYS=n
# Shell login
CONFIG_SHELL_CMDS_SELECT=y

# For the release build we want to disable all "unsafe" shell commands
CONFIG_ADC_SHELL=n
CONFIG_APP_EVENT_MANAGER_SHELL=n
CONFIG_DATE_SHELL=n
CONFIG_DEVICE_SHELL=n
CONFIG_DEVMEM_SHELL=n
CONFIG_FLASH_SHELL=n
CONFIG_GPIO_SHELL=n
CONFIG_I2C_SHELL=n
CONFIG_KERNEL_SHELL=n
CONFIG_LTE_SHELL=n
CONFIG_MCUBOOT_SHELL=n
CONFIG_CLOCK_CONTROL_NRF_SHELL=n
CONFIG_SENSOR_SHELL=n

# Bluetooth
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_BROADCASTER=y

# Allow for larger Bluetooth data packets.
CONFIG_BT_L2CAP_TX_MTU=252

# Use BT GATT client to force MTU exchange
CONFIG_BT_GATT_CLIENT=y

# shell over NUS
CONFIG_BT_NUS=y
CONFIG_SHELL_BT_NUS=y
CONFIG_SHELL_BT_NUS_TX_RING_BUFFER_SIZE=502
CONFIG_SHELL_BT_NUS_RX_RING_BUFFER_SIZE=256
CONFIG_SHELL_BT_NUS_INIT_LOG_LEVEL_NONE=y
# DFU
CONFIG_MCUMGR=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
# Decrease number of buffers to slow down the rate of data transfer.
# This lowers the chance of nrf52 from crashing during DFU.
CONFIG_MCUMGR_BUF_COUNT=2

# Since SMP authen is disabled, we do not require any BT security features
CONFIG_BT_SMP=n
# Device name (can be read by a central device on the Generic Access service)
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=40
CONFIG_BT_DEVICE_NAME_GATT_WRITABLE=n

# uptime update in advertising data
CONFIG_BLE_STATUS_UPTIME_UPDATE_INTERVAL=60

# RAM analog circuit driver
CONFIG_RAM_ANALOG=y

# Battery measurement
CONFIG_ADC=y
CONFIG_VOLTAGE_DIVIDER=y
# Disable shell command since it is unsafe
CONFIG_VOLTAGE_DIVIDER_SHELL=n

# Date-Time lib
CONFIG_DATE_TIME=y

# Hardware Watchdog
CONFIG_WATCHDOG=y

# # Memfault
CONFIG_MEMFAULT=y
# Using UDP, so no need to enable memfault HTTP support
CONFIG_MEMFAULT_HTTP_ENABLE=n
# disable memfault shell
CONFIG_MEMFAULT_SHELL=n
# Don't store coredump in flash
CONFIG_MEMFAULT_NCS_INTERNAL_FLASH_BACKED_COREDUMP=n
# Store coredump in RAM
CONFIG_MEMFAULT_RAM_BACKED_COREDUMP=y
CONFIG_MEMFAULT_COREDUMP_COLLECT_BSS_REGIONS=y
# Use custom device config
CONFIG_MEMFAULT_DEVICE_INFO_CUSTOM=y
CONFIG_MEMFAULT_NCS_PROJECT_KEY="doesntmatter"
CONFIG_MEMFAULT_NCS_FW_TYPE="doesntmatter"
CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC=y
CONFIG_MEMFAULT_NCS_DEVICE_ID="doesntmatter"

CONFIG_MEMFAULT_NCS_STACK_METRICS=y
# If this is not set, CONFIG_LOG=y will be forced on due to a weird Kconfig choice.
# See https://github.com/zephyrproject-rtos/zephyr/issues/59919.
# Note that this does not enable printk.
# Thread analyzer is enabled by CONFIG_MEMFAULT_NCS_STACK_METRICS
CONFIG_THREAD_ANALYZER_USE_PRINTK=y


# LoRaWAN
CONFIG_LORA_BASICS_MODEM=y
CONFIG_LORA_BASICS_MODEM_PRINTERS=y
CONFIG_LR11XX_LIB=y
CONFIG_SPI=y

CONFIG_ENTROPY_GENERATOR=y

# disable unused regions:
CONFIG_LORA_BASICS_MODEM_ENABLE_ALL_REGIONS=y
CONFIG_LORA_BASICS_MODEM_REGION_CN_470=n
CONFIG_LORA_BASICS_MODEM_REGION_CN_470_RP_1_0=n
CONFIG_LORA_BASICS_MODEM_REGION_WW_2G4=n

# Enable printers for use in shell
CONFIG_LORA_BASICS_MODEM_PRINTERS=y

# TODO: How can we disable class B and C? Seems not possible currently.
