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

# General configuration
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_NVS_LOOKUP_CACHE=y
CONFIG_SETTINGS_NVS_NAME_CACHE=y
CONFIG_HWINFO=y
CONFIG_DK_LIBRARY=y
CONFIG_LOG=y

# Bootloader configuration
CONFIG_NCS_APPLICATION_BOOT_BANNER_STRING="Mesh DFU Target"
CONFIG_STREAM_FLASH=y
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE=y
CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="1.0.0+0"
CONFIG_REBOOT=y

# Bluetooth configuration
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="Mesh DFU Target"
CONFIG_BT_L2CAP_TX_BUF_COUNT=8
CONFIG_BT_OBSERVER=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_SETTINGS=y

# Disable unused Bluetooth features
CONFIG_BT_CTLR_LE_ENC=n
CONFIG_BT_DATA_LEN_UPDATE=n
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_CTLR_CHAN_SEL_2=n
CONFIG_BT_CTLR_PRIVACY=n

# Bluetooth Mesh configuration
CONFIG_BT_MESH=y
CONFIG_BT_MESH_RELAY=y
CONFIG_BT_MESH_FRIEND=y
CONFIG_BT_MESH_MSG_CACHE_SIZE=256
CONFIG_BT_MESH_ADV_BUF_COUNT=128
CONFIG_BT_MESH_TX_SEG_MAX=14
CONFIG_BT_MESH_RX_SEG_MAX=14
CONFIG_BT_MESH_TX_SEG_MSG_COUNT=2
CONFIG_BT_MESH_RX_SEG_MSG_COUNT=2
CONFIG_BT_MESH_PB_GATT=y
CONFIG_BT_MESH_PB_ADV=y
CONFIG_BT_MESH_GATT_PROXY=y
CONFIG_BT_MESH_DK_PROV=y
CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME=y
CONFIG_BT_MESH_MODEL_EXTENSIONS=y
CONFIG_BT_MESH_MODEL_EXTENSION_LIST_SIZE=1

# Bluetooth Mesh models
CONFIG_BT_MESH_BLOB_SRV=y
CONFIG_BT_MESH_BLOB_IO_FLASH=y
CONFIG_BT_MESH_DFU_SRV=y
CONFIG_BT_MESH_DFU_METADATA=y
CONFIG_BT_MESH_SAR_CFG_SRV=y

# Reconfigure transport SAR for DFU
# Increase probability of delivering segmented messages
CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_COUNT=0x5
CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_WITHOUT_PROG_COUNT=0x3
# Reduce amount of generated SegAcks
CONFIG_BT_MESH_SAR_RX_ACK_RETRANS_COUNT=0x0
CONFIG_BT_MESH_SAR_RX_ACK_DELAY_INC=0x7
CONFIG_BT_MESH_SAR_RX_SEG_INT_STEP=0xf
CONFIG_BT_MESH_SAR_RX_SEG_THRESHOLD=0x1f

# Debug configuration
CONFIG_BT_MESH_LOG_LEVEL_DBG=y
CONFIG_BT_MESH_MODEL_LOG_LEVEL_DBG=y
CONFIG_BT_MESH_DFU_LOG_LEVEL_DBG=y
CONFIG_BT_MESH_PROVISIONEE_LOG_LEVEL_INF=y

# CONFIG_DFU_TARGET_MODE_DELTA=n
# CONFIG_DFU_TARGET_FULL_MODE=n
CONFIG_DFU_TARGET_CUSTOM=n
CONFIG_DFU_TARGET=y
CONFIG_DFU_TARGET_MCUBOOT=y
CONFIG_DFU_TARGET_LOG_LEVEL_DEFAULT=y
CONFIG_DFU_TARGET_STREAM_SAVE_PROGRESS=y
CONFIG_DFU_TARGET_STREAM_SYNCHRONOUS=y
CONFIG_STREAM_FLASH_PROGRESS=y
