# Copyright (c) 2023 Trackunit Corporation
# SPDX-License-Identifier: Apache-2.0

menuconfig MODEM_MODULES
	bool "Modem modules"
	select EXPERIMENTAL

if MODEM_MODULES

config MODEM_CHAT
	bool "Modem chat module"
	select RING_BUFFER
	select MODEM_PIPE

if MODEM_CHAT

config MODEM_CHAT_LOG_BUFFER_SIZE
	int "Modem chat log buffer size in bytes"
	default 128

endif

config MODEM_CMUX
	bool "Modem CMUX module"
	select MODEM_PIPE
	select RING_BUFFER
	select EVENTS
	select CRC

if MODEM_CMUX

config MODEM_CMUX_DEFAULT_MTU_127
	bool
	default y if (DT_HAS_QUECTEL_BG95_ENABLED || DT_HAS_QUECTEL_EG25_G_ENABLED || \
		      DT_HAS_SIMCOM_SIM7080_ENABLED || DT_HAS_U_BLOX_SARA_R4_ENABLED || \
		      DT_HAS_U_BLOX_SARA_R5_ENABLED || DT_HAS_SWIR_HL7800_ENABLED || \
		      DT_HAS_TELIT_ME910G1_ENABLED || DT_HAS_TELIT_ME310G1_ENABLED || \
		      DT_HAS_SQN_GM02S_ENABLED || DT_HAS_QUECTEL_EG800Q_ENABLED || \
		      DT_HAS_SIMCOM_A76XX_ENABLED)
	help
	  Use the default MTU size of 127 bytes for the CMUX module on certain modems.
	  This must match the AT+CMUX commands in the modem_cellular driver.

config MODEM_CMUX_MTU
	int "CMUX MTU size in bytes"
	range 16 1500
	default 127 if MODEM_CMUX_DEFAULT_MTU_127
	default 31
	help
	  Maximum Transmission Unit (MTU) size for the CMUX module.
	  Linux ldattach defaults to 127 bytes, 3GPP TS 27.010 to 31.

config MODEM_CMUX_WORK_BUFFER_SIZE
	int "CMUX module work buffer size in bytes"
	range 23 1507
	default 134 if MODEM_CMUX_DEFAULT_MTU_127
	default 38
	help
	  Size of the work buffer used by the CMUX module.
	  Recommended size is MODEM_CMUX_MTU + 7 (CMUX header size).

module = MODEM_CMUX
module-str = modem_cmux
source "subsys/logging/Kconfig.template.log_config"

endif

config MODEM_PIPE
	bool "Modem pipe module"
	select EVENTS

config MODEM_PIPELINK
	bool "Modem pipelink module"
	depends on MODEM_PIPE

config MODEM_PPP
	bool "Modem PPP module"
	depends on NET_L2_PPP
	select MODEM_PIPE
	select RING_BUFFER
	select CRC

if MODEM_PPP

config MODEM_PPP_NET_BUF_FRAG_SIZE
	int "Network buffer fragment size"
	default NET_BUF_DATA_SIZE if NET_BUF_FIXED_DATA_SIZE
	default 128

endif

config MODEM_STATS
	bool "Modem statistics"
	depends on SHELL
	help
	  Enables modem statistics shell commands which track the usage of
	  buffers across the modem modules. The statistics are useful for
	  scaling buffer sizes, as these are application specific.

config MODEM_STATS_BUFFER_NAME_SIZE
	int "Maximum string size of modem stats buffer name"
	default 32
	range 8 64

config MODEM_UBX
	bool "Modem U-BLOX module"
	select RING_BUFFER
	select MODEM_PIPE
	help
	  Enable Modem U-BLOX module.

if MODEM_UBX

config MODEM_UBX_LOG_BUFFER
	int "Modem U-BLOX log buffer size"
	default 128

endif

module = MODEM_MODULES
module-str = modem_modules
source "subsys/logging/Kconfig.template.log_config"

rsource "backends/Kconfig"

endif
