Skip to content

Commit 7279874

Browse files
eivindj-nordicrlubos
authored andcommitted
net: new downloader
The new downloader is replacing the download_client library and is based on that. Internal restructuring: * Restructuring of socket functions and files. * Parse HTTP header line for line. This reduces the size requirement for the download client recv buffer. * Change TLS range override logic. * Use range requests for nRF91 TLS only, and when specified by app. API updates: * Let application provide client buffer. This allows for multiple download clients with different buffer sizes. * Add downloader_deinit() * Add downloader_stop() * Remove downloader_disconnect() * Changed signature of downloader_init(), downloader_start() and downloader_get() to take a URI. * Added downloader_get_with_host_and_path() for downloads where host and path are separate arguments to keep backwards compatibility. * The transports (http, coap) are now separated out of the download client with its own API. Future work: * Take uri as input param to fota_download library and use URI in other relevant libaries and structures. * Curent download client is deprecated and will be removed later. Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 5eb1bd1 commit 7279874

File tree

120 files changed

+6503
-468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+6503
-468
lines changed

.github/test-spec.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
- "lib/nrf_modem_lib/**/*"
3939
- "lib/sms/**/*"
4040
- "subsys/dfu/dfu_target/**/*"
41-
- "subsys/net/lib/download_client/**/*"
41+
- "subsys/net/lib/downloader/**/*"
4242
- "subsys/net/lib/fota_download/**/*"
4343
- "subsys/net/lib/ftp_client/**/*"
4444
- "subsys/net/lib/nrf_cloud/**/*"
@@ -51,7 +51,7 @@
5151
- "lib/modem_info/**/*"
5252
- "lib/modem_key_mgmt/**/*"
5353
- "lib/date_time/**/*"
54-
- "subsys/net/lib/download_client/**/*"
54+
- "subsys/net/lib/downloader/**/*"
5555
- "subsys/net/lib/fota_download/**/*"
5656
- "subsys/net/lib/lwm2m_client_utils/**/*"
5757
- "subsys/dfu/dfu_target/**/*"
@@ -81,7 +81,7 @@
8181
- "include/modem/nrf_modem_lib.h"
8282
- "include/modem/pdn.h"
8383
- "include/modem/sms.h"
84-
- "include/net/download_client.h"
84+
- "include/net/downloader.h"
8585
- "include/secure_services.h"
8686
- "lib/at_host/**/*"
8787
- "lib/at_monitor/**/*"
@@ -102,7 +102,7 @@
102102
- "samples/cellular/pdn/**/*"
103103
- "samples/cellular/sms/**/*"
104104
- "samples/cellular/udp/**/*"
105-
- "subsys/net/lib/download_client/**/*"
105+
- "subsys/net/lib/downloader/**/*"
106106

107107
"CI-lwm2m-test":
108108
- "include/modem/lte_lc*.h"
@@ -114,8 +114,8 @@
114114
- "samples/cellular/lwm2m_carrier/**/*"
115115
- "include/modem/at_monitor.h"
116116
- "lib/at_monitor/**/*"
117-
- "include/net/download_client.h"
118-
- "subsys/net/lib/download_client/**/*"
117+
- "include/net/downloader.h"
118+
- "subsys/net/lib/downloader/**/*"
119119
- "lib/sms/**/*"
120120
- "include/modem/sms.h"
121121
- "lib/pdn/**/*"
@@ -147,7 +147,7 @@
147147
- "subsys/mgmt/**/*"
148148
- "subsys/pcd/*"
149149
- "subsys/net/lib/*fota*/**/*"
150-
- "subsys/net/lib/download_client/**/*"
150+
- "subsys/net/lib/downloader/**/*"
151151
- "tests/subsys/bootloader/**/*"
152152
- "tests/subsys/dfu/**/*"
153153

