// @file sns_threshold.proto
//
// Defines standard message types for the Threshold Algorithm
//
// Copyright (c) 2018-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
syntax = "proto2";
import "nanopb.proto";
import "sns_std.proto";
import "sns_std_sensor.proto";
import "sns_resampler.proto";

// Threshold Sensor Attribute Requirements:
// SNS_STD_SENSOR_ATTRID_TYPE: "threshold"
// SNS_STD_SENSOR_ATTRID_STREAM_TYPE: SNS_STD_SENSOR_STREAM_TYPE_STREAMING

// Sensor output event:
// Threshold uses sns_std_sensor_event for it's output event.
// An event is generated by the threshold algorithm only if the threshold is met
// on any of the axis for the sensor.
// Thresholding can be done as value based delta between current value and
// the last generated output. Or thresholding can be done as the delta between
// current value and the last output, as a percentage of the last output.
// Thresholding can also be done based on the current value going beyond a particular
// absolute threshold value.
// When thresholding criteria is met , an event is generated by the algorithm.

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

  SNS_THRESHOLD_MSGID_SNS_THRESHOLD_CONFIG = 512;
}

//Thresholding types
enum sns_threshold_type
{
  option (nanopb_enumopt).long_names = false;

  // Provide thresholding as a delta between current value
  // and last reported value, exceeding above the configured threshold.
  SNS_THRESHOLD_TYPE_RELATIVE_VALUE = 0;

  // Provide thresholding as a delta between current value
  // and last reported value, compared as a percentage of the last reported value,
  // where the percentage is the configured threshold.
  SNS_THRESHOLD_TYPE_RELATIVE_PERCENT = 1;

  // Provides thresholding of the current value against a fixed configured
  // threshold value.
  SNS_THRESHOLD_TYPE_ABSOLUTE = 2;

  // Provides thresholding of angle between current and last reported quaternion
  // for quaternion sensors, in radians
  SNS_THRESHOLD_TYPE_ANGLE = 3;
}

// Configuration Message
// Used to either request for a new configuration of the threshold Sensor or
// alter an already existing configuration or query the current configuration.
message sns_threshold_config
{
  // UID of the sensor from which data is being requested from.
  required sns_std_suid sensor_uid = 1;

  // The threshold value per axis.
  // The number of threshold values need to be less than or equal to the number of
  // sensor data axes.
  // For SNS_THRESHOLD_TYPE_ANGLE, a single threshold_val value representing the
  // angle between current and last reported quaternions
  repeated float threshold_val = 2;

  // Tells us how to use the thresholding value provided.
  required  sns_threshold_type  threshold_type = 3;

  // The message id to be used to configure the underlying sensor.
  // This is used together with the below payload field.
  required uint32 payload_cfg_msg_id = 4;

  // Dynamic length payload, containing the actual data/configuration request
  // This payload will need to be decoded separately, using the Sensor-specific
  // header file.
  required bytes payload = 5;
}

// Config is used to inform the client of the configuration that was set,
// after a configuration is done .
// The config message is sent back to the client
// in the threshold config message.
// All data events are generated as sns_std_sensor_event.
