# 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.settings
description: |
  Messages for reading and writing the device's device settings.

  Note that some of these messages share the same message type ID for both the
  host request and the device response. See the accompanying document for
  descriptions of settings configurations and examples:

  https://github.com/swift-nav/piksi\_firmware/blob/master/docs/settings.pdf
stable: True
public: True
include:
  - types.yaml
definitions:

 - MSG_SETTINGS_SAVE:
    id: 0x00A1
    short_desc: Save settings to flash (host => device)
    desc: |
      The save settings message persists the device's current settings
      configuration to its onboard flash memory file system.

 - MSG_SETTINGS_WRITE:
    id: 0x00A0
    short_desc: Write device configuration settings (host => device)
    desc: The setting message writes the device configuration.
    fields:
      - setting:
          type: string
          desc: |
            A NULL-terminated and delimited string with contents
            [SECTION_SETTING, SETTING, VALUE]. A device will only
            process to this message when it is received from sender ID
            0x42.

 - MSG_SETTINGS_READ_REQ:
    id: 0x00A4
    short_desc: Read device configuration settings (host => device)
    desc: The setting message reads the device configuration.
    fields:
      - setting:
          type: string
          desc: |
            A NULL-terminated and delimited string with contents
            [SECTION_SETTING, SETTING]. A device will only respond to
            this message when it is received from sender ID 0x42.

 - MSG_SETTINGS_READ_RESP:
    id: 0x00A5
    short_desc: Read device configuration settings (host <= device)
    desc: The setting message reads the device configuration.
    fields:
      - setting:
          type: string
          desc: |
            A NULL-terminated and delimited string with contents
            [SECTION_SETTING, SETTING, VALUE].

 - MSG_SETTINGS_READ_BY_INDEX_REQ:
    id: 0x00A2
    short_desc: Read setting by direct index (host => device)
    desc: |
      The settings message for iterating through the settings
      values. It will read the setting at an index, returning a
      NULL-terminated and delimited string with contents
      [SECTION_SETTING, SETTING, VALUE]. A device will only respond to
      this message when it is received from sender ID 0x42.
    fields:
      - index:
          type: u16
          desc: |
            An index into the device settings, with values ranging from
            0 to length(settings)

 - MSG_SETTINGS_READ_BY_INDEX_RESP:
    id: 0x00A7
    short_desc: Read setting by direct index (host <= device)
    desc: |
      The settings message for iterating through the settings
      values. It will read the setting at an index, returning a
      NULL-terminated and delimited string with contents
      [SECTION_SETTING, SETTING, VALUE].
    fields:
      - index:
          type: u16
          desc: |
            An index into the device settings, with values ranging from
            0 to length(settings)
      - setting:
          type: string
          desc: |
            A NULL-terminated and delimited string with contents
            [SECTION_SETTING, SETTING, VALUE].

 - MSG_SETTINGS_READ_BY_INDEX_DONE:
    id: 0x00A6
    short_desc: Finished reading settings (host <= device)
    desc: |
      The settings message for indicating end of the settings values.

 - MSG_SETTINGS_REGISTER:
    id: 0x00AE
    public: false
    short_desc: Register setting and default value (device => host)
    desc: |
      This message registers the presence and default value of a setting
      with a settings daemon.  The host should reply with MSG_SETTINGS_WRITE
      for this setting to set the initial value.
    fields:
      - setting:
          type: string
          desc: |
            A NULL-terminated and delimited string with contents
            [SECTION_SETTING, SETTING, VALUE].