@@ -433,7 +433,7 @@
433433
- "include/modem/nrf_modem_lib.h"
434434
- "include/modem/pdn.h"
435435
- "include/modem/sms.h"
436-
- "include/net/download_client.h"
436+
- "include/net/downloader.h"
437437
- "include/net/fota_download.h"
438438
- "include/net/nrf_cloud.h"
439439
- "include/net/nrf_cloud_agnss.h"
@@ -457,7 +457,7 @@
457457
- "lib/sms/**/*"
458458
- "lib/supl/**/*"
459459
- "samples/cellular/modem_shell/**/*"
460-
- "subsys/net/lib/download_client/**/*"
460+
- "subsys/net/lib/downloader/**/*"
461461
- "subsys/net/lib/fota_download/**/*"
462462
- "subsys/net/lib/nrf_cloud/**/*"
463463
- "subsys/net/lib/rest_client/**/*"
@@ -509,7 +509,7 @@
509509
- "include/drivers/flash/**/*"
510510
- "include/flash_map_pm.h"
511511
- "include/modem/**/*"
512-
- "include/net/download_client.h"
512+
- "include/net/downloader.h"
513513
- "include/net/fota_download.h"
514514
- "include/net/nrf_cloud*"
515515
- "include/net/rest_client.h"
@@ -531,7 +531,7 @@
531531
- "subsys/bootloader/**/*"
532532
- "subsys/caf/**/*"
533533
- "subsys/dfu/**/*"
534-
- "subsys/net/lib/download_client/**/*"
534+
- "subsys/net/lib/downloader/**/*"
535535
- "subsys/net/lib/fota_download/**/*"
536536
- "subsys/net/lib/nrf_cloud/**/*"
537537
- "subsys/net/lib/nrf_provisioning/**/*"

CODEOWNERS

+8
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
/doc/nrf/libraries/networking/azure_*.rst @nrfconnect/ncs-cia-doc
168168
/doc/nrf/libraries/networking/coap_utils.rst @nrfconnect/ncs-terahertz-doc
169169
/doc/nrf/libraries/networking/download_client.rst @nrfconnect/ncs-modem-doc
170+
/doc/nrf/libraries/networking/downloader.rst @nrfconnect/ncs-modem-doc
170171
/doc/nrf/libraries/networking/fota_download.rst @nrfconnect/ncs-pluto-doc
171172
/doc/nrf/libraries/networking/ftp_client.rst @nrfconnect/ncs-iot-oulu-tampere-doc
172173
/doc/nrf/libraries/networking/icalendar_parser.rst @nrfconnect/ncs-doc-leads
@@ -335,7 +336,10 @@
335336
/include/mgmt/ @nrfconnect/ncs-pluto
336337
/include/modem/ @nrfconnect/ncs-modem
337338
/include/mpsl/ @nrfconnect/ncs-dragoon
339+
/include/net/ @nrfconnect/ncs-co-networking
338340
/include/net/azure_* @nrfconnect/ncs-cia
341+
/include/net/download_client* @nrfconnect/ncs-modem
342+
/include/net/downloader* @nrfconnect/ncs-modem
339343
/include/net/nrf_cloud_* @nrfconnect/ncs-nrf-cloud
340344
/include/net/wifi_credentials.h @nrfconnect/ncs-cia
341345
/include/nfc/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-si-muffin
@@ -741,6 +745,8 @@
741745
/subsys/net/lib/mqtt_helper/ @nrfconnect/ncs-cia
742746
/subsys/net/lib/azure_* @nrfconnect/ncs-cia
743747
/subsys/net/lib/aws_* @nrfconnect/ncs-cia
748+
/subsys/net/lib/download_client* @nrfconnect/ncs-modem
749+
/subsys/net/lib/downloader/ @nrfconnect/ncs-modem
744750
/subsys/net/lib/ftp_client/ @nrfconnect/ncs-iot-oulu
745751
/subsys/net/lib/hostap_crypto/ @krish2718 @jukkar @vivekuppunda
746752
/subsys/net/lib/icalendar_parser/ @lats1980
@@ -850,6 +856,8 @@
850856
/tests/subsys/mpsl/ @nrfconnect/ncs-dragoon
851857
/tests/subsys/net/lib/aws_*/ @nrfconnect/ncs-cia
852858
/tests/subsys/net/lib/azure_iot_hub/ @nrfconnect/ncs-cia
859+
/tests/subsys/net/lib/downloader/ @nrfconnect/ncs-modem
860+
/tests/subsys/net/lib/download_client/ @nrfconnect/ncs-modem
853861
/tests/subsys/net/lib/fota_download/ @nrfconnect/ncs-pluto
854862
/tests/subsys/net/lib/lwm2m_*/ @nrfconnect/ncs-iot-oulu
855863
/tests/subsys/net/lib/mqtt_helper/ @nrfconnect/ncs-cia

