# Copyright (c) 2017 Linaro Limited
# SPDX-License-Identifier: Apache-2.0

menuconfig LWM2M
	bool "OMA LWM2M protocol stack"
	select COAP
	select HTTP_PARSER_URL
	select NET_SOCKETS
	select NET_SOCKETS_POSIX_NAMES
	help
	  This option adds logic for managing OMA LWM2M data

if LWM2M

module = LWM2M
module-dep = LOG
module-str = Log level for LWM2M library
source "subsys/net/Kconfig.template.log_config.net"

config LWM2M_DTLS_SUPPORT
	bool "Enable DTLS support in the LwM2M client"
	select TLS_CREDENTIALS
	select NET_SOCKETS_SOCKOPT_TLS
	select NET_SOCKETS_ENABLE_DTLS

config LWM2M_DNS_SUPPORT
	bool "Enable DNS support in the LWM2M client"
	default y if DNS_RESOLVER

config LWM2M_ENGINE_STACK_SIZE
	int "LWM2M engine stack size"
	default 2560 if NET_LOG
	default 2048
	help
	  Set the stack size for the LWM2M library engine (used for handling
	  OBSERVE and NOTIFY events)

config LWM2M_ENGINE_MAX_MESSAGES
	int "LWM2M engine max. message object"
	default 10
	help
	  Set the maximum message objects for the LWM2M library client

config LWM2M_COAP_BLOCK_SIZE
	int "LWM2M CoAP block-wise transfer size"
	default 256
	range 64 1024
	help
	  CoAP block size used by LWM2M when performing block-wise
	  transfers. Possible values: 16, 32, 64, 128, 256, 512 and 1024.

config LWM2M_ENGINE_MESSAGE_HEADER_SIZE
	int "Room for CoAP header data"
	default 48
	range 24 128
	help
	  Extra room allocated to handle CoAP header data

config LWM2M_ENGINE_VALIDATION_BUFFER_SIZE
	int "Size of the validation buffer for the incoming data"
	default 64
	help
	  LwM2M will use the validation buffer during the write operation, to
	  decode the resource value before validating it (applies for resources
	  for which validation callback has been registered). Set this value to
	  the maximum expected size of the resources that need to be validated
	  (and thus have validation callback registered).
	  Setting the validation buffer size to 0 disables validation support.

config LWM2M_ENGINE_MAX_PENDING
	int "LWM2M engine max. pending objects"
	default 5
	help
	  Set the maximum pending objects for the LWM2M library client

config LWM2M_ENGINE_MAX_REPLIES
	int "LWM2M engine max. reply objects"
	default 5
	help
	  Set the maximum reply objects for the LWM2M library client

config LWM2M_ENGINE_MAX_OBSERVER
	int "Maximum # of observable LWM2M resources"
	default 10
	range 5 200
	help
	  This value sets the maximum number of resources which can be
	  added to the observe notification list.

config LWM2M_CANCEL_OBSERVE_BY_PATH
	bool "Use path matching as fallback for cancel-observe"
	help
	  Some ambiguous language in the LwM2M spec causes some LwM2M server
	  implementations to implement cancel-observe by specifying the resource
	  path rather than the token of the original observe request. Without
	  this option, cancel-observe may not work properly when connecting to
	  those servers.

config LWM2M_ENGINE_DEFAULT_LIFETIME
	int "LWM2M engine default server connection lifetime"
	default 30
	range 15 65535
	help
	  Set the default lifetime (in seconds) for the LWM2M library engine

config LWM2M_SECONDS_TO_UPDATE_EARLY
	int "LWM2M Registration Update transmission time before timeout"
	default 6
	range 1 65535
	help
	  Time in seconds before the registration timeout, when the LWM2M
	  Registration Update is sent by the engine. In networks with large
	  round trip times (like NB-IoT), it might be needed to set this value
	  higher, in order to allow the response to arrive before timeout.

config LWM2M_QUEUE_MODE_ENABLED
	bool "Enable Queue Mode UDP binding"
	help
	  Set the transport binding to UDP with Queue Mode (UQ).

config LWM2M_QUEUE_MODE_UPTIME
	int "Specify time the LWM2M client should stay online in queue mode."
	default 93
	help
	  This config specifies time (in seconds) the device should stay online
	  after sending a message to the server. Note, that LWM2M specification
	  recommends this to be CoAP MAX_TRANSMIT_WAIT parameter (which
	  defaults to 93 seconds, see RFC 7252), it does not forbid other
	  values though.

config LWM2M_RD_CLIENT_SUPPORT
	bool "support for LWM2M client bootstrap/registration state machine"
	default y
	help
	  Client will use registration state machine to locate and connect to
	  LWM2M servers (including bootstrap server support)

config LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP
	bool "Enable bootstrap support"
	help
	  Enabling this setting allows the RD client to support bootstrap mode.

config LWM2M_RD_CLIENT_ENDPOINT_NAME_MAX_LENGTH
	int "Maximum length of client endpoint name"
	depends on LWM2M_RD_CLIENT_SUPPORT
	default 33
	help
	  Default: room for 32 hexadeciaml digits (UUID) + NULL

config LWM2M_RD_CLIENT_MAX_RETRIES
	int "Specify maximum number of registration retries"
	default 5
	help
	  Specify maximum number of registration retries, before the application
	  is notified about the network failure. Once application is notified,
	  it's up to the application to handle this situation in a way
	  appropriate for the specific use-case (for instance by waiting for
	  LTE link to be re-established).

