nRF Connect SDK API 2.8.0
Loading...
Searching...
No Matches
location.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 LOCATION_H_
8#define LOCATION_H_
9
10#include <stdbool.h>
11#include <stddef.h>
12#include <stdint.h>
13#if (defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_NRF_CLOUD_AGNSS)) ||\
14 defined(CONFIG_LOCATION_DATA_DETAILS)
15#include <nrf_modem_gnss.h>
16#endif
17#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_NRF_CLOUD_PGPS)
18#include <net/nrf_cloud_pgps.h>
19#endif
20#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_LOCATION_METHOD_CELLULAR)
21#include <modem/lte_lc.h>
22#endif
23#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_LOCATION_METHOD_WIFI)
25#endif
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
60
68
119
134
144
159
163 bool valid;
165 uint16_t year;
167 uint8_t month;
169 uint8_t day;
171 uint8_t hour;
173 uint8_t minute;
175 uint8_t second;
177 uint16_t ms;
178};
179
180#if defined(CONFIG_LOCATION_DATA_DETAILS)
188 struct nrf_modem_gnss_pvt_data_frame pvt_data;
199};
200
208
214
232
233#if defined(CONFIG_LOCATION_METHOD_GNSS)
235 struct location_data_details_gnss gnss;
236#endif
237#if defined(CONFIG_LOCATION_METHOD_CELLULAR)
240#endif
241#if defined(CONFIG_LOCATION_METHOD_WIFI)
244#endif
245};
246#endif
247
251 double latitude;
253 double longitude;
255 float accuracy;
258
259#if defined(CONFIG_LOCATION_DATA_DETAILS)
262#endif
263};
264
265#if defined(CONFIG_LOCATION_DATA_DETAILS)
271
277
291#endif
292
295#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_LOCATION_METHOD_CELLULAR)
298#endif
299#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_LOCATION_METHOD_WIFI)
302#endif
303};
304
311
313 union {
316
317#if defined(CONFIG_LOCATION_DATA_DETAILS)
323
329
336#endif
337
338#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_NRF_CLOUD_AGNSS)
343 struct nrf_modem_gnss_agnss_data_frame agnss_request;
344#endif
345#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) && defined(CONFIG_NRF_CLOUD_PGPS)
351#endif
352#if defined(CONFIG_LOCATION_SERVICE_EXTERNAL) &&\
353 (defined(CONFIG_LOCATION_METHOD_CELLULAR) || defined(CONFIG_LOCATION_METHOD_WIFI))
360#endif
361 };
362};
363
449
502
533
547
552
565 struct location_method_config methods[CONFIG_LOCATION_METHODS_LIST_SIZE];
566
577 uint16_t interval;
578
593 int32_t timeout;
594
602};
603
609typedef void (*location_event_handler_t)(const struct location_event_data *event_data);
610
625
635
650
674int location_request(const struct location_config *config);
675
683
695 struct location_config *config,
696 uint8_t methods_count,
697 enum location_method *method_types);
698
707
721 const struct location_event_data *event_data);
722
741int location_agnss_data_process(const char *buf, size_t buf_len);
742
761int location_pgps_data_process(const char *buf, size_t buf_len);
762
783 enum location_ext_result result,
784 struct location_data *location);
785
788#ifdef __cplusplus
789}
790#endif
791
792#endif /* LOCATION_H_ */
location_service
Definition location.h:146
@ LOCATION_SERVICE_NRF_CLOUD
Definition location.h:155
@ LOCATION_SERVICE_ANY
Definition location.h:153
@ LOCATION_SERVICE_HERE
Definition location.h:157
void location_cloud_location_ext_result_set(enum location_ext_result result, struct location_data *location)
Pass cloud location result to the library.
int location_agnss_data_process(const char *buf, size_t buf_len)
Feed in A-GNSS data to be processed by library.
int location_pgps_data_process(const char *buf, size_t buf_len)
Feed in P-GPS data to be processed by library.
location_ext_result
Definition location.h:121
@ LOCATION_EXT_RESULT_SUCCESS
Definition location.h:123
@ LOCATION_EXT_RESULT_UNKNOWN
Definition location.h:130
@ LOCATION_EXT_RESULT_ERROR
Definition location.h:132
location_req_mode
Definition location.h:62
@ LOCATION_REQ_MODE_FALLBACK
Definition location.h:64
@ LOCATION_REQ_MODE_ALL
Definition location.h:66
int location_request_cancel(void)
Cancels periodic position updates.
int location_init(location_event_handler_t handler)
Initializes the library.
void location_config_defaults_set(struct location_config *config, uint8_t methods_count, enum location_method *method_types)
Sets the default values to a given configuration.
int location_handler_register(location_event_handler_t handler)
void(* location_event_handler_t)(const struct location_event_data *event_data)
Event handler prototype.
Definition location.h:609
int location_handler_deregister(location_event_handler_t handler)
const struct location_data_details * location_details_get(const struct location_event_data *event_data)
Get location data details from the location event data.
const char * location_method_str(enum location_method method)
Return location method as a string.
int location_request(const struct location_config *config)
Requests the current position or starts periodic position updates.
location_accuracy
Definition location.h:136
@ LOCATION_ACCURACY_LOW
Definition location.h:138
@ LOCATION_ACCURACY_NORMAL
Definition location.h:140
@ LOCATION_ACCURACY_HIGH
Definition location.h:142
location_event_id
Definition location.h:70
@ LOCATION_EVT_RESULT_UNKNOWN
Definition location.h:83
@ LOCATION_EVT_STARTED
Definition location.h:109
@ LOCATION_EVT_GNSS_ASSISTANCE_REQUEST
Definition location.h:89
@ LOCATION_EVT_ERROR
Definition location.h:76
@ LOCATION_EVT_LOCATION
Definition location.h:72
@ LOCATION_EVT_GNSS_PREDICTION_REQUEST
Definition location.h:95
@ LOCATION_EVT_CLOUD_LOCATION_EXT_REQUEST
Definition location.h:103
@ LOCATION_EVT_FALLBACK
Definition location.h:117
@ LOCATION_EVT_TIMEOUT
Definition location.h:74
location_method
Definition location.h:39
@ LOCATION_METHOD_CELLULAR
Definition location.h:41
@ LOCATION_METHOD_WIFI_CELLULAR
Definition location.h:58
@ LOCATION_METHOD_WIFI
Definition location.h:45
@ LOCATION_METHOD_GNSS
Definition location.h:43
Module to provide nRF Cloud Predicted GPS (P-GPS) support to nRF9160 SiP.
P-GPS request type.
Definition nrf_cloud_pgps.h:83
uint8_t cell_count
Number of cells to be requested for cellular positioning.
Definition location.h:500
enum location_service service
Used cellular positioning service.
Definition location.h:477
int32_t timeout
Timeout (in milliseconds) of how long the cellular positioning procedure can take....
Definition location.h:467
Definition location.h:451
struct location_method_config methods[CONFIG_LOCATION_METHODS_LIST_SIZE]
Selected location methods and associated configurations in priority order.
Definition location.h:565
enum location_req_mode mode
Location acquisition mode.
Definition location.h:601
int32_t timeout
Timeout (in milliseconds) for the entire location request.
Definition location.h:593
uint8_t methods_count
Definition location.h:551
uint16_t interval
Position update interval in seconds.
Definition location.h:577
Definition location.h:549
const struct lte_lc_cells_info * cell_data
Definition location.h:297
const struct wifi_scan_info * wifi_data
Definition location.h:301
Definition location.h:294
uint8_t ncells_count
Definition location.h:204
uint8_t gci_cells_count
Definition location.h:206
Definition location.h:202
uint32_t elapsed_time_gnss
Definition location.h:198
struct nrf_modem_gnss_pvt_data_frame pvt_data
Definition location.h:188
uint8_t satellites_tracked
Definition location.h:184
uint8_t satellites_used
Definition location.h:186
Definition location.h:182
uint16_t ap_count
Definition location.h:212
Definition location.h:210
struct location_data_details_cellular cellular
Definition location.h:239
uint32_t elapsed_time_method
Definition location.h:231
struct location_data_details_wifi wifi
Definition location.h:243
Definition location.h:223
struct location_data_details details
Definition location.h:269
Definition location.h:267
enum location_method next_method
Definition location.h:281
struct location_data_details details
Definition location.h:289
enum location_event_id cause
Definition location.h:287
Definition location.h:279
struct location_data_details details
Definition location.h:275
Definition location.h:273
double latitude
Definition location.h:251
float accuracy
Definition location.h:255
double longitude
Definition location.h:253
struct location_data_details details
Definition location.h:261
struct location_datetime datetime
Definition location.h:257
Definition location.h:249
uint8_t day
Definition location.h:169
uint8_t second
Definition location.h:175
uint16_t ms
Definition location.h:177
bool valid
Definition location.h:163
uint8_t minute
Definition location.h:173
uint8_t hour
Definition location.h:171
uint16_t year
Definition location.h:165
uint8_t month
Definition location.h:167
Definition location.h:161
struct location_data_cloud cloud_location_request
Definition location.h:359
struct gps_pgps_request pgps_request
Definition location.h:350
struct location_data_unknown unknown
Definition location.h:328
enum location_method method
Definition location.h:310
struct location_data_error error
Definition location.h:322
struct location_data_fallback fallback
Definition location.h:335
struct nrf_modem_gnss_agnss_data_frame agnss_request
Definition location.h:343
enum location_event_id id
Definition location.h:308
struct location_data location
Definition location.h:315
Definition location.h:306
int32_t timeout
Timeout (in milliseconds), meaning how long GNSS is allowed to run when trying to acquire a fix....
Definition location.h:382
enum location_accuracy accuracy
Desired accuracy level.
Definition location.h:396
bool priority_mode
Enable GNSS priority mode if GNSS does not get enough runtime due to LTE idle mode operations.
Definition location.h:447
bool visibility_detection
Obstructed visibility detection. If set to true, the library tries to detect situations where getting...
Definition location.h:425
uint8_t num_consecutive_fixes
The number of fixes GNSS is allowed to produce before the library outputs the current location when a...
Definition location.h:409
Definition location.h:365
enum location_method method
Definition location.h:537
struct location_gnss_config gnss
Definition location.h:542
struct location_cellular_config cellular
Definition location.h:540
struct location_wifi_config wifi
Definition location.h:544
Definition location.h:535
enum location_service service
Used Wi-Fi positioning service.
Definition location.h:531
int32_t timeout
Timeout (in milliseconds) of how long the Wi-Fi positioning procedure can take. SYS_FOREVER_MS means ...
Definition location.h:521
Definition location.h:504
Definition lte_lc.h:529
Access points found during a Wi-Fi scan.
Definition wifi_location_common.h:29