applications/asset_tracker_v2/boards/native_sim.conf

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
103103
# FOTA
104104
CONFIG_FOTA_DOWNLOAD=n
105105
CONFIG_DFU_TARGET=n
106-
CONFIG_DOWNLOAD_CLIENT=n
107-
CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=n
106+
CONFIG_DOWNLOADER=n
108107

109108
# MCUBOOT
110109
CONFIG_BOOTLOADER_MCUBOOT=n

applications/asset_tracker_v2/doc/asset_tracker_v2_description.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ This application uses the following |NCS| libraries and drivers:
235235
* :ref:`lib_date_time`
236236
* :ref:`lte_lc_readme`
237237
* :ref:`modem_info_readme`
238-
* :ref:`lib_download_client`
238+
* :ref:`lib_downloader`
239239
* :ref:`lib_fota_download`
240240
* :ref:`caf_leds`
241241

applications/asset_tracker_v2/overlay-carrier.conf

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ CONFIG_PDN=y
1818
# AT Monitor is used by PDN library
1919
CONFIG_AT_MONITOR=y
2020

21-
# Download client for DFU
22-
CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=230
21+
# Downloader for DFU
22+
CONFIG_DOWNLOADER_MAX_FILENAME_SIZE=230
2323

2424
# Modem info
2525
CONFIG_MODEM_INFO_BUFFER_SIZE=512
@@ -36,3 +36,6 @@ CONFIG_DFU_TARGET=y
3636

3737
# Asserts
3838
CONFIG_ASSERT_VERBOSE=n
39+
40+
# IPv4 (IPv6 is enabled by default)
41+
CONFIG_NET_IPV4=y

applications/asset_tracker_v2/prj.conf

+3-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ CONFIG_FCB=y
6060
# FOTA
6161
CONFIG_FOTA_DOWNLOAD=y
6262
CONFIG_DFU_TARGET=y
63-
CONFIG_DOWNLOAD_CLIENT=y
64-
CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
65-
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
66-
CONFIG_DOWNLOAD_CLIENT_BUF_SIZE=2300
67-
CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE=128
63+
CONFIG_DOWNLOADER=y
64+
CONFIG_DOWNLOADER_STACK_SIZE=4096
65+
CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE=128
6866

6967
# Flash - Used in FOTA, settings and storage for P-GPS.
7068
CONFIG_FLASH=y

applications/serial_lte_modem/doc/slm_description.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ This application uses the following |NCS| libraries:
684684
* :ref:`lib_ftp_client`
685685
* :ref:`sms_readme`
686686
* :ref:`lib_fota_download`
687-
* :ref:`lib_download_client`
687+
* :ref:`lib_downloader`
688688
* :ref:`lib_nrf_cloud`
689689
* :ref:`lib_nrf_cloud_agnss`
690690
* :ref:`lib_nrf_cloud_pgps`

applications/serial_lte_modem/overlay-carrier.conf

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CONFIG_FP_HARDABI=y
1313
CONFIG_PDN=y
1414

1515
# Download client for DFU
16-
CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=230
16+
CONFIG_DOWNLOADER_MAX_FILENAME_SIZE=230
1717

1818
# Modem info
1919
CONFIG_MODEM_INFO_BUFFER_SIZE=512
@@ -28,3 +28,6 @@ CONFIG_LWM2M_CARRIER_SETTINGS=y
2828

2929
# DFU target library
3030
CONFIG_DFU_TARGET=y
31+
32+
# IPv4 (IPv6 is enabled by default)
33+
CONFIG_NET_IPV4=y

