99 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
1010 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
1111 */
12-
1312#include <stdio.h>
1413#include <string.h>
1514
2322#include <libswiftnav/dgnss_management.h>
2423#include <libswiftnav/baseline.h>
2524#include <libswiftnav/linear_algebra.h>
25+ #include <libswiftnav/troposphere.h>
2626
2727#define memory_pool_t MemoryPool
2828#include <ch.h>
4343#include "signal.h"
4444#include "system_monitor.h"
4545#include "main.h"
46+ #include "iono.h"
4647#include "sid_set.h"
4748
4849/* Maximum CPU time the solution thread is allowed to use. */
@@ -433,6 +434,9 @@ static void sol_thd_sleep(systime_t *deadline, systime_t interval)
433434static THD_WORKING_AREA (wa_solution_thread , 8000 ) ;
434435static void solution_thread (void * arg )
435436{
437+ /* The flag is true when we have a fix */
438+ bool soln_flag = false;
439+
436440 (void )arg ;
437441 chRegSetThreadName ("solution" );
438442
@@ -534,6 +538,20 @@ static void solution_thread(void *arg)
534538 continue ;
535539 }
536540
541+ /* check if we have a solution, if yes calc iono and tropo correction */
542+ if (soln_flag ) {
543+ ionosphere_t i_params ;
544+ ionosphere_t * p_i_params = & i_params ;
545+ /* get iono parameters if available */
546+ if (!gps_iono_params_read (p_i_params )) {
547+ p_i_params = NULL ;
548+ }
549+ calc_iono_tropo (n_ready_tdcp , nav_meas_tdcp ,
550+ position_solution .pos_ecef ,
551+ position_solution .pos_llh ,
552+ p_i_params );
553+ }
554+
537555 dops_t dops ;
538556 /* Calculate the SPP position
539557 * disable_raim controlled by external setting. Defaults to false. */
@@ -548,11 +566,15 @@ static void solution_thread(void *arg)
548566 log_warn ("PVT solver: %s (code %d)" , pvt_err_msg [- pvt_ret - 1 ], pvt_ret );
549567 );
550568
569+ soln_flag = false;
570+
551571 /* Send just the DOPs and exit the loop */
552572 solution_send_sbp (0 , & dops , clock_jump );
553573 continue ;
554574 }
555575
576+ soln_flag = true;
577+
556578 if (pvt_ret == 1 )
557579 log_warn ("calc_PVT: RAIM repair" );
558580
0 commit comments