Skip to content

Commit

Permalink
net: lib: nrf_cloud_agnss: Add define for maximum A-GNSS data size
Browse files Browse the repository at this point in the history
Added a define for maximum A-GNSS data size in nrf_cloud_agnss.h
and took it into use in all places where REST or CoAP is used and
a buffer for A-GNSS data is allocated.

Signed-off-by: Tommi Kangas <[email protected]>
  • Loading branch information
tokangas authored and nordic-piks committed Jan 24, 2025
1 parent c73baaf commit 38e7156
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion include/net/nrf_cloud_agnss.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define NRF_CLOUD_AGNSS_H_

/** @file nrf_cloud_agnss.h
* @brief Module to provide nRF Cloud A-GNSS support to nRF9160 SiP.
* @brief Module to provide nRF Cloud A-GNSS support to nRF91 SiP.
*/

#include <zephyr/kernel.h>
Expand All @@ -19,6 +19,12 @@
extern "C" {
#endif

/**
* Maximum size of assistance data in bytes when all assistance data types are received.
* Can be used to set the buffer size for REST and CoAP.
*/
#define NRF_CLOUD_AGNSS_MAX_DATA_SIZE 3600

/** Exclude the mask angle from the A-GNSS request */
#define NRF_CLOUD_AGNSS_MASK_ANGLE_NONE 0xFF

Expand Down
3 changes: 1 addition & 2 deletions lib/location/method_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ BUILD_ASSERT(
#define AT_MDM_SLEEP_NOTIF_START "AT%%XMODEMSLEEP=1,%d,%d"
#endif
#if (defined(CONFIG_NRF_CLOUD_AGNSS) || defined(CONFIG_NRF_CLOUD_PGPS))
#define AGNSS_REQUEST_RECV_BUF_SIZE 3500
#define AGNSS_REQUEST_HTTPS_RESP_HEADER_SIZE 400
/* Minimum time between two A-GNSS data requests in seconds. */
#define AGNSS_REQUEST_MIN_INTERVAL (60 * 60)
Expand Down Expand Up @@ -97,7 +96,7 @@ static int64_t agnss_req_timestamp;
#if !defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && \
(defined(CONFIG_NRF_CLOUD_REST) || defined(CONFIG_NRF_CLOUD_COAP)) && \
!defined(CONFIG_NRF_CLOUD_MQTT)
static char agnss_rest_data_buf[AGNSS_REQUEST_RECV_BUF_SIZE];
static char agnss_rest_data_buf[NRF_CLOUD_AGNSS_MAX_DATA_SIZE];
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion samples/cellular/gnss/src/assistance.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static char jwt_buf[600];
static char rx_buf[2048];

#if defined(CONFIG_NRF_CLOUD_AGNSS)
static char agnss_data_buf[3500];
static char agnss_data_buf[NRF_CLOUD_AGNSS_MAX_DATA_SIZE];
#endif /* CONFIG_NRF_CLOUD_AGNSS */

#if defined(CONFIG_NRF_CLOUD_PGPS)
Expand Down
2 changes: 1 addition & 1 deletion samples/cellular/modem_shell/src/gnss/gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static bool agnss_inject_int = true;

#if defined(CONFIG_NRF_CLOUD_AGNSS) && !defined(CONFIG_NRF_CLOUD_MQTT) && \
!defined(CONFIG_LWM2M_CLIENT_UTILS_LOCATION_ASSIST_AGNSS)
static char agnss_data_buf[3500];
static char agnss_data_buf[NRF_CLOUD_AGNSS_MAX_DATA_SIZE];
#endif

#if defined(CONFIG_NRF_CLOUD_PGPS)
Expand Down
3 changes: 2 additions & 1 deletion samples/cellular/modem_shell/src/gnss/gnss_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "mosh_print.h"
#include "gnss.h"

#define AGNSS_CMD_LINE_INJECT_MAX_LENGTH MIN(3500, CONFIG_SHELL_CMD_BUFF_SIZE)
#define AGNSS_CMD_LINE_INJECT_MAX_LENGTH MIN(NRF_CLOUD_AGNSS_MAX_DATA_SIZE, \
CONFIG_SHELL_CMD_BUFF_SIZE)

static int cmd_gnss_start(const struct shell *shell, size_t argc, char **argv)
{
Expand Down

0 comments on commit 38e7156

Please sign in to comment.