Eeprom files may be missing the GPS time (due to a firmware bug). Working
around this involves finding the next valid GPS time and using that to
create a fake GPS time entry. However, that next GPS time may not
be locked or may have few sats as it is from the boost stage of the
flight. Fix this by simply forcing the fake time packet to have
4 sats and be locked.
Signed-off-by: Keith Packard <keithp@keithp.com>
int flags = (good.b >> 8);
int seconds = hour * 3600 + minute * 60 + second;
int flags = (good.b >> 8);
int seconds = hour * 3600 + minute * 60 + second;
+ /* Make sure this looks like a good GPS value */
+ if ((flags & Altos.AO_GPS_NUM_SAT_MASK) >> Altos.AO_GPS_NUM_SAT_SHIFT < 4)
+ flags = (flags & ~Altos.AO_GPS_NUM_SAT_MASK) | (4 << Altos.AO_GPS_NUM_SAT_SHIFT);
+ flags |= Altos.AO_GPS_RUNNING;
+ flags |= Altos.AO_GPS_VALID;
+
int new_seconds = seconds + diff;
if (new_seconds < 0)
new_seconds += 24 * 3600;
int new_seconds = seconds + diff;
if (new_seconds < 0)
new_seconds += 24 * 3600;