# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

menu "nRF Cloud"

rsource "Kconfig.nrf_cloud_client_id"

rsource "Kconfig.nrf_cloud_mqtt"

rsource "Kconfig.nrf_cloud_fota"

rsource "Kconfig.nrf_cloud_agnss"

rsource "Kconfig.nrf_cloud_pgps"

rsource "Kconfig.nrf_cloud_rest"

rsource "Kconfig.nrf_cloud_location"

rsource "Kconfig.nrf_cloud_alert"

rsource "Kconfig.nrf_cloud_log"

rsource "Kconfig.nrf_cloud_coap"

rsource "Kconfig.nrf_cloud_shadow_info"

config NRF_CLOUD_GATEWAY
	bool "nRF Cloud Gateway"
	help
	  Enables functionality in this device to be compatible with
	  nRF Cloud LTE gateway support.

if NRF_CLOUD_MQTT || NRF_CLOUD_REST || NRF_CLOUD_PGPS || MODEM_JWT || NRF_CLOUD_COAP

config NRF_CLOUD_HOST_NAME
	string "nRF Cloud server hostname"
	default "mqtt.nrfcloud.com"
	help
	  Used for MQTT and JITP performed with REST

config NRF_CLOUD_SEC_TAG
	int "Security tag to use for nRF Cloud connection"
	default 16842753

config NRF_CLOUD_DEVICE_STATUS_ENCODE_VOLTAGE
	bool "Include the (battery) voltage when encoding device status"
	depends on MODEM_INFO
	depends on MODEM_INFO_ADD_DEVICE
	default y

choice NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT
	prompt "Encoding options for Wi-Fi location requests"
	default NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI

config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_ONLY
	bool "Encode only the MAC address"
	help
		The MAC address is the only required parameter.

config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI
	bool "Encode the MAC address and the RSSI value"
	help
		The RSSI value may improve location accuracy.

config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_ALL
	bool "Encode all available parameters"
	help
		This option increases the memory required for creating requests.
		It also increases the amount of data sent to nRF Cloud.
endchoice

config NRF_CLOUD_PROVISION_CERTIFICATES
	bool "Install credentials for nRF Cloud connection"
	select EXPERIMENTAL
	default y if BOARD_QEMU_X86
	imply MBEDTLS_PEM_CERTIFICATE_FORMAT if MBEDTLS
	help
	  Enable run-time provisioning of certificates from the
	  certificates header file selected by using NRF_CLOUD_CERTIFICATES_FILE
	  Please note that this option stores your device's private key in unprotected memory.
	  It is not secure, and for testing purposes only.

if NRF_CLOUD_PROVISION_CERTIFICATES

config NRF_CLOUD_PROVISION_CA_CERT
	bool "Install the CA certificate"
	default y

config NRF_CLOUD_PROVISION_CLIENT_CERT
	bool "Install the client certificate"
	default y

config NRF_CLOUD_PROVISION_PRV_KEY
	bool "Install the private key"
	default y

config NRF_CLOUD_CERTIFICATES_FILE
	string "nRF Cloud certificates"
	default "../include/nrf_cloud-certs.h"
	help
	  The default path for a header file that contains definitions for certificates that are
	  used during run-time provisioning of TLS credentials.
	  By default, the library expects the credentials to be in
	  Privacy Enhanced Mail (PEM) format. See "nrf_cloud-certs.h" for a template.

endif # NRF_CLOUD_PROVISION_CERTIFICATES

config NRF_CLOUD_CHECK_CREDENTIALS
	bool "Enable the ability to check if nRF Cloud credentials are present"

choice NRF_CLOUD_CREDENTIALS_MGMT
	prompt "Select how credentials are managed"
	depends on NRF_CLOUD_CHECK_CREDENTIALS || NRF_CLOUD_PROVISION_CERTIFICATES
	default NRF_CLOUD_CREDENTIALS_MGMT_MODEM if NRF_MODEM_LIB
	default NRF_CLOUD_CREDENTIALS_MGMT_TLS_CRED if !NRF_MODEM_LIB

config NRF_CLOUD_CREDENTIALS_MGMT_MODEM
	depends on NRF_MODEM_LIB
	select MODEM_KEY_MGMT
	bool "Credentials are managed by the modem"

config NRF_CLOUD_CREDENTIALS_MGMT_TLS_CRED
	bool "Credentials are managed by the TLS credentials module"
	select TLS_CREDENTIALS
endchoice

config NRF_CLOUD_JWT_SOURCE_CUSTOM
	bool "Custom JWT creation and signing"
	select EXPERIMENTAL
	select TLS_CREDENTIALS
	select BASE64
	select TINYCRYPT
	select TINYCRYPT_SHA256
	select TINYCRYPT_ECC_DSA
	select TINYCRYPT_CTR_PRNG
	select TINYCRYPT_AES
	select CJSON_LIB
	depends on NEWLIB_LIBC
	depends on NEWLIB_LIBC_FLOAT_PRINTF
	depends on DATE_TIME
	help
	  JWTs are created and signed by the nRF Cloud library, not the modem.
	  The signing key is obtained from the TLS credentials module.

endif # NRF_CLOUD_MQTT || NRF_CLOUD_REST || NRF_CLOUD_PGPS || MODEM_JWT || NRF_CLOUD_COAP

if NRF_CLOUD_AGNSS || NRF_CLOUD_PGPS

module = NRF_CLOUD_GPS
module-str = nRF Cloud GPS Assistance
source "subsys/logging/Kconfig.template.log_config"

endif

module=NRF_CLOUD
module-dep=LOG
module-str=Log level for nRF Cloud
module-help=Enables nRF Cloud log messages.
source "subsys/logging/Kconfig.template.log_config"

endmenu
