2222#include <libswiftnav/ephemeris.h>
2323#include <libswiftnav/coord_system.h>
2424
25+ float decode_ura_index (const u8 index );
26+ u32 decode_fit_interval (u8 fit_interval_flag , u16 iodc );
27+
2528/** \defgroup ephemeris Ephemeris
2629 * Functions and calculations related to the GPS ephemeris.
2730 * \{ */
@@ -320,13 +323,13 @@ u8 ephemeris_valid(const ephemeris_t *e, const gps_time_t *t)
320323 * The function allows to avoid passing whole ephemeris
321324 *
322325 * \param valid ephemeris Valid flag after decoding
323- * \param fit_interval Curve fit interval in hours
326+ * \param fit_interval Curve fit interval in seconds
324327 * \param toe Time from ephemeris reference epoch
325328 * \param t The current GPS time. This is used to determine the ephemeris age
326329 * \return 1 if the ephemeris is valid and not too old.
327330 * 0 otherwise.
328331 */
329- u8 ephemeris_params_valid (const u8 valid , const u8 fit_interval ,
332+ u8 ephemeris_params_valid (const u8 valid , const u32 fit_interval ,
330333 const gps_time_t * toe , const gps_time_t * t )
331334{
332335 assert (t != NULL );
@@ -353,8 +356,8 @@ u8 ephemeris_params_valid(const u8 valid, const u8 fit_interval,
353356
354357 /* TODO: this doesn't exclude ephemerides older than a week so could be made
355358 * better. */
356- /* If dt is greater than fit_interval / 2 hours our ephemeris isn't valid. */
357- if (fabs (dt ) > ((u32 )fit_interval / 2 ) * 60 * 60 ) {
359+ /* If dt is greater than fit_interval / 2 seconds our ephemeris isn't valid. */
360+ if (fabs (dt ) > ((u32 )fit_interval / 2 )) {
358361 return 0 ;
359362 }
360363
@@ -415,10 +418,10 @@ float decode_ura_index(const u8 index) {
415418*
416419* \param fit_interval_flag The curve fit interval flag. 0 is 4 hours, 1 is >4 hours.
417420* \param iodc The IODC value.
418- * \return the curve fit interval in hours .
421+ * \return the curve fit interval in seconds .
419422*/
420- u8 decode_fit_interval (u8 fit_interval_flag , u16 iodc ) {
421- u8 fit_interval = 4 ;
423+ u32 decode_fit_interval (u8 fit_interval_flag , u16 iodc ) {
424+ u8 fit_interval = 4 ; /* This is in hours */
422425
423426 if (fit_interval_flag ) {
424427 fit_interval = 6 ;
@@ -438,7 +441,7 @@ u8 decode_fit_interval(u8 fit_interval_flag, u16 iodc) {
438441 }
439442 }
440443
441- return fit_interval ;
444+ return fit_interval * 60 * 60 ;
442445}
443446
444447/** Decode ephemeris from L1 C/A GPS navigation message frames.
0 commit comments