#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
################################################################################
# Application overlay - Thingy:53 DFU

CONFIG_MCUMGR=y
CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL=y

CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y

# Enable custom SMP request to erase settings partition.
CONFIG_MCUMGR_GRP_ZEPHYR_BASIC=y
CONFIG_MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE=y

# Increase system workqueue stack size to prevent stack overflows while handling
# SMP requests.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2800

CONFIG_BT_L2CAP_TX_MTU=498
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=502

# Use connection parameters that ensure quick data transfer
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=6
CONFIG_BT_PERIPHERAL_PREF_LATENCY=99
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400

# LEDs are not inverted on Thingy:53
CONFIG_DK_LIBRARY_INVERT_LEDS=n

################################################################################
# Bootloader configuration

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_IMAGE_VERSION="1.0.0+0"
CONFIG_UPDATEABLE_IMAGE_NUMBER=2

CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

################################################################################
# External flash configuration

CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

# FLASH nop device is enabled to prevent bus faults when mcumgr tries to access
# simulated partition with network core image data.
CONFIG_FLASH_NOP_DEVICE=y

################################################################################
# Enable USB CDC ACM

CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Thingy:53 Nordic UART Service sample"
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x530E
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_CDC_ACM=y
CONFIG_USB_CDC_ACM_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y

CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_PRINTK=y
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=1024
CONFIG_LOG_PROCESS_THREAD_STARTUP_DELAY_MS=4000
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_RTT=n

CONFIG_BT_NUS_UART_ASYNC_ADAPTER=y
CONFIG_BT_NUS_UART_DEV="CDC_ACM_1"
CONFIG_UART_INTERRUPT_DRIVEN=y

# Disable the UARTE0 enabled in default project configuration
CONFIG_NRFX_UARTE0=n
CONFIG_UART_NRFX=n
