nRF Connect SDK API 2.8.0
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
22#ifdef __cplusplus
23extern "C" {
24#endif
25
30#define NRF_CLOUD_PGPS_NUM_SV (32U)
31
42 uint16_t date_day;
44 uint32_t time_full_s;
46 uint16_t time_frac_ms;
48 uint32_t sv_mask;
50 uint32_t pad;
51} __packed;
52
56 uint8_t time_type;
58 uint16_t time_count;
68 struct nrf_cloud_agnss_ephemeris ephemerii[NRF_CLOUD_PGPS_NUM_SV];
70 uint32_t sentinel;
71} __packed;
72
74#define NRF_CLOUD_PGPS_REQ_NO_COUNT 0
76#define NRF_CLOUD_PGPS_REQ_NO_INTERVAL 0
78#define NRF_CLOUD_PGPS_REQ_NO_GPS_DAY 0
80#define NRF_CLOUD_PGPS_REQ_NO_GPS_TOD (-1)
81
91 uint16_t gps_day;
96} __packed;
97
104 char *host;
106 size_t host_sz;
107
109 char *path;
111 size_t path_sz;
112};
113
115#define ETIMEUNKNOWN 8000
117#define ELOADING 8001
118
122#define NRF_CLOUD_PGPS_EMPTY_EPHEM_HEALTH (0xff)
123
149
157
164typedef void (*pgps_event_handler_t)(struct nrf_cloud_pgps_event *event);
165
175
186void nrf_cloud_pgps_set_location_normalized(int32_t latitude, int32_t longitude);
187
198void nrf_cloud_pgps_set_location(double latitude, double longitude);
199
205
212void nrf_cloud_pgps_set_leap_seconds(int leap_seconds);
213
222
234
248int nrf_cloud_pgps_request(const struct gps_pgps_request *request);
249
256
273
288int nrf_cloud_pgps_process_update(uint8_t *buf, size_t len);
289
302
312
322int nrf_cloud_pgps_process(const char *buf, size_t buf_len);
323
333
343 const struct nrf_modem_gnss_agnss_data_frame *request);
344
350
357
369
372#ifdef __cplusplus
373#endif
374
375#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:30
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:164
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:125
@ PGPS_EVT_LOADING
Definition nrf_cloud_pgps.h:131
@ PGPS_EVT_UNAVAILABLE
Definition nrf_cloud_pgps.h:129
@ PGPS_EVT_REQUEST
Definition nrf_cloud_pgps.h:147
@ PGPS_EVT_INIT
Definition nrf_cloud_pgps.h:127
@ PGPS_EVT_AVAILABLE
Definition nrf_cloud_pgps.h:136
@ PGPS_EVT_READY
Definition nrf_cloud_pgps.h:138
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 over MQTT or REST.
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...
uint16_t prediction_count
Definition nrf_cloud_pgps.h:85
uint32_t gps_time_of_day
Definition nrf_cloud_pgps.h:95
uint16_t gps_day
Definition nrf_cloud_pgps.h:91
uint16_t prediction_period_min
Definition nrf_cloud_pgps.h:87
P-GPS request type.
Definition nrf_cloud_pgps.h:83
struct nrf_cloud_pgps_prediction * prediction
Definition nrf_cloud_pgps.h:153
struct gps_pgps_request * request
Definition nrf_cloud_pgps.h:154
enum nrf_cloud_pgps_event_type type
Definition nrf_cloud_pgps.h:151
Definition nrf_cloud_pgps.h:150
uint32_t storage_base
Definition nrf_cloud_pgps.h:171
pgps_event_handler_t event_handler
Definition nrf_cloud_pgps.h:169
uint32_t storage_size
Definition nrf_cloud_pgps.h:173
Initialization parameters for the module.
Definition nrf_cloud_pgps.h:167
uint16_t ephemeris_count
Definition nrf_cloud_pgps.h:66
uint8_t time_type
Definition nrf_cloud_pgps.h:56
struct nrf_cloud_pgps_system_time time
Definition nrf_cloud_pgps.h:60
uint16_t time_count
Definition nrf_cloud_pgps.h:58
uint8_t ephemeris_type
Definition nrf_cloud_pgps.h:64
uint8_t schema_version
Definition nrf_cloud_pgps.h:62
struct nrf_cloud_agnss_ephemeris ephemerii[(32U)]
Definition nrf_cloud_pgps.h:68
uint32_t sentinel
Definition nrf_cloud_pgps.h:70
P-GPS prediction Flash storage format.
Definition nrf_cloud_pgps.h:54
char * host
Definition nrf_cloud_pgps.h:104
size_t path_sz
Definition nrf_cloud_pgps.h:111
size_t host_sz
Definition nrf_cloud_pgps.h:106
char * path
Definition nrf_cloud_pgps.h:109
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:102
uint32_t time_full_s
Definition nrf_cloud_pgps.h:44
uint16_t date_day
Definition nrf_cloud_pgps.h:42
uint32_t pad
Definition nrf_cloud_pgps.h:50
uint32_t sv_mask
Definition nrf_cloud_pgps.h:48
uint16_t time_frac_ms
Definition nrf_cloud_pgps.h:46
nrf_cloud_pgps_system_time is a special version of nrf_cloud_agnss_system_time that does not include ...
Definition nrf_cloud_pgps.h:38