// @file sns_offset_formatter.proto
//
// Defines standard message types for the Offset/Formatter sensor
//
// Copyright (c) 2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
syntax = "proto2";
import "nanopb.proto";
import "sns_std_type.proto";
import "sns_std_sensor.proto";

enum sns_formatter_msgid {
  option (nanopb_enumopt).long_names = false;

  SNS_FORMATTER_MSGID_SNS_FORMATTER_REQUEST                = 512;
  SNS_FORMATTER_MSGID_SNS_FORMATTER_METRIC_DATA_REQUEST    = 513;

  SNS_FORMATTER_MSGID_SNS_FORMATTER_OUTPUT_EVENT           = 1024;
  SNS_FORMATTER_MSGID_SNS_FORMATTER_ACK_EVENT              = 1025;
}

enum sns_formatter_request_values {
  option (nanopb_enumopt).long_names = false;

  SNS_FORMATTER_REQUEST_INVALID  = 0;
  // Creates a new instance of a metric with given id.
  SNS_FORMATTER_REQUEST_CREATE   = 1;
  // Starts or resumes the update of the metric instances.
  SNS_FORMATTER_REQUEST_START    = 2;
  // Pauses the update of the metric instances.
  SNS_FORMATTER_REQUEST_STOP     = 3;
  // Resets metric instance state.
  SNS_FORMATTER_REQUEST_RESET    = 4;
  // Destroys the metric instance. Release the resources for that instance.
  SNS_FORMATTER_REQUEST_DESTROY  = 5;
  // Set the config data based on the group name.
  SNS_FORMATTER_REQUEST_CONFIG_SET   = 6;
  // fetch the config data based on the group name.
  SNS_FORMATTER_REQUEST_CONFIG_GET   = 7;
  // Updates the batch period at the client manager.
  SNS_FORMATTER_REQUEST_BATCH        = 8;
}

enum sns_formatter_status_values {
  option (nanopb_enumopt).long_names = false;

  SNS_FORMATTER_STATUS_FAILURE        = 0;
  SNS_FORMATTER_STATUS_INVALID_PARAM  = 1;
  SNS_FORMATTER_STATUS_SUCCESS        = 2;
}

enum sns_formatter_client_id {
  option (nanopb_enumopt).long_names = false;

  SNS_FORMATTER_CLIENT_BG   = 0;
  SNS_FORMATTER_CLIENT_APPS = 1;
}

enum sns_formatter_event_type {
  option (nanopb_enumopt).long_names = false;

  SNS_FORMATTER_OUTPUT_DATA_EVENT     = 0;
  SNS_FORMATTER_OUTPUT_BUFFER_EVENT   = 1;
  SNS_FORMATTER_CONFIG_DATA_EVENT     = 2;
}

// "UNUSED" is filled by clients for strings which are
// not applicable for a given sns_formatter-request_values id.
message sns_formatter_config_payload {
  optional sns_std_suid            metric_sensor_suid = 1;
  required sns_std_suid            formatter_suid    = 2;
  required float                   sample_rate       = 3;
  required string                  format_input_str  = 4;
  required string                  metric_name       = 5;
  required string                  group_name        = 7;
  required string                  sensor_config_data = 8;
}

message sns_formatter_output_event_payload
{
  required bytes                        data       = 1;
  required sns_std_sensor_sample_status status     = 2;
  required sns_formatter_event_type     event_type = 3;
}

// Formatter config message
// Used by clients to configure the formatter for various metrics
message sns_formatter_request
{
  required sns_formatter_request_values msg_id                = 1;
  required fixed32                      metric_id             = 2;
  required sns_formatter_client_id client_id                  = 3;
  optional sns_formatter_config_payload payload               = 4;
  optional sns_formatter_output_event_payload  event_payload  = 5;
}

message sns_formatter_metric_data_request
{
  required fixed32     metric_id    = 1;
  required bytes       metric_data  = 2;
}

// Formatter output event
// This event contains the formatted string output corresponding to the
// metric requested by the client.
message sns_formatter_output_event
{
  required fixed32                      metric_id         = 1;
  required string                       formatted_output  = 2;
  required sns_formatter_output_event_payload  event_payload     = 3;
}

// Formatter acknowledge event
// This event contains the status for the request sent from the client.
// Status indicates if the requested format string was valid or not.
message sns_formatter_ack_event
{
  required fixed32                     metric_id  = 1;
  required sns_formatter_status_values status     = 2;
}