Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Commit 67bfe16

Browse files
author
GitHub Actions
committed
1 parent a028013 commit 67bfe16

2 files changed

Lines changed: 38 additions & 7 deletions

File tree

src/modules/cloud_module.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,21 @@ static void agps_data_handle(const uint8_t *buf, size_t len)
246246
LOG_WRN("Unable to process A-GPS data, error: %d", err);
247247
} else {
248248
LOG_DBG("A-GPS data processed");
249-
return;
250249
}
251250
#endif
252251

253252
#if defined(CONFIG_NRF_CLOUD_PGPS)
253+
#if defined(CONFIG_NRF_CLOUD_AGPS)
254+
if (!err) {
255+
err = nrf_cloud_pgps_notify_prediction();
256+
if (err) {
257+
LOG_ERR("Error requesting prediction notification: %d", err);
258+
} else {
259+
return;
260+
}
261+
}
262+
#endif
263+
254264
LOG_DBG("Process incoming data if P-GPS related");
255265

256266
err = nrf_cloud_pgps_process(buf, len);
@@ -638,6 +648,10 @@ void pgps_handler(struct nrf_cloud_pgps_event *event)
638648
LOG_ERR("Unable to send prediction to modem: %d", err);
639649
}
640650

651+
err = nrf_cloud_pgps_preemptive_updates();
652+
if (err) {
653+
LOG_ERR("Error requesting updates: %d", err);
654+
}
641655
break;
642656
case PGPS_EVT_REQUEST: {
643657
LOG_DBG("PGPS_EVT_REQUEST");

src/modules/data_module.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,31 +979,48 @@ static void agps_request_handle(struct nrf_modem_gnss_agps_data_frame *incoming_
979979
{
980980
int err;
981981

982+
#if defined(CONFIG_NRF_CLOUD_AGPS)
983+
struct nrf_modem_gnss_agps_data_frame request;
984+
985+
#if defined(CONFIG_NRF_CLOUD_PGPS)
986+
request.sv_mask_ephe = 0;
987+
request.sv_mask_alm = 0;
988+
#else
989+
request.sv_mask_ephe = incoming_request->sv_mask_ephe;
990+
request.sv_mask_alm = incoming_request->sv_mask_alm;
991+
#endif
992+
request.data_flags = incoming_request->data_flags;
993+
994+
#if defined(CONFIG_NRF_CLOUD_MQTT)
982995
/* If CONFIG_NRF_CLOUD_MQTT is enabled, the nRF Cloud MQTT transport library will be used
983996
* to send the request.
984997
*/
985-
#if defined(CONFIG_NRF_CLOUD_AGPS) && defined(CONFIG_NRF_CLOUD_MQTT)
986-
err = nrf_cloud_agps_request(incoming_request);
998+
err = nrf_cloud_agps_request(&request);
987999
if (err) {
9881000
LOG_WRN("Failed to request A-GPS data, error: %d", err);
9891001
LOG_WRN("This is expected to fail if we are not in a connected state");
9901002
} else {
991-
LOG_DBG("A-GPS request sent");
992-
return;
1003+
if (nrf_cloud_agps_request_in_progress()) {
1004+
LOG_DBG("A-GPS request sent");
1005+
return;
1006+
}
1007+
LOG_DBG("No A-GPS data requested");
1008+
/* Continue so P-GPS, if enabled, can be requested. */
9931009
}
994-
#elif defined(CONFIG_NRF_CLOUD_AGPS) && !defined(CONFIG_NRF_CLOUD_MQTT)
1010+
#else
9951011
/* If the nRF Cloud MQTT transport library is not enabled, we will have to create an
9961012
* A-GPS request and send out an event containing the request for the cloud module to pick
9971013
* up and send to the cloud that is currently used.
9981014
*/
999-
err = agps_request_encode(incoming_request);
1015+
err = agps_request_encode(&request);
10001016
if (err) {
10011017
LOG_WRN("Failed to request A-GPS data, error: %d", err);
10021018
} else {
10031019
LOG_DBG("A-GPS request sent");
10041020
return;
10051021
}
10061022
#endif
1023+
#endif
10071024

10081025
#if defined(CONFIG_NRF_CLOUD_PGPS)
10091026
/* A-GPS data is not expected to be received. Proceed to schedule a callback when

0 commit comments

Comments
 (0)