#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_STD_C23=y
CONFIG_GNU_C_EXTENSIONS=y

CONFIG_HW_STACK_PROTECTION=y
CONFIG_STACK_SENTINEL=y

# General config
CONFIG_ASSERT=y
CONFIG_LOG=y
CONFIG_POLL=y
CONFIG_REBOOT=y
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_RESET_ON_FATAL_ERROR=y

# Device power management
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

# UART
CONFIG_SERIAL=y
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
# See https://devzone.nordicsemi.com/f/nordic-q-a/116554/interrupt-driven-uart-doesn-t-work-with-pm_device_runtime
CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=n

# Log Levels
CONFIG_LOG_DEFAULT_LEVEL=4
#CONFIG_AT_CMD_LOG_LEVEL_DBG=y
#CONFIG_AT_NOTIF_LOG_LEVEL_DBG=y
#CONFIG_AT_MONITOR_LOG_LEVEL_DBG=y
#CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=y
#CONFIG_MODEM_LOG_LEVEL_DBG=y
#CONFIG_KERNEL_LOG_LEVEL_DBG=y
#CONFIG_PM_LOG_LEVEL_INF=y
#CONFIG_DOWNLOAD_CLIENT_LOG_LEVEL_DBG=y

# FOTA
CONFIG_HTTP_PARSER_URL=y
CONFIG_FOTA_DOWNLOAD=y
CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
CONFIG_DFU_TARGET=y
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=2048
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y

# FLASH
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_STREAM_FLASH=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# Application Upgrade support
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_IMG_MANAGER=y

CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_RTT_MODE_DROP=y

# SPI
CONFIG_SPI=n # Not using any default SPI libraries because our SPIS implementation directly uses the NRF_SPIS peripheral

# Libraries
CONFIG_MODEM_KEY_MGMT=y
CONFIG_MODEM_INFO=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_NATIVE=n
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y

# Modem library
CONFIG_NRF_MODEM_LIB=y
CONFIG_NRF_MODEM_LIB_ON_FAULT_RESET_MODEM=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M=y

CONFIG_LTE_LC_CONN_EVAL_MODULE=y
CONFIG_LTE_LC_EDRX_MODULE=y
CONFIG_LTE_LC_NEIGHBOR_CELL_MEAS_MODULE=y
CONFIG_LTE_LC_PERIODIC_SEARCH_MODULE=y
CONFIG_LTE_LC_PSM_MODULE=y
CONFIG_LTE_LC_RAI_MODULE=y
CONFIG_LTE_LC_MODEM_SLEEP_MODULE=y
CONFIG_LTE_LC_TAU_PRE_WARNING_MODULE=y

# Stacks and heaps
CONFIG_MAIN_STACK_SIZE=3072
CONFIG_HEAP_MEM_POOL_SIZE=16384
# For AT notification processing
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Larger stack needed here because default of 1024 isn't large enough for pb_encode() in lte_lc_evt_handler.
CONFIG_LTE_LC_WORKQUEUE_STACK_SIZE=2048

CONFIG_SLM_GPIO=y

CONFIG_AT_MONITOR_HEAP_SIZE=512

# RTT Debugging config
# CONFIG_NRF_MODEM_LIB_TRACE=y
# CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=16384

# Shell can be handy for debugging
#CONFIG_SHELL=y
#CONFIG_AT_SHELL=y
#CONFIG_ISR_TABLE_SHELL=y
#CONFIG_MCUBOOT_SHELL=y
#CONFIG_PM_DEVICE_SHELL=y
#CONFIG_DOWNLOAD_CLIENT_SHELL=y

# Handy debugging options
# CONFIG_DEBUG_OPTIMIZATIONS=y
# CONFIG_RESET_ON_FATAL_ERROR=n
