# ==============================
# General Debugging and Logging
# ==============================

CONFIG_LOG=y                                 # Enable logging framework
CONFIG_LOG_BACKEND_UART=y                    # Use UART backend for logs
CONFIG_LOG_PRINTK=n                          # Allow printk for logs
CONFIG_CBPRINTF_FP_SUPPORT=y                 # Enable floating-point support in logs

# Enable console for debug purposes
CONFIG_CONSOLE=y

CONFIG_PRINTK=n                              # Enable printk debugging

CONFIG_SHELL=n                               # Enable Zephyr Shell for debugging
CONFIG_SHELL_LOG_BACKEND=n
CONFIG_SHELL_CMD_BUFF_SIZE=128

# Enable RTT (Real-Time Transfer) for logs (alternative to UART)
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=y                        # Disable UART console if RTT is enabled
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=512
CONFIG_SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL=y

CONFIG_LOG_BLOCK_IN_THREAD=y
CONFIG_LOG_BUFFER_SIZE=256
CONFIG_DEBUG=n                               # Enable debugging
CONFIG_DEBUG_INFO=n
CONFIG_DEBUG_THREAD_INFO=n

# CONFIG_NCS_BOOT_BANNER=y                     # Enable NCS boot banner
CONFIG_BOOT_BANNER=y

# Enable UART support
CONFIG_SERIAL=y

# ==============================
# Peripheral and Sensor Drivers
# ==============================

CONFIG_I2C=y                                 # Enable I2C interface
CONFIG_SPI=y                                 # Enable SPI interface
CONFIG_ADC=y                                 # Enable ADC driver

CONFIG_SENSOR=y                              # Enable generic sensor support
CONFIG_TMP116=y                              # Enable TMP116 temperature sensor
CONFIG_BMI270=y                              # Enable BMI270 accelerometer
CONFIG_BMI270_TRIGGER_GLOBAL_THREAD=y

CONFIG_WATCHDOG=y                            # Enable watchdog timer
CONFIG_WDT_LOG_LEVEL_DBG=y
CONFIG_WDT_DISABLE_AT_BOOT=n

# Enable LED and regulator drivers
CONFIG_LED=y
CONFIG_REGULATOR=y

# Enable power management IC (NPMX)
# CONFIG_NPMX=y
# CONFIG_NPMX_DEVICE_NPM1300=y

# Enable Nordic Fuel Gauge and BMI270 (Accelerometer and Gyroscope)
CONFIG_NRF_FUEL_GAUGE=y

# Disable SPI NOR flash driver (if not used)
CONFIG_SPI_NOR=y
CONFIG_NORDIC_QSPI_NOR=n

# ==============================
# Power and Memory Optimizations
# ==============================

# Power management configuration
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

# ==============================
# Memory Optimizations
# ==============================

# Configure memory pool and stack sizes
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_ASSERT=n
CONFIG_THREAD_ANALYZER=n
CONFIG_SIZE_OPTIMIZATIONS=y

# ==============================
# Flash Configuration
# ==============================

CONFIG_FLASH=y                               # Enable flash memory support
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FLASH_JESD216_API=y

CONFIG_BT_SETTINGS=y                         # Enable Bluetooth settings
CONFIG_SETTINGS=y                            # Enable settings subsystem
CONFIG_NVS=y                                 # Enable Non-Volatile Storage
CONFIG_NVS_LOG_LEVEL_DBG=y

# ==============================
# Bluetooth Settings
# ==============================

# CONFIG_NCS_SAMPLES_DEFAULTS=y

# Enable Bluetooth and controller settings
CONFIG_BT=y
CONFIG_BT_HCI=y
CONFIG_BT_CTLR=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_BROADCASTER=n
CONFIG_BT_SMP=y
CONFIG_BT_BONDABLE=y
CONFIG_BT_CTLR_ADV_EXT=n
CONFIG_BT_DEVICE_APPEARANCE=1345
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_GATT_CLIENT=y

# Bluetooth security and bonding settings
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y
CONFIG_BT_ID_UNPAIR_MATCHING_BONDS=y
CONFIG_BT_PRIVACY=n
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_USER_PHY_UPDATE=y

# Bluetooth buffer and connection settings
CONFIG_BT_BUF_ACL_RX_SIZE=247
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_BUF_ACL_TX_SIZE=256
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_L2CAP_TX_BUF_COUNT=10
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=247
CONFIG_BT_CTLR_RX_BUFFERS=2
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

CONFIG_BT_GATT_DM=y

# Allow only LESC pairing
# CONFIG_BT_SMP_SC_PAIR_ONLY=y

# Configure Bluetooth connection settings
CONFIG_BT_CTLR_TX_PWR_0=y
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

# Enable PHY updates
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y

# Enable Bluetooth shell for debugging
CONFIG_BT_SHELL=n

# Enable BT NUS (Nordic UART Service) shell for testing
# CONFIG_SHELL_BT_NUS=y

# Enable Battery Service (BAS) for battery level reporting
CONFIG_BT_BAS=y

# ==============================
# Cryptography
# ==============================

CONFIG_TINYCRYPT=y                           # Enable TinyCrypt for secure operations
CONFIG_BT_TINYCRYPT_ECC=y

# ==============================
# Reboot and Misc Settings
# ==============================

CONFIG_REBOOT=y                              # Enable reboot functionality

# ==============================
# DFU Support and Bootloader
# ==============================

# Enable MCUboot and FOTA
CONFIG_BOOTLOADER_MCUBOOT=y
# CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
# CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="priv.pem"
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y

CONFIG_MCUMGR=y
CONFIG_MCUMGR_GRP_IMG=y
CONFIG_IMG_MANAGER=y

# CONFIG_IMG_MANAGER dependencies
CONFIG_STREAM_FLASH=y

# CONFIG_MCUMGR dependencies
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y

# Required for CONFIG_IMG_MANAGER
CONFIG_FLASH_MAP=y

# Enable the Bluetooth mcumgr transport (unauthenticated).
CONFIG_MCUMGR_TRANSPORT_BT=y
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y

CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=2475
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=2048

# Enable erase and reset support
CONFIG_IMG_ERASE_PROGRESSIVELY=y  # Erase flash progressively during updates

# Enable settings for managing DFU flags
CONFIG_SETTINGS_RUNTIME=y         # Enable runtime settings storage

# Enable the file system if required (e.g., for storing configuration or logs)
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y

# Allow erase and reset commands
CONFIG_MCUMGR_GRP_FS=y                   # Enable filesystem management group