/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.gnss@1.0;

@export(name="", value_prefix="GNSS_MAX_")
enum GnssMax : uint32_t {
/** Maximum number of SVs for gnssSvStatusCb(). */
    SVS_COUNT = 64,
};

/** Milliseconds since January 1, 1970 */
typedef int64_t GnssUtcTime;

/**
 * Constellation type of GnssSvInfo
 */

@export(name="", value_prefix="GNSS_CONSTELLATION_")
enum GnssConstellationType : uint8_t {
    UNKNOWN = 0,
    GPS     = 1,
    SBAS    = 2,
    GLONASS = 3,
    QZSS    = 4,
    BEIDOU  = 5,
    GALILEO = 6,
};

/** Bit mask to indicate which values are valid in a GnssLocation object. */
@export(name="", value_prefix="GPS_LOCATION_")
enum GnssLocationFlags : uint16_t {
    /** GnssLocation has valid latitude and longitude. */
    HAS_LAT_LONG              = 0x0001,
    /** GnssLocation has valid altitude. */
    HAS_ALTITUDE              = 0x0002,
    /** GnssLocation has valid speed. */
    HAS_SPEED                 = 0x0004,
    /** GnssLocation has valid bearing. */
    HAS_BEARING               = 0x0008,
    /** GpsLocation has valid horizontal accuracy. */
    HAS_HORIZONTAL_ACCURACY   = 0x0010,
    /** GpsLocation has valid vertical accuracy. */
    HAS_VERTICAL_ACCURACY     = 0x0020,
    /** GpsLocation has valid speed accuracy. */
    HAS_SPEED_ACCURACY        = 0x0040,
    /** GpsLocation has valid bearing accuracy. */
    HAS_BEARING_ACCURACY      = 0x0080
};

/** Represents a location. */
struct GnssLocation {
    /** Contains GnssLocationFlags bits. */
    bitfield<GnssLocationFlags> gnssLocationFlags;

    /** Represents latitude in degrees. */
    double latitudeDegrees;

    /** Represents longitude in degrees. */
    double longitudeDegrees;

    /**
     * Represents altitude in meters above the WGS 84 reference ellipsoid.
     */
    double altitudeMeters;

    /** Represents speed in meters per second. */
    float speedMetersPerSec;

    /** Represents heading in degrees. */
    float bearingDegrees;

    /**
    * Represents expected horizontal position accuracy, radial, in meters
    * (68% confidence).
    */
    float horizontalAccuracyMeters;

    /**
    * Represents expected vertical position accuracy in meters
    * (68% confidence).
    */
    float verticalAccuracyMeters;

    /**
    * Represents expected speed accuracy in meter per seconds
    * (68% confidence).
    */
    float speedAccuracyMetersPerSecond;

    /**
    * Represents expected bearing accuracy in degrees
    * (68% confidence).
    */
    float bearingAccuracyDegrees;

    /** Timestamp for the location fix. */
    GnssUtcTime timestamp;
};
