@@ -92,6 +92,8 @@ static struct k_work method_gnss_agps_ext_work;
9292static void method_gnss_agps_ext_work_fn (struct k_work * item );
9393#endif
9494
95+ static int fixes_remaining ;
96+
9597#if defined(CONFIG_NRF_CLOUD_PGPS )
9698static void method_gnss_manage_pgps (struct k_work * work )
9799{
@@ -582,6 +584,8 @@ static void method_gnss_pvt_work_fn(struct k_work *item)
582584 * in memory and it is not overwritten in case we get an invalid fix.
583585 */
584586 if (pvt_data .flags & NRF_MODEM_GNSS_PVT_FLAG_FIX_VALID ) {
587+ fixes_remaining -- ;
588+
585589 location_result .method = LOCATION_METHOD_GNSS ;
586590 location_result .latitude = pvt_data .latitude ;
587591 location_result .longitude = pvt_data .longitude ;
@@ -595,9 +599,11 @@ static void method_gnss_pvt_work_fn(struct k_work *item)
595599 location_result .datetime .second = pvt_data .datetime .seconds ;
596600 location_result .datetime .ms = pvt_data .datetime .ms ;
597601
598- /* We are done, stop GNSS and publish the fix. */
599- method_gnss_cancel ();
600- location_core_event_cb (& location_result );
602+ if (fixes_remaining <= 0 ) {
603+ /* We are done, stop GNSS and publish the fix. */
604+ method_gnss_cancel ();
605+ location_core_event_cb (& location_result );
606+ }
601607 }
602608}
603609
@@ -626,22 +632,27 @@ static void method_gnss_positioning_work_fn(struct k_work *work)
626632#if defined(CONFIG_NRF_CLOUD_AGPS_ELEVATION_MASK )
627633 err |= nrf_modem_gnss_elevation_threshold_set (CONFIG_NRF_CLOUD_AGPS_ELEVATION_MASK );
628634#endif
635+ /* By default we take the first fix. */
636+ fixes_remaining = 1 ;
629637
630- uint8_t use_case ;
638+ uint8_t use_case = NRF_MODEM_GNSS_USE_CASE_MULTIPLE_HOT_START ;
631639
632640 switch (gnss_config .accuracy ) {
633641 case LOCATION_ACCURACY_LOW :
634- use_case = NRF_MODEM_GNSS_USE_CASE_MULTIPLE_HOT_START |
635- NRF_MODEM_GNSS_USE_CASE_LOW_ACCURACY ;
636- err |= nrf_modem_gnss_use_case_set (use_case );
642+ use_case |= NRF_MODEM_GNSS_USE_CASE_LOW_ACCURACY ;
637643 break ;
638644
639645 case LOCATION_ACCURACY_NORMAL :
640- use_case = NRF_MODEM_GNSS_USE_CASE_MULTIPLE_HOT_START ;
641- err |= nrf_modem_gnss_use_case_set (use_case );
646+ break ;
647+
648+ case LOCATION_ACCURACY_HIGH :
649+ /* In high accuracy mode, use the configured fix count. */
650+ fixes_remaining = gnss_config .num_consecutive_fixes ;
642651 break ;
643652 }
644653
654+ err |= nrf_modem_gnss_use_case_set (use_case );
655+
645656 if (err ) {
646657 LOG_ERR ("Failed to configure GNSS" );
647658 location_core_event_cb_error ();
0 commit comments