applications/serial_lte_modem/prj.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ CONFIG_HTTP_PARSER_URL=y
6262
CONFIG_FOTA_DOWNLOAD=y
6363
CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
6464
CONFIG_DFU_TARGET=y
65-
CONFIG_DOWNLOAD_CLIENT=y
66-
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
67-
CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=2048
65+
CONFIG_DOWNLOADER=y
66+
CONFIG_DOWNLOADER_STACK_SIZE=4096
67+
CONFIG_DOWNLOADER_MAX_FILENAME_SIZE=2048
6868
CONFIG_BOOTLOADER_MCUBOOT=y
6969
CONFIG_IMG_MANAGER=y
7070

applications/serial_lte_modem/src/slm_at_fota.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
LOG_MODULE_REGISTER(slm_fota, CONFIG_SLM_LOG_LEVEL);
2727

2828
/* file_uri: scheme://hostname[:port]path[?parameters] */
29-
#define FILE_URI_MAX CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE
29+
#define FILE_URI_MAX CONFIG_DOWNLOADER_MAX_FILENAME_SIZE
3030
#define SCHEMA_HTTP "http"
3131
#define SCHEMA_HTTPS "https"
32-
#define URI_HOST_MAX CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE
32+
#define URI_HOST_MAX CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE
3333
#define URI_SCHEMA_MAX 8
3434
#define ERASE_POLL_TIME 2
3535

doc/nrf/app_dev/device_guides/nrf91/nrf91_building.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ To perform a FOTA update, complete the following steps:
7171
See :ref:`upgradable_bootloader` for more information.
7272

7373
#. Make the binary file (or files) available for download.
74-
Upload the serialized :file:`.cbor` binary file or files to a web server that is compatible with the :ref:`lib_download_client` library.
74+
Upload the serialized :file:`.cbor` binary file or files to a web server that is compatible with the :ref:`lib_downloader` library.
7575

7676
The full FOTA procedure depends on where the binary files are hosted for download.
7777

doc/nrf/libraries/bin/lwm2m_carrier/app_integration.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ It provides an abstraction of the following modules:
3131
.. lwm2m_osal_mod_list_start
3232
3333
* :ref:`at_monitor_readme`
34-
* :ref:`lib_download_client`
34+
* :ref:`lib_downloader`
3535
* :ref:`sms_readme`
3636
* :ref:`pdn_readme`
3737
* :ref:`lib_dfu_target`

doc/nrf/libraries/bin/lwm2m_carrier/requirements.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Following are some of the requirements and limitations of the application while
4848
* For example, setting :kconfig:option:`CONFIG_LWM2M_CARRIER_SERVER_SEC_TAG` to 42 uses the security tag range 43 to 46 instead of 25 to 28.
4949

5050
* The CA certificates that are used for out-of-band FOTA must be provided by the application.
51-
Out-of-band FOTA updates are done by the :ref:`lib_download_client`.
51+
Out-of-band FOTA updates are done by the :ref:`lib_downloader`.
5252
Although the certificates are updated as part of the |NCS| releases, you must check the requirements from your carrier to know which certificates are applicable.
5353

5454
* The LwM2M carrier library uses the following NVS record key range: ``0xCA00`` to ``0xCAFF``.

doc/nrf/libraries/networking/aws_fota.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Creating a FOTA job
6262
#. Click the uploaded image file :file:`app_update.bin` and copy the *Object URL* without the *https://* prefix and folder path.
6363
#. Create a text file (job document) with content as in the snippet, replacing the following data:
6464

65-
* *protocol* with either `http` or `https`.
65+
* *protocol* with either ``http`` or ``https``.
6666
* *host_url* with the *Object URL* copied in the previous step (for example, ``examplebucket.s3.eu-central-1.amazonaws.com``).
6767
* *file_path* with the path and file name (for example, ``app_update.bin``).
6868

