# Increased stack due to settings API usage
#CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 => default value
CONFIG_MAIN_STACK_SIZE=4096

#CONFIG_DEBUG_THREAD_INFO=y => not help
CONFIG_THREAD_NAME=y

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=n
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y
# these 4 connection params below are handled in app,
# CONFIG_BT_PERIPHERAL_PREF_MIN_INT=400
# CONFIG_BT_PERIPHERAL_PREF_MAX_INT=400
# CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
# CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
CONFIG_BT_DIS=y
# CONFIG_BT_DIS_PNP=n # ??
CONFIG_BT_DIS_MODEL="ECG sensor V2"
CONFIG_BT_DIS_MANUF="NousLogic"
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_FW_REV_STR="3.2"
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_HW_REV_STR="2.0"
CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_BAS=y
#CONFIG_BT_HRS=y
#CONFIG_BT_IAS=y
CONFIG_BT_PRIVACY=y
# CONFIG_BT_DEVICE_NAME="NousLogic ECG" -> bt_set_name()
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=65
CONFIG_BT_DEVICE_APPEARANCE=833

CONFIG_BT_ID_MAX=2

CONFIG_BT_FILTER_ACCEPT_LIST=y

CONFIG_BT_AUTO_PHY_UPDATE=n # in some cases, this can be collided with CONN_PARAM update
CONFIG_BT_CTLR_PHY_2M=n
CONFIG_BT_DIS_SETTINGS=y
CONFIG_BT_DIS_STR_MAX=21

#CONFIG_BT_GATT_CLIENT=y => to bt_gatt_exchange_mtu()

#CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y => many debug logs, which are not helpful

# HCI ACL buffers size
# BT_L2CAP_RX_MTU = CONFIG_BT_BUF_ACL_RX_SIZE - BT_L2CAP_HDR_SIZE
CONFIG_BT_BUF_ACL_RX_SIZE=251

# L2CAP SDU/PDU TX MTU
CONFIG_BT_L2CAP_TX_MTU=247

# Transmit
CONFIG_BT_BUF_ACL_TX_COUNT=10
# CONFIG_BT_BUF_ACL_TX_SIZE=251 complied with CONFIG_BT_L2CAP_TX_MTU. Don't change! 
# CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=7500 (us) by default => good 

# TX power
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_CONN_RSSI=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SETTINGS=y

CONFIG_BT_SMP=y # Security Manager Protocol: pair, bond, encrypt
CONFIG_BT_BONDABLE=y
CONFIG_BT_FIXED_PASSKEY=y

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

CONFIG_SPI=y

# Enable Edge Impulse dependencies
CONFIG_CPP=y
CONFIG_STD_CPP11=y
CONFIG_FP16=n

# Enable Edge Impulse
#CONFIG_CPLUSPLUS=y
#CONFIG_LIB_CPLUSPLUS=y

CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

#CONFIG_EDGE_IMPULSE=y
#CONFIG_EDGE_IMPULSE_URI="./ecg-v11.zip"
#CONFIG_EI_WRAPPER=y
#CONFIG_NFCT_PINS_AS_GPIOS=y
# Battery read
CONFIG_ADC=y
#CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=2048 => default value

#CONFIG_RESET_ON_FATAL_ERROR=y

# If asserted, assert_post_function() is triggered, which by default triggers fatal error.
# Disabling these improves performance and system footprint
CONFIG_ASSERT=n
CONFIG_ASSERT_VERBOSE=n
CONFIG_ASSERT_NO_FILE_INFO=n # 

# save memory. Keep these `n`. Always!
CONFIG_SHELL=n

# USB reading from PC
CONFIG_SERIAL=y

## to printout for debugging: turn these to y
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_LOG=n
CONFIG_LOG_PRINTK=n
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_PRINTK_SYNC=n

# OTA
CONFIG_BOOTLOADER_MCUBOOT=y
#Include MCUMGR and the dependencies in the build
#CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
CONFIG_SETTINGS_NVS=y
#CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=n
CONFIG_SETTINGS_DYNAMIC_HANDLERS=n
CONFIG_SETTINGS_RUNTIME=y
CONFIG_REBOOT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# watchdog
CONFIG_WATCHDOG=y
CONFIG_WDT_DISABLE_AT_BOOT=y
CONFIG_TASK_WDT=y
CONFIG_TASK_WDT_MIN_TIMEOUT=500

CONFIG_USB_CDC_ACM=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="NOUSLOGIC CDC ACM ECG"
CONFIG_USB_DEVICE_PID=0x0001
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=n
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=n
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_POWER_DOMAIN=n
CONFIG_PM_DEVICE_RUNTIME=y

CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_NTP=n

#CONFIG_BOOT_BANNER=y
CONFIG_SECURE_BOOT=y
CONFIG_FW_INFO=y
CONFIG_SB_SIGNING_KEY_FILE="./priv.pem"
CONFIG_DISABLE_FLASH_PATCH=y
CONFIG_HEAP_MEM_POOL_SIZE=10240

CONFIG_ZCBOR=y
CONFIG_MCUMGR_SMP_CBOR_MAX_ENCODING_LEVELS=1

CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_TRUSTED_STORAGE=y
CONFIG_NRF_SECURITY=y