Skip to content

Commit c2bd75d

Browse files
tokangasrlubos
authored andcommitted
samples: nrf9160: location: add GNSS high accuracy example
Added a new example for GNSS high accuracy location. Signed-off-by: Tommi Kangas <[email protected]>
1 parent 0649a61 commit c2bd75d

File tree

1 file changed

+25
-0
lines changed
  • samples/nrf9160/location/src

1 file changed

+25
-0
lines changed

samples/nrf9160/location/src/main.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,29 @@ static void location_gnss_low_accuracy_get(void)
160160
location_event_wait();
161161
}
162162

163+
/**
164+
* @brief Retrieve location with GNSS high accuracy.
165+
*/
166+
static void location_gnss_high_accuracy_get(void)
167+
{
168+
int err;
169+
struct location_config config;
170+
enum location_method methods[] = {LOCATION_METHOD_GNSS};
171+
172+
location_config_defaults_set(&config, sizeof(methods), methods);
173+
config.methods[0].gnss.accuracy = LOCATION_ACCURACY_HIGH;
174+
175+
printk("Requesting high accuracy GNSS location...\n");
176+
177+
err = location_request(&config);
178+
if (err) {
179+
printk("Requesting location failed, error: %d\n", err);
180+
return;
181+
}
182+
183+
location_event_wait();
184+
}
185+
163186
#if defined(CONFIG_LOCATION_METHOD_WIFI)
164187
/**
165188
* @brief Retrieve location with Wi-Fi positioning as first priority, GNSS as second
@@ -260,6 +283,8 @@ int main(void)
260283

261284
location_gnss_low_accuracy_get();
262285

286+
location_gnss_high_accuracy_get();
287+
263288
#if defined(CONFIG_LOCATION_METHOD_WIFI)
264289
location_wifi_get();
265290
#endif

0 commit comments

Comments
 (0)