Skip to content

Commit

Permalink
samples: cellular: gnss: GNSS QZSS assistance support
Browse files Browse the repository at this point in the history
Added support for QZSS assistance.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
  • Loading branch information
tokangas authored and lemrey committed Aug 24, 2023
1 parent 9cdc59f commit c6d1dfc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
34 changes: 28 additions & 6 deletions samples/cellular/gnss/src/assistance.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,25 @@ static void pgps_event_handler(struct nrf_cloud_pgps_event *event)
}
#endif /* CONFIG_NRF_CLOUD_PGPS */

#if defined(CONFIG_NRF_CLOUD_AGPS)
static const char *get_system_string(uint8_t system_id)
{
switch (system_id) {
case NRF_MODEM_GNSS_SYSTEM_INVALID:
return "invalid";

case NRF_MODEM_GNSS_SYSTEM_GPS:
return "GPS";

case NRF_MODEM_GNSS_SYSTEM_QZSS:
return "QZSS";

default:
return "unknown";
}
}
#endif /* CONFIG_NRF_CLOUD_AGPS */

int assistance_init(struct k_work_q *assistance_work_q)
{
work_q = assistance_work_q;
Expand Down Expand Up @@ -242,9 +261,9 @@ int assistance_request(struct nrf_modem_gnss_agnss_data_frame *agnss_request)
return 0;
}

/* P-GPS will handle ephemerides, so skip those. */
/* P-GPS will handle GPS ephemerides, so skip those. */
agnss_request->system[0].sv_mask_ephe = 0;
/* Almanacs are not needed with P-GPS, so skip those. */
/* GPS almanacs are not needed with P-GPS, so skip those. */
agnss_request->system[0].sv_mask_alm = 0;
#endif /* CONFIG_NRF_CLOUD_AGPS */
#endif /* CONFIG_NRF_CLOUD_PGPS */
Expand Down Expand Up @@ -307,10 +326,13 @@ int assistance_request(struct nrf_modem_gnss_agnss_data_frame *agnss_request)
request.net_info = &net_info;
}

LOG_INF("Requesting A-GPS data, ephe 0x%08x, alm 0x%08x, flags 0x%02x",
(uint32_t)agnss_request->system[0].sv_mask_ephe,
(uint32_t)agnss_request->system[0].sv_mask_alm,
agnss_request->data_flags);
LOG_INF("Requesting A-GNSS data: data_flags: 0x%02x", agnss_request->data_flags);
for (int i = 0; i < agnss_request->system_count; i++) {
LOG_INF("Requesting A-GNSS data: %s ephe: 0x%llx, alm: 0x%llx",
get_system_string(agnss_request->system[i].system_id),
agnss_request->system[i].sv_mask_ephe,
agnss_request->system[i].sv_mask_alm);
}

err = nrf_cloud_rest_agps_data_get(&rest_ctx, &request, &result);
if (err) {
Expand Down
35 changes: 31 additions & 4 deletions samples/cellular/gnss/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,23 @@ void lte_disconnect(void)
}
#endif /* CONFIG_GNSS_SAMPLE_LTE_ON_DEMAND */

static const char *get_system_string(uint8_t system_id)
{
switch (system_id) {
case NRF_MODEM_GNSS_SYSTEM_INVALID:
return "invalid";

case NRF_MODEM_GNSS_SYSTEM_GPS:
return "GPS";

case NRF_MODEM_GNSS_SYSTEM_QZSS:
return "QZSS";

default:
return "unknown";
}
}

static void agnss_data_get_work_fn(struct k_work *item)
{
ARG_UNUSED(item);
Expand Down Expand Up @@ -268,12 +285,22 @@ static void agnss_data_get_work_fn(struct k_work *item)
}
#endif /* CONFIG_GNSS_SAMPLE_ASSISTANCE_MINIMAL */

if (last_agnss.data_flags == 0 &&
last_agnss.system[0].sv_mask_ephe == 0 &&
last_agnss.system[0].sv_mask_alm == 0) {
LOG_INF("Ignoring assistance request because only QZSS data is requested");
return;
}

requesting_assistance = true;

LOG_INF("Assistance data needed, ephe 0x%08x, alm 0x%08x, flags 0x%02x",
(uint32_t)last_agnss.system[0].sv_mask_ephe,
(uint32_t)last_agnss.system[0].sv_mask_alm,
last_agnss.data_flags);
LOG_INF("Assistance data needed: data_flags: 0x%02x", last_agnss.data_flags);
for (int i = 0; i < last_agnss.system_count; i++) {
LOG_INF("Assistance data needed: %s ephe: 0x%llx, alm: 0x%llx",
get_system_string(last_agnss.system[i].system_id),
last_agnss.system[i].sv_mask_ephe,
last_agnss.system[i].sv_mask_alm);
}

#if defined(CONFIG_GNSS_SAMPLE_LTE_ON_DEMAND)
lte_connect();
Expand Down

0 comments on commit c6d1dfc

Please sign in to comment.