Skip to content

Commit 3557ba6

Browse files
maxd-nordicjhn-nordic
authored andcommitted
lib: net: fix CoAP downloads for PGPS downloads
Fixes issue introduced in #19908: PGPS downloads were previously wrongly redirected through the FOTA pipeline, but should be handed over to downloader directly. Signed-off-by: Maximilian Deubel <[email protected]>
1 parent 42a7901 commit 3557ba6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

subsys/net/lib/nrf_cloud/src/nrf_cloud_download.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,27 @@ static int coap_dl(struct nrf_cloud_download_data *const dl)
110110
return ret;
111111
}
112112

113-
return fota_download_with_host_cfg("coaps://" CONFIG_NRF_CLOUD_COAP_SERVER_HOSTNAME,
114-
"proxy", dl->dl_host_conf.sec_tag_count ?
115-
dl->dl_host_conf.sec_tag_list[0] : -1,
116-
dl->dl_host_conf.pdn_id, dl->dl_host_conf.range_override,
117-
dl->fota.expected_type, &host_cfg);
113+
const char *host = "coaps://" CONFIG_NRF_CLOUD_COAP_SERVER_HOSTNAME;
114+
const char *file = "proxy";
115+
116+
if (dl->type == NRF_CLOUD_DL_TYPE_FOTA) {
117+
return fota_download_with_host_cfg(host,
118+
file, dl->dl_host_conf.sec_tag_count ?
119+
dl->dl_host_conf.sec_tag_list[0] : -1,
120+
dl->dl_host_conf.pdn_id,
121+
dl->dl_host_conf.range_override,
122+
dl->fota.expected_type, &host_cfg);
123+
} else {
124+
/* If not downloading FOTA, use downloader directly */
125+
dl->dl_host_conf.cid = true;
126+
dl->dl_host_conf.auth_cb = nrf_cloud_download_handle_coap_auth;
127+
dl->dl_host_conf.proxy_uri = proxy_uri;
128+
129+
return downloader_get_with_host_and_file(
130+
dl->dl, &dl->dl_host_conf, host, file, 0
131+
);
132+
}
133+
118134
}
119135
#endif /* NRF_CLOUD_COAP_DOWNLOADS */
120136

subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps_utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ static int downloader_callback(const struct downloader_evt *event)
562562
*/
563563
if ((socket_retries_left) && ((event->error == -ENOTCONN) ||
564564
(event->error == -ECONNREFUSED) ||
565+
(event->error == -EAGAIN) ||
565566
(event->error == -ECONNRESET))) {
566567
LOG_WRN("Download socket error. %d retries left...",
567568
socket_retries_left);

0 commit comments

Comments
 (0)