diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 9d4b1b060fc2..e64dfcb4ff74 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -730,7 +730,10 @@ Libraries for networking * :ref:`lib_fota_download` library: - * Added the functions :c:func:`fota_download` and :c:func:`fota_download_any` that can accept a security tag list and security tag count as arguments instead of a single security tag. + * Added: + + * The functions :c:func:`fota_download` and :c:func:`fota_download_any` that can accept a security tag list and security tag count as arguments instead of a single security tag. + * :c:enumerator:`FOTA_DOWNLOAD_ERROR_CAUSE_CONNECT_FAILED` as a potential error cause in :c:enumerator:`FOTA_DOWNLOAD_EVT_ERROR` events. Libraries for NFC ----------------- diff --git a/include/net/fota_download.h b/include/net/fota_download.h index a08a08dbff78..492ded17803e 100644 --- a/include/net/fota_download.h +++ b/include/net/fota_download.h @@ -71,6 +71,10 @@ enum fota_download_evt_id { enum fota_download_error_cause { /** No error, used when event ID is not FOTA_DOWNLOAD_EVT_ERROR. */ FOTA_DOWNLOAD_ERROR_CAUSE_NO_ERROR, + /** Connecting to the FOTA server failed. A possible reason could be wrong + * TLS credentials. A retry is unlikely to help with the same credentials. + */ + FOTA_DOWNLOAD_ERROR_CAUSE_CONNECT_FAILED, /** Downloading the update failed. The download may be retried. */ FOTA_DOWNLOAD_ERROR_CAUSE_DOWNLOAD_FAILED, /** The update is invalid and was rejected. Retry will not help. */ diff --git a/subsys/net/lib/fota_download/src/fota_download.c b/subsys/net/lib/fota_download/src/fota_download.c index b032d54a876d..ce4faebe2e84 100644 --- a/subsys/net/lib/fota_download/src/fota_download.c +++ b/subsys/net/lib/fota_download/src/fota_download.c @@ -280,6 +280,11 @@ static int download_client_callback(const struct download_client_evt *event) /* Fall through and return 0 below to tell * download_client to retry */ + } else if ((event->error == -ECONNABORTED) || (event->error == -ECONNREFUSED)) { + LOG_ERR("Download client failed to connect to server"); + set_error_state(FOTA_DOWNLOAD_ERROR_CAUSE_CONNECT_FAILED); + + goto error_and_close; } else { LOG_ERR("Download client error"); err = dfu_target_done(false);