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

#############################################################
### Basics ###
#CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_CONSOLE=y
CONFIG_LOG=n
#############################################################
### Enable Debugging Tools ###
# CONFIG_DEBUG_THREAD_INFO=y
# CONFIG_DEBUG_OPTIMIZATIONS=y
# Console
# CONFIG_CONSOLE=n
# CONFIG_UART_CONSOLE=n
CONFIG_STDOUT_CONSOLE=n
CONFIG_PRINTK=n
CONFIG_EARLY_CONSOLE=n
CONFIG_DEBUG=n
#############################################################
### BT CONFIGS ###
CONFIG_BT=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_PERIPHERAL=y
# CONFIG_BT_DEVICE_NAME="AnyXXXX
# CONFIG_BT_BONDABLE=y
# CONFIG_BT_SMP_ENFORCE_MITM=n
# CONFIG_BT_LBS_SECURITY_ENABLED=n

# Enable Dynamic name modification
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
# Maximum chcaracter of the device name
# (Range: 2 to 248)
CONFIG_BT_DEVICE_NAME_MAX=10

# Enable Device Information Service (DIS)
CONFIG_BT_DIS=y
CONFIG_BT_DIS_MANUF="RTL"
CONFIG_BT_DIS_MODEL="CAB"
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_HW_REV_STR="1.0.1"
CONFIG_BT_DIS_SW_REV=y
CONFIG_BT_DIS_SW_REV_STR="Bootloader: 1.0.1, SoftDevice: 6.1.0, Application: 3.0.1"
CONFIG_BT_DIS_PNP=n

# Enable Battery Service (BAS)
CONFIG_BT_BAS=y

### Enable DFU/OTA ###
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_FPROTECT=y
# CONFIG_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE=n
# CONFIG_BOOT_SIGNATURE_KEY_FILE="C:\nordic\myapps\RES-BPB\priv.pem"

### MTU UPDATE/INCREASE ###
# BLE TX BUF
CONFIG_BT_BUF_ACL_TX_COUNT=3
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_L2CAP_TX_BUF_COUNT=2
CONFIG_BT_L2CAP_TX_MTU=100
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_DATA_LEN_UPDATE=y
#CONFIG_BT_BUF_ACL_RX_SIZE=69
# CONFIG_BT_BUF_ACL_TX_SIZE=251
# CONFIG_BT_L2CAP_TX_MTU=247
#CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
#############################################################
### Enable ADC for battery measurement ###
CONFIG_ADC=y
#############################################################
### General Memory Sizes ###
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
#CONFIG_MAIN_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=1024
#CONFIG_HEAP_MEM_POOL_SIZE=8192
#############################################################
### Enable PWM ###
CONFIG_LED=y
CONFIG_PWM=y
CONFIG_LED_PWM=y
CONFIG_TIMER=y
#############################################################
### Enable Crypto Functionality ###
# The Zephyr CMSIS emulation assumes that ticks are ms, currently
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

# Enable nordic security backend and PSA APIs
CONFIG_CRYPTO=n
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_PSA_CRYPTO_STORAGE_C=y
CONFIG_TRUSTED_STORAGE=y
CONFIG_PSA_INTERNAL_TRUSTED_STORAGE=y


CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=4096

CONFIG_PSA_WANT_ALG_ECDSA=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR=y
CONFIG_PSA_WANT_ECC_SECP_R1_384=y
CONFIG_PSA_WANT_ALG_SHA_384=y
# CONFIG_PSA_WANT_ECC_SECP_R1_256=n
# CONFIG_PSA_WANT_ALG_SHA_256=n
# CONFIG_PSA_WANT_ALG_SHA_512=n


CONFIG_MBEDTLS=n

# For key generation
CONFIG_PSA_WANT_GENERATE_RANDOM=y
#############################################################
### CONFIGS to reduce Memory usage ###
CONFIG_I2C=n 
CONFIG_SPI=n
# CONFIG_SERIAL=n
CONFIG_DYNAMIC_INTERRUPTS=n
#CONFIG_IRQ_OFFLOAD=n
# Memory protection
#CONFIG_THREAD_STACK_INFO=n
CONFIG_THREAD_CUSTOM_DATA=n
CONFIG_FPU=n
CONFIG_SIZE_OPTIMIZATIONS=y

# Disable features not needed
CONFIG_TIMESLICING=n
#CONFIG_MINIMAL_LIBC_MALLOC=n
#CONFIG_LOG=n
CONFIG_ASSERT=n #CONFIG_ASSERT=n would be the lower memory usage option

# Disable Bluetooth features not needed
CONFIG_BT_DEBUG_NONE=y
CONFIG_BT_ASSERT=n #CONFIG_BT_ASSERT=n would be the lower memory usage option
# CONFIG_BT_DATA_LEN_UPDATE=n   #Is needed
CONFIG_BT_PHY_UPDATE=n 
# CONFIG_BT_GATT_CACHING=n  #Is maybe needed
#CONFIG_BT_GATT_SERVICE_CHANGED=n #Is needed
# CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n #Is maybe needed
CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y
# CONFIG_BT_HCI_VS_EXT=n #Is maybe needed

# Disable Bluetooth controller features not needed
CONFIG_BT_CTLR_PRIVACY=n
# CONFIG_BT_CTLR_PHY_2M=n

# Reduce Bluetooth buffers
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=58
CONFIG_BT_BUF_EVT_RX_COUNT=2

CONFIG_BT_CONN_TX_MAX=2
CONFIG_BT_L2CAP_TX_BUF_COUNT=2
CONFIG_BT_BUF_ACL_TX_COUNT=3
# CONFIG_BT_BUF_ACL_TX_SIZE=27

CONFIG_BOOT_BANNER=n
CONFIG_BOOT_DELAY=0
#############################################################
CONFIG_RESET_ON_FATAL_ERROR=y
#############################################################
### Thread Analyzer ###
# CONFIG_THREAD_NAME=y
# CONFIG_THREAD_ANALYZER=y
# CONFIG_THREAD_ANALYZER_AUTO=y
# CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
# CONFIG_THREAD_ANALYZER_USE_PRINTK=y
# CONFIG_CONSOLE=y
# CONFIG_UART_CONSOLE=y
# CONFIG_SERIAL=y
# CONFIG_PRINTK=y
#############################################################
