if PERCEPIO_DFM

config PERCEPIO_DFM_CFG_FIRMWARE_VERSION
	string "Firmware version"
	default "X.Y.Z"
	help
		The firmware verison. This needs to be set to differentiate alerts between different versions

config PERCEPIO_DFM_CFG_PRODUCTID
	int "Product id"
	default 1
	help
		An identifier to identify the product type.

config PERCEPIO_DFM_CFG_ENABLE_DEBUG_PRINT
	bool "Enable debug messages"
	default n
	help
		Enable Diagnostic messages from DFM_DEBUG(	.). Will use DFM_ERROR to output debug information.

menu "Cloudport Config"

choice PERCEPIO_DFM_CFG_CLOUDPORT
	prompt "Cloudport"
	default PERCEPIO_DFM_CFG_CLOUDPORT_NONE

config PERCEPIO_DFM_CFG_CLOUDPORT_SERIAL
	bool "Serial"
	help
		Send Alerts and chunks through the serial port, used with a serial terminal and accompanying
		scripts, which post-processes the data and makes it available in Detect or DevAlert.

config PERCEPIO_DFM_CFG_CLOUDPORT_NONE
	bool "None"
	help
		Don't send alerts via the cloudport

endchoice # choice PERCEPIO_DFM_CFG_CLOUDPORT

endmenu # menu "Cloudport Config"

menu "Storageport Config"

choice PERCEPIO_DFM_CFG_STORAGEPORT
	prompt "Storageport"
	default PERCEPIO_DFM_CFG_STORAGEPORT_NONE

config PERCEPIO_DFM_CFG_STORAGEPORT_NONE
	bool "None"
	help
		Don't store alerts.

config PERCEPIO_DFM_CFG_STORAGEPORT_FLASH
	bool "Flash via FCB"
	depends on (FLASH && FLASH_MAP && FCB)
	help
		Storage alerts on flash via the Zephyr FCB module.

config PERCEPIO_DFM_CFG_STORAGEPORT_FILESYSTEM
	bool "Filesystem"
	depends on (FLASH && FLASH_MAP && FILE_SYSTEM)
	help
		Store alerts in a location on a filesystem. Uses
		the zephyr file system abstraction.

endchoice # choice PERCEPIO_DFM_CFG_STORAGEPORT

endmenu # menu "Storageport Config"

menu "Buffer Settings"

config PERCEPIO_DFM_CFG_MAX_PAYLOAD_CHUNK_SIZE
	int "Maximum payload chunk size"
	default 1000
	help
		The maximum size of a "chunk" that will be stored or sent.

config PERCEPIO_DFM_CFG_DEVICE_NAME_MAX_LEN
	int "Maximum device name length"
	default 32
	help
		The maximum length of the device name.
	
config PERCEPIO_DFM_CFG_MAX_PAYLOADS
	int "Max Payloads"
	default 8
	help
		The maximum number of payloads which can be attached to a single alert.

config PERCEPIO_DFM_CFG_MAX_SYMPTOMS
	int "Max Symptoms"
	default 8
	help
		The maximum number of symptoms which can be attached to a single alert.

config PERCEPIO_DFM_CFG_FIRMWARE_VERSION_MAX_LEN
	int "Maximum firmware version string length"
	default 64
	help
		The max firmware version string length.

config PERCEPIO_DFM_CFG_DESCRIPTION_MAX_LEN
	int "Description string maximum length"
	default 64
	help
		The maximum length of the description string.

config PERCEPIO_DFM_CFG_DELAY_BETWEEN_SEND
	int "Delay between sends"
	default 0
	help
		Create a delay between transfers. Should normally not be needed.

endmenu # menu "Buffer Settings"

menu "Strategy Settings"

choice PERCEPIO_DFM_CFG_SELECTED_STORAGE_STRATEGY
	prompt "Storage strategy"
	default PERCEPIO_DFM_CFG_SELECTED_STORAGE_STRATEGY_IGNORE

config PERCEPIO_DFM_CFG_SELECTED_STORAGE_STRATEGY_IGNORE
	bool "Ignore"
	help
		Never store alerts/payloads

config PERCEPIO_DFM_CFG_SELECTED_STORAGE_STRATEGY_OVERWRITE
	bool "Overwrite"
	help
		Overwrite old alerts/payloads if the storage is full.

config PERCEPIO_DFM_CFG_SELECTED_STORAGE_STRATEGY_SKIP
	bool "Skip"
	help
		Don't save the new alert/payload of the storage already is full.

endchoice # choice "PERCEPIO_SELECTED_STORAGE_STRATEGY"

