# Copyright (C) 2015 Swift Navigation Inc.
# Contact: Fergus Noble <fergus@swiftnav.com>
#
# 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.system
description: Standardized system messages from Swift Navigation devices.
stable: True
public: True
include:
  - types.yaml
definitions:

 - MSG_STARTUP:
    id: 0xFF00
    short_desc: System start-up message
    desc: |
        The system start-up message is sent once on system
        start-up. It notifies the host or other attached devices that
        the system has started and is now ready to respond to commands
        or configuration requests.
    fields:
        - cause:
            type: u8
            desc: Cause of startup
            fields:
              - 0-8:
                  desc: Cause of startup
                  values:
                    - 0: Power on
                    - 1: Software reset
                    - 2: Watchdog reset
        - startup_type:
            type: u8
            desc: Startup type
            fields:
              - 0-8:
                  values:
                    - 0: Cold start
                    - 1: Warm start
                    - 2: Hot start

        - reserved:
            type: u16
            desc: Reserved

 - MSG_DGNSS_STATUS:
    id: 0xFF02
    short_desc: Status of received corrections
    desc: |
        This message provides information about the receipt of Differential
        corrections.  It is expected to be sent with each receipt of a complete
        corrections packet.
    fields:
        - flags:
            type: u8
            desc: Status flags
            fields:
              - 4-7:
                  desc: Reserved
              - 0-3:
                  desc: Differential type
                  values:
                      - 0: Invalid
                      - 1: Code Difference
                      - 2: RTK
        - latency:
            type: u16
            units: deci-seconds
            desc: Latency of observation receipt
        - num_signals:
            type: u8
            desc: Number of signals from base station
        - source:
            type: string
            desc: Corrections source string


 - MSG_HEARTBEAT:
    id: 0xFFFF
    short_desc: System heartbeat message
    desc: |
        The heartbeat message is sent periodically to inform the host
        or other attached devices that the system is running. It is
        used to monitor system malfunctions. It also contains status
        flags that indicate to the host the status of the system and
        whether it is operating correctly. Currently, the expected
        heartbeat interval is 1 sec.

        The system error flag is used to indicate that an error has
        occurred in the system. To determine the source of the error,
        the remaining error flags should be inspected.
    fields:
        - flags:
            type: u32
            desc: Status flags
            fields:
              - 31:
                  desc: External antenna present
                  values:
                      - 0: No external antenna detected
                      - 1: External antenna is present
              - 24-30:
                  desc: Reserved
              - 16-23:
                  desc: SBP major protocol version number
              - 8-15:
                  desc: SBP minor protocol version number
              - 3-7:
                  desc: Reserved
              - 2:
                  desc: SwiftNAP Error
                  values:
                      - 0: System Healthy
                      - 1: An error has occurred in the SwiftNAP
              - 1:
                  desc: IO Error
                  values:
                      - 0: System Healthy
                      - 1: An IO error has occurred
              - 0:
                  desc: System Error Flag
                  values:
                      - 0: System Healthy
                      - 1: An error has occurred
