# Copyright (C) 2015 Swift Navigation Inc.
# Contact: Vlad Ungureanu <vvu@vdev.ro>
#
# This source is subject to the license found in the file 'LICENSE' which must
# be 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:

 - GnssSignal16:
    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 identifier
        - 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

 - GnssSignal:
    short_desc: Represents all the relevant information about the signal
    desc: |
        Signal identifier containing constellation, band, and satellite identifier
    fields:
        - sat:
            type: u16
            desc: |
                Constellation-specific satellite identifier.

                Note: unlike GnssSignal16, 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

 - GPSTime:
    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

 - GPSTimeNano:
    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
