rrlp-ephemeris: Add support for filling ReferenceTime IE

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
master
Sylvain Munaut 13 years ago committed by Harald Welte
parent 639889b05f
commit 14039dd324
  1. 9
      gps.h
  2. 9
      rrlp.c

@ -151,12 +151,20 @@ struct gps_ref_pos { /* WSG84 ellipsoid */
};
/* Reference time */
struct gps_ref_time {
int wn; /* GPS week number */
double tow; /* in seconds */
};
/* All assist data */
#define GPS_FIELD_IONOSPHERE (1<<0)
#define GPS_FIELD_UTC (1<<1)
#define GPS_FIELD_ALMANAC (1<<2)
#define GPS_FIELD_EPHEMERIS (1<<3)
#define GPS_FIELD_REFPOS (1<<4)
#define GPS_FIELD_REFTIME (1<<5)
struct gps_assist_data {
int fields;
@ -165,6 +173,7 @@ struct gps_assist_data {
struct gps_almanac almanac;
struct gps_ephemeris ephemeris;
struct gps_ref_pos ref_pos;
struct gps_ref_time ref_time;
};

@ -430,16 +430,17 @@ _rrlp_add_reference_time(
{
struct ReferenceTime *rrlp_reftime;
/* FIXME: Check if info is in gps_ad */
if (!(gps_ad->fields & GPS_FIELD_REFTIME))
return -EINVAL;
rrlp_reftime = calloc(1, sizeof(*rrlp_reftime));
if (!rrlp_reftime)
return -ENOMEM;
rrlp_gps_ad->controlHeader.referenceTime = rrlp_reftime;
/* FIXME */
// rrlp_reftime.gpsTime.gpsTOW23b = g_gps_tow / 80; /* 23 bits */
// rrlp_reftime.gpsTime.gpsWeek = g_gps_week & 0x3ff; /* 10 bits */
rrlp_reftime->gpsTime.gpsWeek = gps_ad->ref_time.wn & 0x3ff; /* 10b */
rrlp_reftime->gpsTime.gpsTOW23b =
((int)floor(gps_ad->ref_time.tow / 0.08)) & 0x7fffff; /* 23b */
return 0;
}

Loading…
Cancel
Save