Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 300f6ae

Browse files
committed
MINOR: #define EPHEMERIS_VALID_TIME instead of 4 hour magic number
1 parent 89c27d9 commit 300f6ae

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ephemeris.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include "constants.h"
2121
#include "ephemeris.h"
2222

23+
#define EPHEMERIS_VALID_TIME (4*60*60) /* seconds +/- from epoch.
24+
TODO: should be 2 hrs? */
25+
2326
/** Calculate satellite position, velocity and clock offset from ephemeris.
2427
*
2528
* References:
@@ -59,8 +62,8 @@ s8 calc_sat_state(const ephemeris_t *ephemeris, gps_time_t t,
5962
dt = gpsdifftime(t, ephemeris->toe);
6063

6164
/* If dt is greater than 4 hours our ephemeris isn't valid. */
62-
if (fabs(dt) > 4*3600) {
63-
log_warn("Using ephemeris older (or newer!) than 4 hours.\n");
65+
if (fabs(dt) > EPHEMERIS_VALID_TIME) {
66+
log_error("Using ephemeris outside validity period, dt = %+.0f\n", dt);
6467
return -1;
6568
}
6669

@@ -168,7 +171,7 @@ u8 ephemeris_good(ephemeris_t *eph, gps_time_t t)
168171

169172
/* TODO: this doesn't exclude ephemerides older than a week so could be made
170173
* better. */
171-
return (eph->valid && eph->healthy && fabs(dt) < 4*3600);
174+
return (eph->valid && eph->healthy && fabs(dt) < EPHEMERIS_VALID_TIME);
172175
}
173176

174177
/** Decode ephemeris from L1 C/A GPS navigation message frames.

0 commit comments

Comments
 (0)