config LWM2M_PEER_PORT
	int "LWM2M server port"
	depends on LWM2M_RD_CLIENT_SUPPORT
	default 5683
	help
	  This is the default server port to connect to for LWM2M communication

config LWM2M_SECURITY_INSTANCE_COUNT
	int "Maximum # of LWM2M Security object instances"
	default 2 if LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP
	default 1
	range 1 10
	help
	  This setting establishes the total count of LWM2M Security instances
	  available to the client.

config LWM2M_SECURITY_KEY_SIZE
	int "Buffer size of the security key resources"
	default 16
	range 16 256
	help
	  This setting establishes the size of the key (pre-shared / public)
	  resources in the security object instances.

config LWM2M_SERVER_DEFAULT_PMIN
	int "Default server record PMIN"
	default 0
	help
	  Default minimum amount of time in seconds the client must wait
	  between notifications.  If a resource has to be notified during this
	  minimum time period, the notification must be sent after the time
	  period expires.

config LWM2M_SERVER_DEFAULT_PMAX
	int "Default server record PMAX"
	default 0
	help
	  Default maximum amount of time in seconds the client may wait
	  between notifications.  When this time period expires a notification
	  must be sent.

config LWM2M_SERVER_INSTANCE_COUNT
	int "Maximum # of LWM2M Server object instances"
	default 2 if LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP
	default 1
	range 1 10
	help
	  This setting establishes the total count of LWM2M Server instances
	  available to the client (including: bootstrap and regular servers).

config LWM2M_CONN_MON_OBJ_SUPPORT
	bool "Connectivity Monitoring object support"
	help
	  Include support for LWM2M Connectivity Monitoring Object (ID 4)

config LWM2M_CONN_MON_BEARER_MAX
	int "Maximum # of available network bearer resource instances"
	depends on LWM2M_CONN_MON_OBJ_SUPPORT
	default 1
	help
	  This value sets the maximum number of available network bearer
	  resource instances.  These are displayed via the
	  "Connection Monitoring" object /4/0/1.

config LWM2M_CONN_MON_APN_MAX
	int "Maximum # of APN resource instances"
	depends on LWM2M_CONN_MON_OBJ_SUPPORT
	default 1
	help
	  This value sets the maximum number of APN resource instances.
	  These are displayed via the "Connection Monitoring" object /4/0/7.

config LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT
	bool "Firmware Update object support"
	default y
	help
	  Include support for LWM2M Firmware Update Object (ID 5)

config LWM2M_FIRMWARE_UPDATE_PULL_SUPPORT
	bool "Firmware Update object pull support"
	default y
	depends on LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT
	depends on (HTTP_PARSER || HTTP_PARSER_URL)
	help
	  Include support for pulling a file from a remote server via
	  block transfer and "FIRMWARE PACKAGE URI" resource.  This option
	  adds another UDP context and packet handling.

config LWM2M_NUM_BLOCK1_CONTEXT
	int "Maximum # of LWM2M block1 contexts"
	default 3
	help
	  This value sets up the maximum number of block1 contexts for
	  CoAP block-wise transfer we can handle at the same time.

config LWM2M_FIRMWARE_UPDATE_PULL_COAP_PROXY_SUPPORT
	bool "Firmware Update object pull via CoAP-CoAP/HTTP proxy support"
	depends on LWM2M_FIRMWARE_UPDATE_PULL_SUPPORT
	help
	  Include support for pulling firmware file via a CoAP-CoAP/HTTP proxy.

config LWM2M_FIRMWARE_UPDATE_PULL_COAP_PROXY_ADDR
	string "CoAP proxy network address"
	depends on LWM2M_FIRMWARE_UPDATE_PULL_COAP_PROXY_SUPPORT
	help
	  Network address of the CoAP proxy server.

config LWM2M_RW_JSON_SUPPORT
	bool "support for JSON writer"
	default y
	help
	  Include support for writing JSON data

config LWM2M_DEVICE_PWRSRC_MAX
	int "Maximum # of device power source records"
	default 5
	range 1 20
	help
	  This value sets the maximum number of power source data that a device
	  can store.  These are displayed via the "Device" object /3/0/6,
	  /3/0/7 and /3/0/8 resources.

config LWM2M_DEVICE_ERROR_CODE_MAX
	int "Maximum # of device obj error codes to store"
	default 10
	range 1 20
	help
	  This value sets the maximum number of error codes that the device
	  object will store before ignoring new values.

config LWM2M_DEVICE_EXT_DEV_INFO_MAX
	int "Maximum # of device obj external device info to store"
	default 5
	range 1 20
	help
	  This value sets the maximum number of external device info that the
	  device object will store before ignoring new values.

config LWM2M_NUM_ATTR
	int "Maximum # of LWM2M attributes"
	default 20
	help
	  This value sets up the maximum number of LwM2M attributes that
	  we can handle at the same time.

config LWM2M_LOCATION_OBJ_SUPPORT
	bool "Location object support"
	help
	  Include support for LWM2M Location Object (ID 6)

menu "IPSO Alliance Smart Object Support"

source "subsys/net/lib/lwm2m/Kconfig.ipso"

endmenu

endif # LWM2M
