# Copyright (C) 2017-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.ndb
description: >
  Messages for logging NDB events.
stable: False
public: False
include:
  - types.yaml
  - gnss.yaml
definitions:
 - MSG_NDB_EVENT:
    id: 0x0400
    public: false
    short_desc: Navigation DataBase Event
    desc: >
      This message is sent out when an object is stored into NDB. If needed
      message could also be sent out when fetching an object from NDB.
    fields:
      - recv_time:
          type: u64
          units: ms
          desc: HW time in milliseconds.
      - event:
          type: u8
          desc: Event type.
          fields:
            - 2-7:
                desc: Reserved.
            - 0-1:
                desc: Event type.
                values:
                    - 0: UNKNOWN
                    - 1: STORE
                    - 2: FETCH
                    - 3: ERASE
      - object_type:
          type: u8
          desc: Event object type.
          fields:
            - 3-7:
                desc: Reserved.
            - 0-2:
                desc: Event object type.
                values:
                    - 0: UNKNOWN
                    - 1: EPHEMERIS
                    - 2: ALMANAC
                    - 3: ALMANAC_WN
                    - 4: IONO
                    - 5: L2C_CAP
                    - 6: LGF
      - result:
          type: u8
          desc: Event result.
          fields:
            - 4-7:
                desc: Reserved.
            - 0-3:
                desc: Event result.
                values:
                    - 0: NDB_ERR_NONE
                    - 1: NDB_ERR_MISSING_IE
                    - 2: NDB_ERR_UNSUPPORTED
                    - 3: NDB_ERR_FILE_IO
                    - 4: NDB_ERR_INIT_DONE
                    - 5: NDB_ERR_BAD_PARAM
                    - 6: NDB_ERR_UNRELIABLE_DATA
                    - 7: NDB_ERR_ALGORITHM_ERROR
                    - 8: NDB_ERR_NO_DATA
                    - 9: NDB_ERR_NO_CHANGE
                    - 10: NDB_ERR_OLDER_DATA
      - data_source:
           type: u8
           desc: Data source for STORE event, reserved for other events.
           fields:
            - 2-7:
                desc: Reserved.
            - 0-1:
                desc: Data source.
                values:
                    - 0: NDB_DS_UNDEFINED
                    - 1: NDB_DS_INIT
                    - 2: NDB_DS_RECEIVER
                    - 3: NDB_DS_SBP
      - object_sid:
           type: GnssSignal
           desc: >
             GNSS signal identifier,
             If object_type is Ephemeris OR Almanac, sid indicates for which
             signal the object belongs to. Reserved in other cases.
      - src_sid:
           type: GnssSignal
           desc: >
             GNSS signal identifier,
             If object_type is Almanac, Almanac WN, Iono OR L2C capabilities
             AND data_source is NDB_DS_RECEIVER sid indicates from which SV
             data was decoded. Reserved in other cases.
      - original_sender:
           type: u16
           desc: >
             A unique identifier of the sending hardware. For v1.0,
             set to the 2 least significant bytes of the device serial
             number, valid only if data_source is NDB_DS_SBP. Reserved in case
             of other data_source.
