# BEGIN Configurations from basic/minimal

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


#https://devzone.nordicsemi.com/f/nordic-q-a/109194/reducing-rom-size-for-the-nrf52833/477386

CONFIG_NCS_SAMPLES_DEFAULTS=n

CONFIG_BT=n
CONFIG_BT_PERIPHERAL=y

CONFIG_DK_LIBRARY=n

# Enable RTT
CONFIG_USE_SEGGER_RTT=n
CONFIG_RTT_CONSOLE=n
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP=y
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096

# Enable GPIO
CONFIG_GPIO=y

# Enable UART driver
CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y

# Power Management aktivieren
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

# Interrupts
CONFIG_DYNAMIC_INTERRUPTS=n
CONFIG_IRQ_OFFLOAD=n

# Memory protection
CONFIG_THREAD_STACK_INFO=n
CONFIG_THREAD_CUSTOM_DATA=n
CONFIG_FPU=n

# Boot
CONFIG_BOOT_BANNER=n
CONFIG_BOOT_DELAY=0
# USB related configs
CONFIG_USB_DEVICE_STACK=n
CONFIG_USB_DEVICE_PRODUCT="ILOCKIT_PRO"
CONFIG_USB_DEVICE_PID=0x9876
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=n
CONFIG_USB_DEVICE_LOOPBACK=n
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=n
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

# Enable I2C driver
CONFIG_I2C=y
CONFIG_I2C_CALLBACK=y

# Enable console
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_STDOUT_CONSOLE=n
CONFIG_PRINTK=n
CONFIG_EARLY_CONSOLE=n

# Build
CONFIG_SIZE_OPTIMIZATIONS=y

# Enable logging
CONFIG_LOG=n
CONFIG_LOG_MODE_MINIMAL=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

CONFIG_LOG_MODE_DEFERRED=n

# ARM
CONFIG_ARM_MPU=n

# Enable nordic security backend and PSA APIs
CONFIG_NRF_SECURITY=n
CONFIG_MBEDTLS_PSA_CRYPTO_C=n

CONFIG_MBEDTLS_ENABLE_HEAP=n
CONFIG_MBEDTLS_HEAP_SIZE=8192

CONFIG_PSA_WANT_ALG_SHA_256=n

# CRC Bibliothek hinzufügen
CONFIG_CRC=y

# Dynamisches Festlegen des Advertisment Namens
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
# Länge muss 25 betragen, wenn der Wert kleiner gewählt wird, startet das Advertisment nicht
CONFIG_BT_DEVICE_NAME_MAX=25

# Anzahl maximaler Verbindungen
CONFIG_BT_MAX_CONN=4

# Anzahl maximaler Verbindungen mit Smartphone
CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=3

# PWM aktivieren
CONFIG_PWM=y

# Reboot Library aktivieren
CONFIG_REBOOT=y

# NVS/Flash aktivieren
CONFIG_FLASH=y
CONFIG_NVS=y
CONFIG_NVS_LOG_LEVEL_DBG=n
CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_FLASH_MAP=n
CONFIG_FLASH_MAP_CUSTOM=y

# RAM Memory retention aktivieren
CONFIG_RETENTION=y
CONFIG_RETAINED_MEM=y

# Abfrage der RSSI-Werte aktivieren
CONFIG_BT_CTLR_CONN_RSSI=y

# Multithreading aktivieren
CONFIG_MULTITHREADING=y

# Watchdog hinzufügen
CONFIG_WATCHDOG=y
CONFIG_WDT_DISABLE_AT_BOOT=n

# SAADC Wandler und PPI aktivieren
CONFIG_NRFX_SAADC=y
CONFIG_NRFX_PPI=y
CONFIG_NRFX_TIMER2=y

# Handsender Konfiguration
CONFIG_BT_CENTRAL=y
CONFIG_BT_SCAN=y
CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DM=y
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_SETTINGS=y
CONFIG_MAIN_STACK_SIZE=1536
CONFIG_BT_SCAN_WITH_IDENTITY=y
CONFIG_BT_FILTER_ACCEPT_LIST=y
CONFIG_BT_CTLR_PRIVACY=y

#https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/building-a-ble-application-on-ncs-sdk---contrasting-to-softdevice-based-ble-applications---part-2-central-role#mcetoc_1f50ptl3g2

# FOTA update Service
#CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
#https://www.youtube.com/watch?v=fCU8x-pmtqU


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

CONFIG_CBPRINTF_NANO=y
CONFIG_CBPRINTF_LIBC_SUBSTS=n
CONFIG_MINIMAL_LIBC=y
CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_TIMEOUT_64BIT=n
CONFIG_LOG=n
CONFIG_ASSERT=n # should be enabled while developing, disabled for production
CONFIG_CONSOLE=n # should be enabled while developing, disabled for production
CONFIG_USE_SEGGER_RTT=n # is this required for development? what does this really do?

# 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=n
CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y
CONFIG_BT_HCI_VS=n
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=n
CONFIG_BT_SETTINGS=n
CONFIG_BT_HCI=y
CONFIG_BT_EXT_ADV=n
CONFIG_BT_LL_SOFTDEVICE=n
CONFIG_BT_GATT_READ_MULTIPLE=n
CONFIG_BT_GATT_READ_MULT_VAR_LEN=n
CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_CTLR_LE_PING=n
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=43
CONFIG_BT_BUF_EVT_RX_COUNT=2

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

# NRFX PWM
CONFIG_NRFX_PWM1=y

# DFU Service
#CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_MCUMGR=y
CONFIG_MCUMGR_TRANSPORT_BT=y