Commit f0fb867b authored by Gerson Fernando Budke's avatar Gerson Fernando Budke Committed by Anas Nashif
Browse files

lib: updatehub: Kconfig: Add coap max retry option

The current implementation uses a fixed value for max retries. That
value could be good for an wired network like Ethernet. However,
wireless network can suffer with higher packet collision, low reception
signal etc. This refacts the variable to be defined at Kconfig. This
way max retries can be adjust conform the current media.

Signed-off-by: default avatarGerson Fernando Budke <gerson.budke@ossystems.com.br>
parent 6e60ede6
Loading
Loading
Loading
Loading
+10 −1
Changes for lib/updatehub/Kconfig: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
# Copyright (c) 2018, 2019 O.S.Systems
# Copyright (c) 2018-2020 O.S.Systems
# SPDX -License-Identifier: Apache-2.0

menuconfig UPDATEHUB
@@ -86,6 +86,15 @@ config UPDATEHUB_DTLS
	  Enables DTLS communication between the UpdateHub
	  client and the server

config UPDATEHUB_COAP_MAX_RETRY
	int "Maximum retries attempts to download a packet"
	default 10
	range 3 10
	depends on UPDATEHUB
	help
	  Set the maximum number of retries attempts to download a packet
	  before abort a current update.

module = UPDATEHUB
module-str = Log level for UpdateHub
module-help = Enables logging for UpdateHub code.
+2 −2
Changes for lib/updatehub/updatehub.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ LOG_MODULE_REGISTER(updatehub, CONFIG_UPDATEHUB_LOG_LEVEL);
 * otherwise download size will be less than real size.
 */
#define MAX_DOWNLOAD_DATA (MAX_PAYLOAD_SIZE + 32)
#define COAP_MAX_RETRY 3
#define MAX_IP_SIZE 30

#define SHA256_HEX_DIGEST_SIZE	((TC_SHA256_DIGEST_SIZE * 2) + 1)
@@ -486,7 +485,8 @@ static enum updatehub_response install_update(void)
		}

		if (verification_download == ctx.downloaded_size) {
			if (attempts_download == COAP_MAX_RETRY) {
			if (attempts_download ==
			    CONFIG_UPDATEHUB_COAP_MAX_RETRY) {
				LOG_ERR("Could not get the packet");
				ctx.code_status = UPDATEHUB_DOWNLOAD_ERROR;
				goto cleanup;