@@ -105,10 +105,10 @@ Configure the following parameters when using this library:
105105
* :kconfig:option:`CONFIG_AWS_FOTA_PAYLOAD_SIZE` - Sets the maximum payload size for AWS IoT job messages.
106106
* :kconfig:option:`CONFIG_AWS_FOTA_DOWNLOAD_SECURITY_TAG` - Sets the security tag to be used in case of HTTPS downloads.
107107

108-
Additionally, configure the :ref:`lib_download_client` library:
108+
Additionally, configure the :ref:`lib_downloader` library:
109109

110-
* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the download client.
111-
* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the download client.
110+
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the library.
111+
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the library.
112112

113113
.. _aws_fota_implementation:
114114

@@ -133,7 +133,7 @@ The following sequence diagram shows how a firmware over-the-air update is imple
133133
AWS IoT jobs
134134
============
135135

136-
The implementation uses a job document like the following (where *protocol* is either `http` or `https`, *bucket_name* is the name of your bucket and *file_name* is the name of your file) for passing information from `AWS IoT jobs`_ to the device:
136+
The implementation uses a job document like the following (where *protocol* is either ``http`` or ``https``, *bucket_name* is the name of your bucket and *file_name* is the name of your file) for passing information from `AWS IoT jobs`_ to the device:
137137

138138
.. parsed-literal::
139139
:class: highlight
@@ -191,17 +191,17 @@ Presigned URLs
191191

192192
When using the presigned URLs, you might need to increase the value of the following Kconfig options to accommodate the long file name and payload size of the presigned URL and the secure download of the image:
193193

194-
* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE`.
194+
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_FILENAME_SIZE`.
195195
* :kconfig:option:`CONFIG_AWS_FOTA_PAYLOAD_SIZE`.
196196
* :kconfig:option:`CONFIG_MBEDTLS_HEAP_SIZE` - If running Mbed TLS on the application core (Wi-Fi® builds).
197197

198198
Limitations
199199
***********
200200

201201
* If the :kconfig:option:`CONFIG_AWS_FOTA_DOWNLOAD_SECURITY_TAG` Kconfig option is not configured but HTTPS is selected as the protocol, the update job fails.
202-
For further information about HTTPS support, refer to :ref:`the HTTPS section of the download client documentation <download_client_https>`.
202+
For further information about HTTPS support, refer to :ref:`the HTTPS section of the Downloader library documentation <downloader_https>`.
203203
* The library requires a Content-Range header to be present in the HTTP response from the server.
204-
This limitation is inherited from the :ref:`lib_download_client` library.
204+
This limitation is inherited from the :ref:`lib_downloader` library.
205205

206206
API documentation
207207
*****************

doc/nrf/libraries/networking/azure_fota.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ Configure the following parameters when using this library:
5858
* :kconfig:option:`CONFIG_AZURE_FOTA_TLS` - Enables HTTPS for downloads. By default, TLS is enabled and currently, the transport protocol must be configured at compile time.
5959
* :kconfig:option:`CONFIG_AZURE_FOTA_SEC_TAG` - Sets the security tag for TLS credentials when using HTTPS as the transport layer. See :ref:`azure_iot_hub_flash_certs` for more details.
6060

61-
Additionally, configure the :ref:`lib_download_client` library:
61+
Additionally, configure the :ref:`lib_downloader` library:
6262

63-
* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the download client.
64-
* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the download client.
63+
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the library.
64+
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the library.
6565

6666
Limitations
6767
***********
6868

6969
The library requires a ``Content-Range`` header to be present in the HTTP response from the server.
70-
This limitation is inherited from the :ref:`lib_download_client` library.
70+
This limitation is inherited from the :ref:`lib_downloader` library.
7171

7272
API documentation
7373
*****************

doc/nrf/libraries/networking/download_client.rst

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Download client
77
:local:
88
:depth: 2
99

10+
.. note::
11+
12+
The :ref:`lib_download_client` library has been deprecated and it will be removed in one of the future releases.
13+
Use the :ref:`lib_downloader` library instead.
14+
1015
The download client library can be used to download files from an HTTP or a CoAP server.
1116

1217
Overview

0 commit comments

Comments
 (0)