# Imported from zephyr/samples/net/mqtt_publisher/prj.conf
# If this doesn't work, I blame the idiots who created this mess of a build system.

CONFIG_BUILD_WITH_TFM=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y

# For native_sim specifically:
CONFIG_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=y
CONFIG_PRINTK=n
CONFIG_POSIX_API=y
#CONFIG_UART_NATIVE_TTY=y

CONFIG_RING_BUFFER=y

# Basic networking config.
#CONFIG_NETWORKING=y
#CONFIG_NET_SOCKETS=y
#CONFIG_NET_TCP=y
#CONFIG_NET_LOG=y

CONFIG_NETWORKING=y
CONFIG_NET_CONNECTION_MANAGER=y # Added later.
CONFIG_NET_HOSTNAME_ENABLE=y # Ditto.
# Enable IPv6 support
CONFIG_NET_IPV6=y
# Enable IPv4 support
CONFIG_NET_IPV4=y

# Enable the USB serial I/O capability.
CONFIG_PINCTRL=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y

CONFIG_GPIO=y

# Otherwise you can't print floating point numbers!
CONFIG_CBPRINTF_FP_SUPPORT=y

#CONFIG_NET_IPV6_RA_RDNSS=y # Depends on DNS_RESOLVER. Investigate.
#CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
#CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2

# Enable the MQTT Lib
CONFIG_MQTT_LIB=y
CONFIG_MQTT_KEEPALIVE=1200

#CONFIG_NET_CONFIG_SETTINGS=y
#CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
#CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
#
#CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
#CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
CONFIG_NET_SOCKETS_POLL_MAX=32

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_IDLE_STACK_SIZE=4096
CONFIG_ISR_STACK_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_NET_RX_STACK_SIZE=4096
CONFIG_NET_TX_STACK_SIZE=4096
CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096
CONFIG_NRF_MODEM_LIB_HEAP_SIZE=4096
CONFIG_NRF_MODEM_LIB_SENDMSG_BUF_SIZE=4096

# For IPv6
CONFIG_NET_BUF_DATA_SIZE=2048

#CONFIG_NET_SHELL=y

CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

# DNS Resolution Settings

# CONFIG_ZVFS_POLL_MAX=512
CONFIG_ZVFS_OPEN_MAX=32
# Enable the DNS resolver
CONFIG_DNS_RESOLVER=y
CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG=y
# Enable additional buffers
CONFIG_DNS_RESOLVER_ADDITIONAL_BUF_CTR=5
# Enable additional queries
CONFIG_DNS_RESOLVER_ADDITIONAL_QUERIES=2
# Enable mDNS support
CONFIG_MDNS_RESOLVER=y
# Enable LLMNR support
CONFIG_LLMNR_RESOLVER=n

CONFIG_DNS_RESOLVER_MAX_SERVERS=3
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_NUM_CONCUR_QUERIES=5

# Google DNS IPv4 and IPv6 servers
CONFIG_DNS_SERVER1="8.8.8.8"
CONFIG_DNS_SERVER2="2001:4860:4860::8888"

# Router is needed when resolving using external DNS servers
CONFIG_NET_CONFIG_NEED_IPV6_ROUTER=n

######### MODEM SETTINGS ##########
CONFIG_MODEM=y
CONFIG_NRF_MODEM_LIB=y
# CONFIG_AT_HOST_LIBRARY=y
# CONFIG_AT_CMD_CUSTOM=n
CONFIG_LTE_LINK_CONTROL=y
# CONFIG_LTE_LC_EDRX_MODULE=y
# CONFIG_LTE_LC_PSM_MODULE=y
# CONFIG_MODEM_INFO=y

CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IPV6_MLD=n
# CONFIG_NET_CONNECTION_MANAGER=y
#CONFIG_NRF_MODEM_LIB_NET_IF=y
#CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN=y
#CONFIG_NRF_MODEM_LIB_NET_IF_DOWN_DEFAULT_LTE_DISCONNECT=y

CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# AT command helper libs
# CONFIG_AT_PARSER=y
# CONFIG_AT_MONITOR=y

CONFIG_HW_STACK_PROTECTION=y

######### DEBUGGING MODE ##########
# CONFIG_DEBUG=y
# CONFIG_DEBUG_INFO=y
# CONFIG_DEBUG_THREAD_INFO=y
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y

CONFIG_NRF_MODEM_LIB_TRACE=n
CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_UART=n

# Debugging configuration
CONFIG_THREAD_NAME=y
# CONFIG_THREAD_ANALYZER=y
# CONFIG_THREAD_ANALYZER_AUTO=y
# CONFIG_THREAD_ANALYZER_AUTO_STACK_SIZE=2048
# CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
# CONFIG_THREAD_ANALYZER_USE_PRINTK=y

CONFIG_TRACING=n
CONFIG_TRACING_USER=n
# CONFIG_TRACING_NET_CORE=y
# CONFIG_TRACING_NET_SOCKETS=y
# CONFIG_TRACING_OBJECT_TRACKING=y
# 
# CONFIG_SEGGER_SYSTEMVIEW=y

CONFIG_NET_LOG=y
CONFIG_MQTT_LOG_LEVEL_DBG=y
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
#CONFIG_LOG_BUFFER_SIZE=4096
#CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
CONFIG_LOG_MODE_DEFERRED=n

# Possibly important values.
CONFIG_POSIX_MAX_FDS=32
CONFIG_MODEM_SOCKET=y
CONFIG_MODEM_SOCKET_PACKET_COUNT=20

# CONFIG_NRF_MODEM_LIB_MEM_DIAG=y
# CONFIG_NRF_MODEM_LIB_MEM_DIAG_ALLOC=y
# CONFIG_NRF_MODEM_LIB_MEM_DIAG_DUMP=y
CONFIG_NRF_MODEM_LIB_ON_FAULT_RESET_MODEM=y
CONFIG_NRF_MODEM_LIB_SENDMSG_BUF_SIZE=4096
CONFIG_NRF_MODEM_LIB_SHMEM_RX_SIZE=4096
CONFIG_NRF_MODEM_LIB_SHMEM_TX_SIZE=4096

CONFIG_MQTT_CLEAN_SESSION=y

# Add asserts
# CONFIG_ASSERT=y
# CONFIG_ASSERT_VERBOSE=y
# CONFIG_ASSERT_NO_COND_INFO=n
# CONFIG_ASSERT_NO_MSG_INFO=n
# CONFIG_THREAD_NAME=y
# CONFIG_STACK_SENTINEL=y
