#In release build debug code and manufacturing scripts are disabled to preserve code space
#In debug/manufacturing build MCUBoot is disabled to enable full flash size code space
CONFIG_OPAL_RELEASE_BUILD=n
CONFIG_BOOTLOADER_MCUBOOT=n

#CONFIG_ZTEST=y
#serial makes spi not working 
CONFIG_SERIAL=y

#i2c makes spi not working, i2c0 must be disabled if spi is used
CONFIG_I2C=y

CONFIG_UART_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_CONSOLE=y

#Console
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_GETLINE=y

#enable SPI
CONFIG_SPI=y
#CONFIG_SPI_ASYNC=y
#CONFIG_SPI_NRFX=y
#CONFIG_NRFX_SPIM0=y

CONFIG_GPIO=y

CONFIG_NEWLIB_LIBC=y
#CONFIG_MINIMAL_LIBC=y
#CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
#CONFIG_MAIN_STACK_SIZE=2048


#enabling internal clock
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n

CONFIG_CBPRINTF_FP_SUPPORT=y

CONFIG_RING_BUFFER=y

CONFIG_GPIO_AS_PINRESET=n

CONFIG_NFCT_PINS_AS_GPIOS=y
CONFIG_ADC=n


#ble minimal 

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=n
CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y

CONFIG_BT_DIS=n

CONFIG_BT_DIS_SERIAL_NUMBER=n
CONFIG_BT_DIS_PNP=n
CONFIG_BT_DIS_FW_REV=n
CONFIG_BT_DIS_HW_REV=n
CONFIG_BT_DIS_SW_REV=n

CONFIG_BT_DIS_MODEL="v0.0.1"
CONFIG_BT_DIS_MANUF="Eclateral"

CONFIG_BT_DIS_FW_REV_STR="v0.0.7"

CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_BAS=y
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_NAME="Opal"
CONFIG_BT_DEVICE_APPEARANCE=0
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=32

CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_BT_MAX_PAIRED=4

#CONFIG_BT_LL_SW_SPLIT=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_SDC_RX_STACK_SIZE=512
# 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_SIGNAL_STACK_SIZE=600
# CONFIG_MAIN_STACK_SIZE=1512
# CONFIG_IDLE_STACK_SIZE=64
# CONFIG_ISR_STACK_SIZE=600

#CONFIG_SDC_RX_STACK_SIZE=1512
CONFIG_BT_RX_STACK_SIZE=1512
CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
CONFIG_BT_HCI_TX_STACK_SIZE=1512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_MPSL_SIGNAL_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2048 
CONFIG_IDLE_STACK_SIZE=256
CONFIG_ISR_STACK_SIZE=1512





CONFIG_NEWLIB_LIBC_NANO=y

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

# Disable Bluetooth features not needed
CONFIG_BT_DEBUG_NONE=y
CONFIG_BT_ASSERT=n
CONFIG_BT_DATA_LEN_UPDATE=y
CONFIG_BT_PHY_UPDATE=y
CONFIG_BT_GATT_CACHING=n

#this was changed because of mcumgr
CONFIG_BT_GATT_SERVICE_CHANGED=y

CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y
CONFIG_BT_HCI_VS_EXT=n

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

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

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

#static passkey
CONFIG_BT_FIXED_PASSKEY=y

#extended data packet
#CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
#CONFIG_BT_RX_BUF_LEN=258
#CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

# CONFIG_BT_BUF_ACL_RX_SIZE=100
# CONFIG_BT_BUF_ACL_TX_SIZE=100

#CONFIG_BT_DATA_LEN_UPDATE=y
# CONFIG_BT_CTLR_DATA_LENGTH=y 
#CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
# CONFIG_BT_CTLR_DATA_LENGTH_MAX=100
#CONFIG_BT_RX_BUF_LEN=255

#MTU parameters can be exchanged
CONFIG_BT_GATT_CLIENT=y

CONFIG_SIZE_OPTIMIZATIONS=y


# CONFIG_BT_L2CAP_TX_MTU = 251
# CONFIG_BT_L2CAP_RX_MTU = 251

#CONFIG_CAF_BLE_STATE_EXCHANGE_MTU=y

#usb 
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Opal"
# PID based on CONFIG_USB_PID_CDC_ACM_SAMPLE=0x0001
CONFIG_USB_DEVICE_PID=0x0001

# enable FOTA

CONFIG_MCUMGR=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_SMP_BT=y

CONFIG_MCUMGR_SMP_BT_AUTHEN=n

# CONFIG_BT_L2CAP_TX_MTU=252
# CONFIG_BT_BUF_ACL_RX_SIZE=256

#for faster upload of image
CONFIG_BT_L2CAP_TX_MTU=521
CONFIG_BT_BUF_ACL_RX_SIZE=521
CONFIG_MCUMGR_BUF_SIZE=656