Skip to content

Commit 322a86e

Browse files
tokangasrlubos
authored andcommitted
net: lib: nrf_cloud: add GNSS API support for nRFCloud A-GPS and P-GPS
Added support for writing assistance data to GNSS using the new GNSS API. If GPS driver is not enabled and no GNSS socket descriptor has been given, it's assumed that the GNSS API is used. Removed Kconfig dependency to the GPS driver from both A-GPS and P-GPS. It's should not be mandatory for the application to enable the GPS driver. The library does use gps.h, but that's always present regardless of the NRF9160_GPS configuration option. Signed-off-by: Tommi Kangas <[email protected]>
1 parent c782d6b commit 322a86e

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

subsys/net/lib/nrf_cloud/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ menu "nRF Cloud A-GPS"
200200

201201
config NRF_CLOUD_AGPS
202202
bool "Enable nRF Cloud Assisted GPS"
203-
depends on NRF9160_GPS
204203
depends on MODEM_INFO
205204
depends on MODEM_INFO_ADD_NETWORK
206205

@@ -230,7 +229,6 @@ menu "nRF Cloud P-GPS"
230229

231230
config NRF_CLOUD_PGPS
232231
bool "Enable nRF Cloud Predicted GPS"
233-
depends on NRF9160_GPS
234232
depends on MODEM_INFO
235233
depends on MODEM_INFO_ADD_NETWORK
236234
select STREAM_FLASH_ERASE

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <drivers/gps.h>
1010
#include <net/socket.h>
1111
#include <nrf_socket.h>
12+
#include <nrf_modem_gnss.h>
1213
#include <cJSON.h>
1314
#include <cJSON_os.h>
1415
#include <modem/modem_info.h>
@@ -339,22 +340,22 @@ static int send_to_modem(void *data, size_t data_len,
339340
agps_print(type, data);
340341
}
341342

342-
/* At this point, GPS driver or app-provided socket is assumed. */
343343
if (gps_dev) {
344-
return gps_agps_write(gps_dev, type_socket2gps(type), data,
345-
data_len);
346-
}
347-
348-
err = nrf_sendto(fd, data, data_len, 0, &type, sizeof(type));
349-
if (err < 0) {
350-
LOG_ERR("Failed to send AGPS data to modem, errno: %d", errno);
351-
err = -errno;
344+
/* GPS driver */
345+
err = gps_agps_write(gps_dev, type_socket2gps(type), data, data_len);
346+
} else if (fd != -1) {
347+
/* GNSS socket */
348+
err = nrf_sendto(fd, data, data_len, 0, &type, sizeof(type));
349+
if (err < 0) {
350+
err = -errno;
351+
} else {
352+
err = 0;
353+
}
352354
} else {
353-
err = 0;
355+
/* GNSS API */
356+
err = nrf_modem_gnss_agps_write(data, data_len, type);
354357
}
355358

356-
LOG_DBG("A-GSP data sent to modem");
357-
358359
return err;
359360
}
360361

@@ -725,7 +726,7 @@ int nrf_cloud_agps_process(const char *buf, size_t buf_len, const int *socket)
725726

726727
parsed_len += element_size;
727728

728-
LOG_DBG("Parsed_len: %d\n", parsed_len);
729+
LOG_DBG("Parsed_len: %d", parsed_len);
729730

730731
if (element.type == NRF_CLOUD_AGPS_GPS_TOWS) {
731732
memcpy(&sys_time.sv_tow[element.tow->sv_id - 1],

0 commit comments

Comments
 (0)