Skip to content

Commit

Permalink
net: lib: nrf_cloud: Fix warnings on PGPS
Browse files Browse the repository at this point in the history
The new downloader library behaves slightly differently
than the old download_client library.

Specify the download protocol. Expect an -EPERM error
when calling downloader_cancel() when download is already
done.

Also address potential build error with coap provisioning
overlay.

Jira: IRIS-9994

Signed-off-by: Pete Skeggs <[email protected]>
  • Loading branch information
plskeggs authored and rlubos committed Jan 13, 2025
1 parent 6dd7041 commit baff83c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ Cellular samples

* :ref:`nrf_cloud_multi_service` sample:

* Fixed an issue with an uninitialized variable in the :c:func:`handle_at_cmd_requests` function.
* Fixed:

* An issue with an uninitialized variable in the :c:func:`handle_at_cmd_requests` function.
* An issue with the too small :kconfig:option:`CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE` Kconfig value
in the :file:`overlay-coap_nrf_provisioning.conf` file.

* :ref:`lte_sensor_gateway` sample:

Expand Down Expand Up @@ -512,6 +516,9 @@ Libraries for networking
* :ref:`lib_azure_fota`
* :ref:`lib_fota_download`

* :ref:`lib_nrf_cloud_pgps` library:

* Fixed the warning due to missing ``https`` download protocol.

Libraries for NFC
-----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CONFIG_NRF_PROVISIONING_CODEC_RX_SZ_START=2048

# CoAP Client
CONFIG_COAP_EXTENDED_OPTIONS_LEN=y
CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE=64
CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE=192
CONFIG_COAP_CLIENT_THREAD_PRIORITY=0
CONFIG_COAP_CLIENT_BLOCK_SIZE=1024
CONFIG_COAP_CLIENT_MESSAGE_SIZE=1024
Expand Down
21 changes: 10 additions & 11 deletions subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LOG_MODULE_REGISTER(nrf_cloud_pgps, CONFIG_NRF_CLOUD_GPS_LOG_LEVEL);
#include "nrf_cloud_pgps_utils.h"
#include "nrf_cloud_codec_internal.h"

#define FORCE_HTTP_DL 0 /* set to 1 to force HTTP instead of HTTPS */
#define DOWNLOAD_PROTOCOL "https://"
#define PGPS_DEBUG 0 /* set to 1 for extra logging */

#if defined(CONFIG_NRF_CLOUD_PGPS_PREDICTION_PERIOD_120_MIN)
Expand Down Expand Up @@ -867,14 +867,18 @@ int nrf_cloud_pgps_process(const char *buf, size_t buf_len)
int err;
static char host[CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE];
static char path[CONFIG_DOWNLOADER_MAX_FILENAME_SIZE];
size_t sz = strlen(DOWNLOAD_PROTOCOL);

struct nrf_cloud_pgps_result pgps_dl = {
.host = host,
.host_sz = sizeof(host),
.host = &host[sz],
.host_sz = sizeof(host) - sz,
.path = path,
.path_sz = sizeof(path)
};

/* Include protocol so downloader does not issue a warning. */
strncpy(host, DOWNLOAD_PROTOCOL, sz + 1);

#if defined(CONFIG_NRF_CLOUD_MQTT)
LOG_HEXDUMP_DBG(buf, buf_len, "MQTT packet");
#endif
Expand All @@ -888,6 +892,9 @@ int nrf_cloud_pgps_process(const char *buf, size_t buf_len)
return err;
}

/* Point to start of full host name including protocol. */
pgps_dl.host = host;

return nrf_cloud_pgps_update(&pgps_dl);
}

Expand Down Expand Up @@ -918,14 +925,6 @@ int nrf_cloud_pgps_update(struct nrf_cloud_pgps_result *file_location)

int sec_tag = nrf_cloud_sec_tag_get();

if (FORCE_HTTP_DL && (strncmp(file_location->host, "https", 5) == 0)) {
memmove(&file_location->host[4],
&file_location->host[5],
strlen(&file_location->host[4]));

sec_tag = -1;
}

err = npgps_download_start(file_location->host, file_location->path,
sec_tag, 0, FRAGMENT_SIZE);

Expand Down

0 comments on commit baff83c

Please sign in to comment.