choice PERCEPIO_DFM_CFG_SELECTED_CLOUD_STRATEGY
	prompt "Cloud strategy"
	default PERCEPIO_DFM_CFG_SELECTED_CLOUD_STRATEGY_ONLINE

config PERCEPIO_DFM_CFG_SELECTED_CLOUD_STRATEGY_ONLINE
	bool "Online"
	help
		Attempt to send alerts/payloads.

config PERCEPIO_DFM_CFG_SELECTED_CLOUD_STRATEGY_OFFLINE
	bool "Offline"
	help
		Don't attempt to send alerts/payloads.

endchoice

choice PERCEPIO_DFM_CFG_SELECTED_SESSIONID_STRATEGY
	prompt "Session Id Strategy"
	default PERCEPIO_DFM_CFG_SELECTED_SESSIONID_STRATEGY_ONALERT

config PERCEPIO_DFM_CFG_SELECTED_SESSIONID_STRATEGY_ONSTARTUP
	bool "On Startup"
	help
		Set the session id on startup

config PERCEPIO_DFM_CFG_SELECTED_SESSIONID_STRATEGY_ONALERT
	bool "On Alert"
	help
		Set the session id when an alert is generated
		
endchoice # choice "PERCEPIO_DFM_CFG_SELECTED_SESSIONID_STRATEGY"

endmenu # menu "Strategy Settings"

menuconfig PERCEPIO_DFM_CFG_RETAINED_MEMORY
	bool "Retained Memory support"
	depends on (RETAINED_MEM && RETENTION)
	help
		Enable the ability to temporarily store alerts in retained RAM.
		This can be used when the storageport is unavailable from the
		current context (hardfault). After reboot the alert can be either
		sent to cloudport or saved to storageport.
		This requires that you set up a retained memory region called
		retention0 in a devicetree overlay. Depending on your use case
		you might have to disable the mutex usage protecting this memory
		in order to write to it (such as writing from a hardfault context).

menuconfig PERCEPIO_DFM_CFG_ENABLE_COREDUMPS
	bool "Enable Core Dump support"
	default n
	depends on (DEBUG_COREDUMP && DEBUG_COREDUMP_BACKEND_OTHER && DEBUG_COREDUMP_MEMORY_DUMP_MIN)
	help
		Support for adding Core Dumps to alerts.

if PERCEPIO_DFM_CFG_ENABLE_COREDUMPS

choice PERCEPIO_DFM_CFG_COREDUMP_STRATEGY
	prompt "Core Dump strategy"
	default PERCEPIO_DFM_CFG_COREDUMP_RETAIN

config PERCEPIO_DFM_CFG_COREDUMP_RETAIN
	bool "Save in Retained Memory"
	help
		This requires that Retained Memory has been enabled and configured properly.
		See the Getting Started guide for more details.

config PERCEPIO_DFM_CFG_COREDUMP_STORE
	bool "Store using selected storageport"
	help
		Core Dumps will be stored using the selected storageport. If the storageport
		isn't compatible with the context where the coredump is generated then it will not work.

endchoice # choice "PERCEPIO_DFM_CFG_COREDUMP_STRATEGY"

config PERCEPIO_DFM_CFG_STACKDUMP_SIZE
	int "Stack Dump size"
	default 300
	help
		How many bytes to dump from the stack (relative to the current stack pointer)

config PERCEPIO_DFM_CFG_MAX_COREDUMP_SIZE
	int "Core Dump size"
	default 1000
	help
		Maximum total size of the Core Dump. Since this uses a buffer in memory as a temporary work area,
		this will affect memory usage.

config PERCEPIO_DFM_CFG_ADD_TRACE
	bool "Save Trace"
	depends on (PERCEPIO_TRACERECORDER && PERCEPIO_TRC_CFG_STREAM_PORT_RINGBUFFER)
	default y
	help
		If this is set to true, crashcatcher will always try to save a trace with the Alert.
		Please not that this feature requires the Percepio Trace Recorder to be included in
		the project as well.

endif # PERCEPIO_DFM_ENABLE_COREDUMPS

if PERCEPIO_DFM_CFG_STORAGEPORT_FLASH
rsource "storageports/Flash/Kconfig"
endif # PERCEPIO_DFM_CFG_STORAGEPORT_FLASH

if PERCEPIO_DFM_CFG_STORAGEPORT_FILESYSTEM
rsource "storageports/Filesystem/Kconfig"
endif # PERCEPIO_DFM_CFG_STORAGEPORT_FILESYSTEM

if PERCEPIO_DFM_CFG_STORAGEPORT_RAM
rsource "storageports/Ram/Kconfig"
endif # PERCEPIO_DFM_CFG_STORAGEPORT_RAM

endif # PERCEPIO_DFM
