// @file sns_registry.proto
//
// Sensors Registry message definitions for internal and external clients
//
// Copyright (c) 2017,2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
syntax = "proto2";
import "nanopb.proto";

// Registry Sensor Attribute Requirements:
// SNS_STD_SENSOR_ATTRID_TYPE: "registry"
// SNS_STD_SENSOR_ATTRID_STREAM_TYPE: SNS_STD_SENSOR_STREAM_TYPE_SINGLE_OUTPUT

// Registry Sensor message IDs:
enum sns_registry_msgid {
  option (nanopb_enumopt).long_names = false;

  SNS_REGISTRY_MSGID_SNS_REGISTRY_READ_REQ = 512;
  SNS_REGISTRY_MSGID_SNS_REGISTRY_WRITE_REQ = 513;
  // The following event was mistakenly given an invalid message ID
  SNS_REGISTRY_MSGID_SNS_REGISTRY_READ_EVENT = 514;
  SNS_REGISTRY_MSGID_SNS_REGISTRY_WRITE_EVENT = 768;
}

message sns_registry_data
{
  message item
  {
    option (nanopb_msgopt).no_unions = true;

    // Item name (i.e. Only item-specific name, sans group name)
    required string name = 1;
    optional fixed32 version = 2;

    oneof data
    {
      sns_registry_data subgroup = 10;
      string str = 11;
      float flt = 12;
      sfixed64 sint = 13;
    }
  }
  repeated item items = 3;
}

// All read requests will be replied with a read event
message sns_registry_read_req
{
  // Full name of the item or group to be read
  required string name = 1;
}

message sns_registry_read_event
{
  // Full name of the group which was read
  required string name = 1;

  // If the requested registry group was not found, data is empty
  required sns_registry_data data = 2;
}

// All write requests will be replied with a write event
message sns_registry_write_req
{
  // Full name of the group to be written
  required string name = 1;

  required sns_registry_data data = 2;
}

// Registry write status
enum sns_registry_write_status
{
  option (nanopb_enumopt).long_names = false;

  // The registry write was successful, and the data was stored on the FS
  SNS_REGISTRY_WRITE_STATUS_SUCCESS = 0;
  // An unspecified error has occurred; data may be lost
  SNS_REGISTRY_WRITE_STATUS_ERROR_OTHER = 1;
}

message sns_registry_write_event
{
  required sns_registry_write_status status = 1;
}
