Skip to content

Commit fadde7d

Browse files
committed
app: nrfcloud: Add GCI support to cellpos
Implement cell positioning similarly to Location library meaning AT%NCELLMEAS will be done 1-3 times depending on how many cells are requested and found in each attempt. Implementation done by copying GCI parsing from lte_lc. Signed-off-by: Tommi Rantanen <tommi.rantanen@nordicsemi.no>
1 parent a72923d commit fadde7d

8 files changed

Lines changed: 1060 additions & 372 deletions

File tree

app/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ config SM_GNSS
248248
config SM_NRF_CLOUD
249249
bool "nRF Cloud support"
250250
default y
251+
depends on NRF_CLOUD
252+
depends on NRF_CLOUD_COAP
253+
depends on DATE_TIME
251254
select EXPERIMENTAL
252255

253256
if SM_NRF_CLOUD
@@ -261,6 +264,7 @@ endif # SM_NRF_CLOUD
261264

262265
config SM_NRF_CLOUD_LOCATION
263266
bool "nRF Cloud Location support"
267+
default y
264268
depends on SM_NRF_CLOUD
265269
help
266270
Enable the nRF Cloud Location service for cloud-assisted geolocation.

app/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ CONFIG_SETTINGS_NVS=y
9494
CONFIG_NVS=y
9595

9696
# nRF Cloud
97-
CONFIG_SM_NRF_CLOUD_LOCATION=y
9897
CONFIG_NRF_CLOUD=y
9998
CONFIG_NRF_CLOUD_COAP=y
10099
CONFIG_NRF_CLOUD_COAP_DOWNLOADS=n

app/src/sm_at_gnss.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,11 @@ static void agnss_requestor(struct k_work *)
322322
int err;
323323
struct nrf_modem_gnss_agnss_data_frame req;
324324
struct nrf_cloud_coap_agnss_request request = {
325-
NRF_CLOUD_COAP_AGNSS_REQ_CUSTOM,
326-
&req,
325+
.type = NRF_CLOUD_COAP_AGNSS_REQ_CUSTOM,
326+
.agnss_req = &req,
327+
.net_info = NULL,
328+
.filtered = false,
329+
.mask_angle = 0,
327330
};
328331
char *agnss_rest_data_buf = calloc(1, NRF_CLOUD_AGNSS_MAX_DATA_SIZE);
329332

@@ -339,20 +342,30 @@ static void agnss_requestor(struct k_work *)
339342
}
340343

341344
struct nrf_cloud_coap_agnss_result result = {
342-
agnss_rest_data_buf,
343-
NRF_CLOUD_AGNSS_MAX_DATA_SIZE,
344-
0
345+
.buf = agnss_rest_data_buf,
346+
.buf_sz = NRF_CLOUD_AGNSS_MAX_DATA_SIZE,
347+
.agnss_sz = 0,
345348
};
346-
struct lte_lc_cells_info net_info = {0};
347349

348-
err = get_single_cell_info(&net_info.current_cell);
349-
if (err) {
350-
LOG_ERR("Failed to obtain single-cell cellular network information (%d).", err);
351-
goto cleanup;
352-
}
353-
request.net_info = &net_info;
350+
#if defined(CONFIG_SM_NRF_CLOUD_LOCATION)
351+
struct lte_lc_cells_info *net_info = sm_at_nrfcloud_ncellmeas(1, false);
354352

353+
if (net_info != NULL && net_info->current_cell.id != LTE_LC_CELL_EUTRAN_ID_INVALID) {
354+
request.net_info = net_info;
355+
} else {
356+
LOG_WRN("Requesting A-GNSS data without location assistance");
357+
sm_at_nrfcloud_ncellmeas_cleanup(net_info);
358+
net_info = NULL;
359+
}
360+
#else
361+
LOG_INF("Requesting A-GNSS data without location assistance "
362+
"since CONFIG_SM_NRF_CLOUD_LOCATION is not defined");
363+
#endif
355364
err = nrf_cloud_coap_agnss_data_get(&request, &result);
365+
#if defined(CONFIG_SM_NRF_CLOUD_LOCATION)
366+
sm_at_nrfcloud_ncellmeas_cleanup(net_info);
367+
net_info = NULL;
368+
#endif
356369
if (err) {
357370
LOG_ERR("Failed to request A-GNSS data via CoAP (%d).", err);
358371
goto cleanup;

0 commit comments

Comments
 (0)