nRF Connect SDK API 3.3.99
Loading...
Searching...
No Matches
nrf_cloud_pgps.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef NRF_CLOUD_PGPS_H_
8#define NRF_CLOUD_PGPS_H_
9
14#include <zephyr/kernel.h>
15#if defined(CONFIG_NRF_MODEM)
16#include <nrf_modem_gnss.h>
17#else
18struct nrf_modem_gnss_agnss_data_frame;
19#endif
20#include "nrf_cloud_agnss_schema_v1.h"
21#if defined(CONFIG_NRF_CLOUD_COAP)
23#endif
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
33#define NRF_CLOUD_PGPS_NUM_SV (32U)
34
45 uint16_t date_day;
47 uint32_t time_full_s;
49 uint16_t time_frac_ms;
51 uint32_t sv_mask;
53 uint32_t pad;
54} __packed;
55
59 uint8_t time_type;
61 uint16_t time_count;
71 struct nrf_cloud_agnss_ephemeris ephemerii[NRF_CLOUD_PGPS_NUM_SV];
73 uint32_t sentinel;
74} __packed;
75
77#define NRF_CLOUD_PGPS_REQ_NO_COUNT 0
79#define NRF_CLOUD_PGPS_REQ_NO_INTERVAL 0
81#define NRF_CLOUD_PGPS_REQ_NO_GPS_DAY 0
83#define NRF_CLOUD_PGPS_REQ_NO_GPS_TOD (-1)
84
94 uint16_t gps_day;
99} __packed;
100
107 char *host;
109 size_t host_sz;
111 char *path;
113 size_t path_sz;
114};
115
128
130#define ETIMEUNKNOWN 8000
132#define ELOADING 8001
133
137#define NRF_CLOUD_PGPS_EMPTY_EPHEM_HEALTH (0xff)
138
164
172
179typedef void (*pgps_event_handler_t)(struct nrf_cloud_pgps_event *event);
180
190
201void nrf_cloud_pgps_set_location_normalized(int32_t latitude, int32_t longitude);
202
213void nrf_cloud_pgps_set_location(double latitude, double longitude);
214
220
227void nrf_cloud_pgps_set_leap_seconds(int leap_seconds);
228
237
249
263int nrf_cloud_pgps_request(const struct gps_pgps_request *request);
264
271
288
303int nrf_cloud_pgps_process_update(uint8_t *buf, size_t len);
304
317
327
337int nrf_cloud_pgps_process(const char *buf, size_t buf_len);
338
348
358 const struct nrf_modem_gnss_agnss_data_frame *request);
359
365
372
384
387#ifdef __cplusplus
388}
389#endif
390
391#endif /* NRF_CLOUD_PGPS_H_ */
int nrf_cloud_pgps_update(struct nrf_cloud_pgps_result *file_location)
Processes binary P-GPS data using URL received from nRF Cloud.
int nrf_cloud_pgps_process_update(uint8_t *buf, size_t len)
Call this function when your transport receives a block of prediction data. Prediction data must be r...
#define NRF_CLOUD_PGPS_NUM_SV
Definition nrf_cloud_pgps.h:33
bool nrf_cloud_pgps_loading(void)
Find out if P-GPS update is in progress.
int nrf_cloud_pgps_finish_update(void)
Call this function regardless of whether the download succeeded or failed.
void nrf_cloud_pgps_set_leap_seconds(int leap_seconds)
Update the storage of the leap second offset between GPS time and UTC. This called automatically by t...
void nrf_cloud_pgps_request_reset(void)
If previous request for P-GPS data failed, re-enable future retries. This should be called by the app...
int nrf_cloud_pgps_begin_update(void)
Use this function when you use a custom transport mechanism for downloading prediction data....
void nrf_cloud_pgps_clear_location(void)
If location has previously been set, clear it. The application should do this if significant distance...
void(* pgps_event_handler_t)(struct nrf_cloud_pgps_event *event)
Event handler registered with the module to handle asynchronous events from the module.
Definition nrf_cloud_pgps.h:179
int nrf_cloud_pgps_notify_prediction(void)
Schedule a callback when prediction for current time is available. Callback could be immediate,...
int nrf_cloud_pgps_request_all(void)
Requests all available P-GPS data from nRF Cloud via MQTT. Not used for other transports.
nrf_cloud_pgps_event_type
P-GPS event passed to the registered pgps_event_handler.
Definition nrf_cloud_pgps.h:140
@ PGPS_EVT_LOADING
Definition nrf_cloud_pgps.h:146
@ PGPS_EVT_UNAVAILABLE
Definition nrf_cloud_pgps.h:144
@ PGPS_EVT_REQUEST
Definition nrf_cloud_pgps.h:162
@ PGPS_EVT_INIT
Definition nrf_cloud_pgps.h:142
@ PGPS_EVT_AVAILABLE
Definition nrf_cloud_pgps.h:151
@ PGPS_EVT_READY
Definition nrf_cloud_pgps.h:153
int nrf_cloud_pgps_preemptive_updates(void)
Download more predictions if less than CONFIG_NRF_CLOUD_PGPS_REPLACEMENT_THRESHOLD predictions remain...
int nrf_cloud_pgps_init(struct nrf_cloud_pgps_init_param *param)
Initialize P-GPS subsystem. Validates what is stored, then requests any missing predictions,...
int nrf_cloud_pgps_request(const struct gps_pgps_request *request)
Requests specified P-GPS data from nRF Cloud via MQTT. Not used for other transports.
int nrf_cloud_pgps_find_prediction(struct nrf_cloud_pgps_prediction **prediction)
Tries to find an appropriate GPS prediction for the current time.
int nrf_cloud_pgps_inject(struct nrf_cloud_pgps_prediction *p, const struct nrf_modem_gnss_agnss_data_frame *request)
Injects binary P-GPS data to the modem. If request is NULL, it is assumed that only ephemerides assis...
void nrf_cloud_pgps_set_location_normalized(int32_t latitude, int32_t longitude)
Update storage of the most recent known location, in modem-specific normalized format (int32_t)....
int nrf_cloud_pgps_process(const char *buf, size_t buf_len)
Processes binary P-GPS data received from nRF Cloud.
void nrf_cloud_pgps_set_location(double latitude, double longitude)
Update the storage of the most recent known location in degrees. This will be injected along with the...
Module to provide nRF Cloud location support to nRF9160 SiP.
uint16_t prediction_count
Definition nrf_cloud_pgps.h:88
uint32_t gps_time_of_day
Definition nrf_cloud_pgps.h:98
uint16_t gps_day
Definition nrf_cloud_pgps.h:94
uint16_t prediction_period_min
Definition nrf_cloud_pgps.h:90
P-GPS request type.
Definition nrf_cloud_pgps.h:86
const struct gps_pgps_request * pgps_req
Definition nrf_cloud_pgps.h:126
Data required for nRF Cloud Predicted GPS (P-GPS) request.
Definition nrf_cloud_pgps.h:122
struct nrf_cloud_pgps_prediction * prediction
Definition nrf_cloud_pgps.h:168
struct gps_pgps_request * request
Definition nrf_cloud_pgps.h:169
enum nrf_cloud_pgps_event_type type
Definition nrf_cloud_pgps.h:166
Definition nrf_cloud_pgps.h:165
uint32_t storage_base
Definition nrf_cloud_pgps.h:186
pgps_event_handler_t event_handler
Definition nrf_cloud_pgps.h:184
uint32_t storage_size
Definition nrf_cloud_pgps.h:188
Initialization parameters for the module.
Definition nrf_cloud_pgps.h:182
uint16_t ephemeris_count
Definition nrf_cloud_pgps.h:69
uint8_t time_type
Definition nrf_cloud_pgps.h:59
struct nrf_cloud_pgps_system_time time
Definition nrf_cloud_pgps.h:63
uint16_t time_count
Definition nrf_cloud_pgps.h:61
uint8_t ephemeris_type
Definition nrf_cloud_pgps.h:67
uint8_t schema_version
Definition nrf_cloud_pgps.h:65
struct nrf_cloud_agnss_ephemeris ephemerii[(32U)]
Definition nrf_cloud_pgps.h:71
uint32_t sentinel
Definition nrf_cloud_pgps.h:73
P-GPS prediction Flash storage format.
Definition nrf_cloud_pgps.h:57
char * host
Definition nrf_cloud_pgps.h:107
size_t path_sz
Definition nrf_cloud_pgps.h:113
size_t host_sz
Definition nrf_cloud_pgps.h:109
char * path
Definition nrf_cloud_pgps.h:111
nRF Cloud Predicted GPS (P-GPS) result; the location of the P-GPS data file which is to be downloaded...
Definition nrf_cloud_pgps.h:105
uint32_t time_full_s
Definition nrf_cloud_pgps.h:47
uint16_t date_day
Definition nrf_cloud_pgps.h:45
uint32_t pad
Definition nrf_cloud_pgps.h:53
uint32_t sv_mask
Definition nrf_cloud_pgps.h:51
uint16_t time_frac_ms
Definition nrf_cloud_pgps.h:49
nrf_cloud_pgps_system_time is a special version of nrf_cloud_agnss_system_time that does not include ...
Definition nrf_cloud_pgps.h:41