Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3d92783 authored by gomo's avatar gomo
Browse files

GNSS O Features according to go/o-gps-hal

Added "Tow Known" as a possible gnss measurement state. As well added Automatic Gain Control (AGC)
to allow jammer detection. Also added the GNSS carrier frequeny to SV status. Also adedd vertical
GPS position uncertainty, speed uncertainty and bearing uncertainty. Also propagate locaton new
fields to geofence engine.
Test: Existing unit tests still pass.

Change-Id: I26784a17e82c044002395e1929f8862cc9de63cb
parent ef578757
Loading
Loading
Loading
Loading
+25 −13
Original line number Diff line number Diff line
@@ -40,10 +40,10 @@ interface IGnssCallback {
        ON_DEMAND_TIME                  = 1 << 4,
        /** GNSS supports Geofencing  */
        GEOFENCING                      = 1 << 5,
        /** GNSS supports Measurements. */
        /** GNSS supports Measurements for at least GPS. */
        MEASUREMENTS                    = 1 << 6,
        /** GNSS supports Navigation Messages */
        NAV_MESSAGES   = 1 << 7,
        NAV_MESSAGES                    = 1 << 7
    };

    /* GNSS status event values. */
@@ -67,7 +67,8 @@ interface IGnssCallback {
        NONE                  = 0,
        HAS_EPHEMERIS_DATA    = 1 << 0,
        HAS_ALMANAC_DATA      = 1 << 1,
        USED_IN_FIX         = 1 << 2
        USED_IN_FIX           = 1 << 2,
        HAS_CARRIER_FREQUENCY = 1 << 3
    };

    struct GnssSvInfo {
@@ -108,6 +109,17 @@ interface IGnssCallback {
        /** Azimuth of SV in degrees. */
        float azimuthDegrees;

        /*
         * Carrier frequency of the signal tracked, for example it can be the
         * GPS L1 = 1.57542e9 Hz, or L2, L5, varying GLO channels, etc. If
         * the field is not set, it is the primary common use frequency,
         * e.g. L1 for GPS.
         *
         * If the data is available, gnssClockFlags must contain
         * HAS_CARRIER_FREQUENCY.
         */
        float carrierFrequencyHz;

        /*
         * Contains additional data about the given SV.
         */
+19 −2
Original line number Diff line number Diff line
@@ -45,11 +45,28 @@ interface IGnssDebug {
        double longitudeDegrees;
        /* Altitude above ellipsoid expressed in meters */
        float altitudeMeters;
        /* Represents speed in meters per second. */
        float speedMetersPerSec;
        /* Represents heading in degrees. */
        float bearingDegrees;
        /*
         * estimated horizontal accuracy of position expressed in meters, radial,
         * 68% confidence.
         */
        double accuracyMeters;
        double horizontalAccuracyMeters;
        /*
         * estimated vertical accuracy of position expressed in meters, with
         * 68% confidence.
         */
        double verticalAccuracyMeters;
        /*
         * estimated speed accuracy in meters per second with 68% confidence.
         */
        double speedAccuracyMetersPerSecond;
        /*
         * estimated bearing accuracy degrees with 68% confidence.
         */
        double bearingAccuracyDegrees;
        /*
         * Time duration before this report that this position information was
         * valid.
@@ -103,7 +120,7 @@ interface IGnssDebug {
        TimeDebug time;
        /*
         * Provides a list of the decoded satellite ephemeris.
         * Should provide a complete list for all constellations device can track,
         * Must provide a complete list for all constellations device can track,
         * including GnssConstellationType UNKNOWN.
         */
        vec<SatelliteData> satelliteDataArray;
+65 −22
Original line number Diff line number Diff line
@@ -51,7 +51,9 @@ interface IGnssMeasurementCallback {
        /** A valid 'carrier phase' is stored in the data structure. */
        HAS_CARRIER_PHASE              = 1 << 11,
        /** A valid 'carrier phase uncertainty' is stored in the data structure. */
        HAS_CARRIER_PHASE_UNCERTAINTY  = 1 << 12
        HAS_CARRIER_PHASE_UNCERTAINTY  = 1 << 12,
        /** A valid automatic gain control is stored in the data structure. */
        HAS_AUTOMATIC_GAIN_CONTROL     = 1 << 13
    };

    /*
@@ -95,7 +97,9 @@ interface IGnssMeasurementCallback {
        STATE_GAL_E1BC_CODE_LOCK     = 1 << 10,
        STATE_GAL_E1C_2ND_CODE_LOCK  = 1 << 11,
        STATE_GAL_E1B_PAGE_SYNC      = 1 << 12,
        STATE_SBAS_SYNC              = 1 << 13
        STATE_SBAS_SYNC              = 1 << 13,
        STATE_TOW_KNOWN              = 1 << 14,
        STATE_GLO_TOD_KNOWN          = 1 << 15,
    };

    /*
@@ -321,6 +325,11 @@ interface IGnssMeasurementCallback {
         * Bit sync        : [ 0 20ms  ] : STATE_BIT_SYNC set
         * Subframe sync   : [ 0  6s   ] : STATE_SUBFRAME_SYNC set
         * TOW decoded     : [ 0 1week ] : STATE_TOW_DECODED set
         * TOW Known       : [ 0 1week ] : STATE_TOW_KNOWN set
         *
         * Note: TOW Known refers to the case where TOW is possibly not decoded
         * over the air but has been determined from other sources. If TOW
         * decoded is set then TOW Known must also be set.
         *
         * Note: If there is any ambiguity in integer millisecond,
         * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS must be set accordingly, in the
@@ -338,7 +347,12 @@ interface IGnssMeasurementCallback {
         * Symbol sync         : [ 0  10ms ] : STATE_SYMBOL_SYNC set
         * Bit sync            : [ 0  20ms ] : STATE_BIT_SYNC set
         * String sync         : [ 0    2s ] : STATE_GLO_STRING_SYNC set
         * Time of day     : [ 0  1day ] : STATE_GLO_TOW_DECODED set
         * Time of day decoded : [ 0  1day ] : STATE_GLO_TOD_DECODED set
         * Time of day known   : [ 0  1day ] : STATE_GLO_TOD_KNOWN set
         *
         * Note: Time of day known refers to the case where it is possibly not
         * decoded over the air but has been determined from other sources. If
         * Time of day decoded is set then Time of day known must also be set.
         *
         * For Beidou, this is the received Beidou time of week,
         * at the measurement time in nanoseconds.
@@ -351,7 +365,12 @@ interface IGnssMeasurementCallback {
         * Bit sync (D1)        : [ 0  20ms ] : STATE_BIT_SYNC set.
         * Subframe (D2)        : [ 0  0.6s ] : STATE_BDS_D2_SUBFRAME_SYNC set.
         * Subframe (D1)        : [ 0    6s ] : STATE_SUBFRAME_SYNC set.
         * Time of week : [ 0 1week ] : STATE_TOW_DECODED set.
         * Time of week decoded : [ 0 1week ] : STATE_TOW_DECODED set.
         * Time of week known   : [ 0 1week ] : STATE_TOW_KNOWN set
         *
         * Note: TOW Known refers to the case where TOW is possibly not decoded
         * over the air but has been determined from other sources. If TOW
         * decoded is set then TOW Known must also be set.
         *
         * For Galileo, this is the received Galileo time of week,
         * at the measurement time in nanoseconds.
@@ -359,7 +378,12 @@ interface IGnssMeasurementCallback {
         * E1BC code lock       : [ 0  4ms ] : STATE_GAL_E1BC_CODE_LOCK set.
         * E1C 2nd code lock    : [ 0 100ms] : STATE_GAL_E1C_2ND_CODE_LOCK set.
         * E1B page             : [ 0   2s ] : STATE_GAL_E1B_PAGE_SYNC set.
         * Time of week     : [ 0 1week] : STATE_TOW_DECODED is set.
         * Time of week decoded : [ 0 1week] : STATE_TOW_DECODED is set.
         * Time of week known   : [ 0 1week] : STATE_TOW_KNOWN set
         *
         * Note: TOW Known refers to the case where TOW is possibly not decoded
         * over the air but has been determined from other sources. If TOW
         * decoded is set then TOW Known must also be set.
         *
         * For SBAS, this is received SBAS time, at the measurement time in
         * nanoseconds.
@@ -455,9 +479,10 @@ interface IGnssMeasurementCallback {
        double accumulatedDeltaRangeUncertaintyM;

        /*
         * Carrier frequency at which codes and messages are modulated, it can
         * be L1 or L2. If the field is not set, the carrier frequency is
         * assumed to be L1.
         * Carrier frequency of the signal tracked, for example it can be the
         * GPS L1 = 1.57542e9 Hz, or L2, L5, varying GLO channels, etc. If the
         * field is not set, it is the primary common use frequency,
         * e.g. L1 for GPS.
         *
         * If the data is available, gnssClockFlags must contain
         * HAS_CARRIER_FREQUENCY.
@@ -524,6 +549,24 @@ interface IGnssMeasurementCallback {
         * observed noise floor" to "the noise RMS".
         */
        double snrDb;

        /*
         * Automatic gain control (AGC) level. AGC acts as a variable gain
         * amplifier adjusting the power of the incoming signal to minimize the
         * quantization losses. The AGC level may be used to indicate potential
         * interference. When AGC is at a nominal level, this value
         * must be set as 0. Higher gain (and/or lower input power) must be
         * output as a positive number. Hence in cases of strong jamming, in the
         * band of this signal, this value must go more negative.
         *
         * Note: Different hardware designs (e.g. antenna, pre-amplification, or
         * other RF HW components) may also affect the typical output of of this
         * value on any given hardware design in an open sky test - the
         * important aspect of this output is that changes in this value are
         * indicative of changes on input signal power in the frequency band for
         * this measurement.
         */
        double agcLevelDb;
    };

    /*
+4 −1
Original line number Diff line number Diff line
@@ -121,7 +121,10 @@ void Gnss::gnssSvStatusCb(GnssSvStatus* status) {
            .cN0Dbhz = svInfo.c_n0_dbhz,
            .elevationDegrees = svInfo.elevation,
            .azimuthDegrees = svInfo.azimuth,
            .svFlag = svInfo.flags
            .svFlag = svInfo.flags,
            // Older chipsets do not provide carrier frequency, hence HAS_CARRIER_FREQUENCY flag
            // is not set and the carrierFrequencyHz field is set to zero
            .carrierFrequencyHz = 0
        };
        svStatus.gnssSvList[i] = gnssSvInfo;
    }
+8 −1
Original line number Diff line number Diff line
@@ -51,12 +51,19 @@ void GnssMeasurement::gnssMeasurementCb(LegacyGnssData* legacyGnssData) {

    for (size_t i = 0; i < gnssData.measurementCount; i++) {
        auto entry = legacyGnssData->measurements[i];
        auto state = static_cast<GnssMeasurementState>(entry.state);
        if (state & IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED) {
          state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_KNOWN;
        }
        if (state & IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED) {
          state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_KNOWN;
        }
        gnssData.measurements[i] = {
            .flags = entry.flags,
            .svid = entry.svid,
            .constellation = static_cast<GnssConstellationType>(entry.constellation),
            .timeOffsetNs = entry.time_offset_ns,
            .state = entry.state,
            .state = state,
            .receivedSvTimeInNs = entry.received_sv_time_in_ns,
            .receivedSvTimeUncertaintyInNs = entry.received_sv_time_uncertainty_in_ns,
            .cN0DbHz = entry.c_n0_dbhz,
Loading