# Copyright (C) 2015-2021 Swift Navigation Inc.
# Contact: https://support.swiftnav.com
#
# This source is subject to the license found in the file 'LICENSE' which must
# be distributed together with this source. All other rights reserved.
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

package: swiftnav.sbp.gnss
description: Various structs shared between modules
stable: True
public: True
include:
  - types.yaml

definitions:

 - GnssSignal:
    short_desc: Represents all the relevant information about the signal
    desc: >
        Signal identifier containing constellation, band, and satellite identifier.
    fields:
        - sat:
            type: u8
            desc: >
                Constellation-specific satellite id. For GLO can
                either be (100+FCN) where FCN is in [-7,+6] or
                the Slot ID in [1,28].
        - code:
            type: u8
            desc: Signal constellation, band and code
            fields:
              - 0-7:
                  values:
                      - 0: GPS L1CA
                      - 1: GPS L2CM
                      - 2: SBAS L1CA
                      - 3: GLO L1CA
                      - 4: GLO L2CA
                      - 5: GPS L1P
                      - 6: GPS L2P
                      - 12: BDS2 B1
                      - 13: BDS2 B2
                      - 14: GAL E1B
                      - 20: GAL E7I
                      - 31: QZS L1CA
                      - 36: QZS L2CL
                      - 39: QZS L5Q
                      - 47: BDS3 B2a

 - SvId:
    short_desc: Space vehicle identifier
    desc: >
      A (Constellation ID, satellite ID) tuple that uniquely identifies
      a space vehicle.
    fields:
    - satId:
        type: u8
        desc: >
          Constellation-specific satellite id. For GLO can
          either be (100+FCN) where FCN is in [-7,+6] or
          the Slot ID in [1,28].
    - constellation:
        type: u8
        desc: Constellation ID to which the SV belongs
        fields:
          - 0-7:
              values:
                - 0: GPS
                - 3: BDS
                - 4: QZS
                - 5: GAL

 - GnssSignalDep:
    short_desc: Deprecated
    desc: Deprecated.
    fields:
        - sat:
            type: u16
            desc: >
              Constellation-specific satellite identifier.


              Note: unlike GnssSignal, GPS satellites are encoded as
              (PRN - 1). Other constellations do not have this offset.
        - code:
            type: u8
            desc: Signal constellation, band and code
            fields:
              - 0-7:
                  values:
                      - 0: GPS L1CA
                      - 1: GPS L2CM
                      - 2: SBAS L1CA
                      - 3: GLO L1CA
                      - 4: GLO L2CA
                      - 5: GPS L1P
                      - 6: GPS L2P
        - reserved:
            type: u8
            desc: Reserved

 - GPSTimeDep:
    short_desc: Millisecond-accurate GPS time
    desc: >
      A wire-appropriate GPS time, defined as the number of
      milliseconds since beginning of the week on the Saturday/Sunday
      transition.
    fields:
        - tow:
            type: u32
            units: ms
            desc: Milliseconds since start of GPS week
        - wn:
            type: u16
            units: week
            desc: GPS week number


 - GPSTimeSec:
    short_desc: Whole second accurate GPS time
    desc: >
      A GPS time, defined as the number of
      seconds since beginning of the week on the Saturday/Sunday
      transition.
    fields:
        - tow:
            type: u32
            units: s
            desc: Seconds since start of GPS week
        - wn:
            type: u16
            units: week
            desc: GPS week number

 - GPSTime:
    short_desc: Nanosecond-accurate receiver clock time
    desc: >
      A wire-appropriate receiver clock time, defined as the time
      since the beginning of the week on the Saturday/Sunday
      transition. In most cases, observations are epoch aligned
      so ns field will be 0.
    fields:
        - tow:
            type: u32
            units: ms
            desc: Milliseconds since start of GPS week
        - ns_residual:
            type: s32
            units: ns
            desc: >
              Nanosecond residual of millisecond-rounded TOW (ranges
              from -500000 to 500000)
        - wn:
            type: u16
            units: week
            desc: GPS week number

 - CarrierPhase:
      short_desc: GNSS carrier phase measurement
      desc: >
        Carrier phase measurement in cycles represented as a 40-bit
        fixed point number with Q32.8 layout, i.e. 32-bits of whole
        cycles and 8-bits of fractional cycles. This phase has the
        same sign as the pseudorange.
      fields:
          - i:
              type: s32
              units: cycles
              desc: Carrier phase whole cycles
          - f:
              type: u8
              units: cycles / 256
              desc: Carrier phase fractional part
