
CONFIG_NCS_SAMPLES_DEFAULTS=y

# Bluetooth
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_GATT_WRITABLE=y
CONFIG_BT_PRIVACY=n
CONFIG_SETTINGS=n
CONFIG_BT_SETTINGS=n

CONFIG_FPU=y
CONFIG_NEWLIB_LIBC_NANO=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

# Bootloader
CONFIG_MCUMGR=y
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_MCUMGR_TRANSPORT_BT=y
CONFIG_DK_LIBRARY=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y

# Drivers and peripherals
CONFIG_I2C=n
CONFIG_WATCHDOG=y
CONFIG_GPIO=y
CONFIG_SPI=n
CONFIG_SERIAL=y
CONFIG_ADC=y
CONFIG_HW_ID_LIBRARY=y
CONFIG_HW_ID_LIBRARY_SOURCE_DEVICE_ID=y

# NFC stuff
CONFIG_NFC_NDEF=y
CONFIG_NFC_T4T_NRFXLIB=y
CONFIG_NDEF_FILE_SIZE=64
CONFIG_NFC_NDEF_MSG=y
CONFIG_NFC_NDEF_RECORD=y
CONFIG_NFC_NDEF_URI_MSG=y
CONFIG_NFC_NDEF_URI_REC=y
CONFIG_NFC_NDEF_TEXT_RECORD=n

# Flash/NVS stuff
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_MPU=y
CONFIG_SOC_FLASH_NRF_UICR=y
CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y

# Crypto
CONFIG_NRF_SECURITY=y
CONFIG_PSA_CRYPTO_DRIVER_OBERON=y
CONFIG_PSA_WANT_GENERATE_RANDOM=y
CONFIG_PSA_WANT_KEY_TYPE_AES=y
CONFIG_PSA_WANT_ALG_GCM=y
CONFIG_PSA_WANT_AES_KEY_SIZE_128=y
CONFIG_PSA_WANT_ALG_CTR_DRBG=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=512

# Power management
CONFIG_POWEROFF=y

# Interrupts
CONFIG_DYNAMIC_INTERRUPTS=n
CONFIG_IRQ_OFFLOAD=n

# Memory protection
CONFIG_THREAD_STACK_INFO=n
CONFIG_THREAD_CUSTOM_DATA=n

# Boot
CONFIG_BOOT_BANNER=n
CONFIG_BOOT_DELAY=0

# Console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_EARLY_CONSOLE=n
CONFIG_LOG=y
CONFIG_UART_INTERRUPT_DRIVEN=y

# # Shell
# CONFIG_SHELL=y
# CONFIG_SHELL_STACK_SIZE=1024
# CONFIG_SHELL_BACKEND_SERIAL=n
# # Enable RTT shell
# CONFIG_USE_SEGGER_RTT=y
# CONFIG_SHELL_BACKEND_RTT=y
# CONFIG_SHELL_AUTOSTART=y

# Build
CONFIG_SIZE_OPTIMIZATIONS=y

# In order to correctly tune the stack sizes for the threads the following
# Configurations can enabled to print the current use:
# 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

# Example output of thread analyzer
# SDC RX              : unused 816 usage 208 / 1024 (20 %)
# BT RX               : unused 1784 usage 416 / 2200 (18 %)
# BT TX               : unused 992 usage 544 / 1536 (35 %)
# thread_analyzer     : unused 136 usage 376 / 512 (73 %)
# sysworkq            : unused 1824 usage 224 / 2048 (10 %)
# MPSL signal         : unused 520 usage 504 / 1024 (49 %)
# idle 00             : unused 192 usage 64 / 256 (25 %)
# main                : unused 136 usage 888 / 1024 (86 %)
# Configurations set based on thread analyzer output.
CONFIG_BT_RX_STACK_SIZE=1024
CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
CONFIG_BT_HCI_TX_STACK_SIZE=640
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MPSL_WORK_STACK_SIZE=640
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=128
CONFIG_ISR_STACK_SIZE=1024

# Disable features not needed
CONFIG_TIMESLICING=n
CONFIG_MINIMAL_LIBC_MALLOC=n
CONFIG_ASSERT=n

# Disable Bluetooth features not needed
CONFIG_BT_DEBUG_NONE=y
CONFIG_BT_ASSERT=n
CONFIG_BT_DATA_LEN_UPDATE=n
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_GATT_CACHING=n
CONFIG_BT_GATT_SERVICE_CHANGED=y
CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=n
CONFIG_BT_HCI_VS_EXT=n

# 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