#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
# General config
CONFIG_LOG=y
CONFIG_ASSERT=y
CONFIG_ASSERT_VERBOSE=n
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_STACK_SENTINEL=y
CONFIG_PICOLIBC_IO_FLOAT=y
CONFIG_RING_BUFFER=y
CONFIG_REBOOT=y
CONFIG_EVENTFD=y

# Segger RTT
CONFIG_USE_SEGGER_RTT=y
# Where console messages (printk) are output.
# By itself, SLM does not output any.
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n
# Where SLM logs are output.
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n

# Increase the buffer so that all SLM boot logs fit into the buffer.
# Because J-Link RTT Viewer has to be connected after the bootup,
# only logs that fit into the buffer are shown. This is especially useful in showing
# errors if SLM does not start properly.
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=2048

# Network
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_NATIVE=y # required for PPP
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y

# Modem library
CONFIG_NRF_MODEM_LIB=y
CONFIG_AT_CMD_CUSTOM=y
# Align the max FD entry to NRF_MODEM_MAX_SOCKET_COUNT(8)
CONFIG_ZVFS_OPEN_MAX=8

# Handle modem fault
CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y

# Use GPIO
CONFIG_GPIO=y
CONFIG_GPIO_NRFX=y

# UART interface
CONFIG_SERIAL=y
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_TIMER2=y

# Stacks and heaps
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_AT_MONITOR_HEAP_SIZE=4096

# Device power management
CONFIG_PM_DEVICE=y

# FOTA
CONFIG_HTTP_PARSER_URL=y
CONFIG_FOTA_DOWNLOAD=y
CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
CONFIG_DFU_TARGET=y
CONFIG_DOWNLOADER=y
CONFIG_DOWNLOADER_STACK_SIZE=4096
CONFIG_DOWNLOADER_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

# Settings
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y
CONFIG_NVS=y

# nRF Cloud
CONFIG_NRF_CLOUD=y
CONFIG_NRF_CLOUD_MQTT=y
CONFIG_NRF_CLOUD_FOTA=n
CONFIG_NRF_CLOUD_AGNSS=y
CONFIG_NRF_CLOUD_AGNSS_FILTERED=n
CONFIG_NRF_CLOUD_PGPS=n
CONFIG_NRF_CLOUD_LOCATION=n
CONFIG_NRF_CLOUD_LOG_LEVEL_INF=y
CONFIG_NRF_CLOUD_GPS_LOG_LEVEL_WRN=y
CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y
CONFIG_NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI=n
CONFIG_DATE_TIME=y
CONFIG_MODEM_INFO=y
CONFIG_MODEM_INFO_ADD_DATE_TIME=n

# UUID and JWT
CONFIG_MODEM_JWT=y

# MQTT client
#CONFIG_MQTT_KEEPALIVE=60
CONFIG_MQTT_CLEAN_SESSION=y

# AT command helper libraries
CONFIG_AT_PARSER=y
CONFIG_AT_MONITOR=y

# Eventfd's to use with AT-commands.
CONFIG_ZVFS_EVENTFD_MAX=2

# Disable TF-M logging.
# TF-M log sending will block until remote end is ready, when HWFC is used on UART1.
CONFIG_TFM_LOG_LEVEL_SILENCE=y

#
# Zephyr modem configurations for external MCU
#
# The nRF91 is power-managed by Zephyr's modem_cellular driver running on the other chip.
# CONFIG_SLM_START_SLEEP=y

CONFIG_SLM_POWER_PIN=8
CONFIG_SLM_INDICATE_PIN=9

# Increase buffer space as hardware flow control is not used with Thingy:91 X.
CONFIG_SLM_UART_RX_BUF_SIZE=4096

# Disable commands of IP-based protocols to save flash space.
# CONFIG_SLM_FTPC=n
# CONFIG_SLM_TFTPC=n
# CONFIG_SLM_HTTPC=n
# CONFIG_SLM_MQTTC=n

#
# Support for LwM2M carrier (if using Verizon)
#

# CONFIG_LWM2M_CARRIER=y
# # LwM2M carrier is only compiled for hard-float
# CONFIG_FP_HARDABI=y
# # PDN management support
# CONFIG_PDN=y
# # Modem info
# CONFIG_MODEM_INFO_BUFFER_SIZE=512
# # Enable LwM2M carrier support in SLM
# CONFIG_SLM_CARRIER=y
# CONFIG_SLM_AUTO_CONNECT=y
# # Enable LwM2M carrier settings support
# CONFIG_LWM2M_CARRIER_SETTINGS=y

#
# SLM-specific configurations
#
CONFIG_SLM_CUSTOMER_VERSION="0.7.0"
CONFIG_SLM_EXTERNAL_XTAL=n

# For using external GNSS antenna
#CONFIG_MODEM_ANTENNA=y
#CONFIG_MODEM_ANTENNA_GNSS_EXTERNAL=y

#
# Debug Options
#
CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_DEBUG_THREAD_INFO=y
CONFIG_THREAD_MONITOR=y
CONFIG_THREAD_NAME=y
# Additional Logging
CONFIG_SLM_LOG_LEVEL_DBG=y
# CONFIG_LOG_BUFFER_SIZE=8192
# CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
CONFIG_UART_LOG_LEVEL_DBG=y


