
// @file sns_distance_bound.proto
//
// Defines message types for the Distance Bound (DB) Sensor.
//
// Copyright (c) 2017 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.

syntax = "proto2";
import "nanopb.proto";
import "sns_std_sensor.proto";

// Distance Bound (DB) algorithm tracks the distance covered in meters
// It expects, as part of its request, distance in meters. DB reports the client
// when this distance is covered from the instant the request was received.
// After a client sends a DB request for distance, it can query DB for
// distance accumulated at any instant before the final breach occurs

// DB Sensor Attribute Requirements:
// SNS_STD_SENSOR_ATTRID_TYPE: "distance_bound"
// SNS_STD_SENSOR_ATTRID_STREAM_TYPE: SNS_STD_SENSOR_STREAM_TYPE_SINGLE_OUTPUT

// Stream Requests:

// Message IDs for DB Sensor
enum sns_distance_bound_msgid {
  option (nanopb_enumopt).long_names = false;

  // Uses message: sns_set_distance_bound
  // Purpose:
  // A distance bound request from the client

  SNS_DISTANCE_BOUND_MSGID_SNS_SET_DISTANCE_BOUND = 516;

  // Uses message: None
  // Purpose:
  // client can query the distance accumulated at a given instance
  // before final breach occurs.
  // Note: This message should be preceeded by a
  // SNS_DISTANCE_BOUND_MSGID_SNS_SET_DISTANCE_BOUND request msg

  SNS_DISTANCE_BOUND_MSGID_SNS_GET_DISTANCE_ACCUMULATED = 517;

  // Uses message: sns_distance_bound_event
  // Purpose:
  // This event corresponds to request:
  // SNS_DISTANCE_BOUND_MSGID_SNS_SET_DISTANCE_BOUND
  // This event is raised  when the breach occurs.

  SNS_DISTANCE_BOUND_MSGID_SNS_DISTANCE_BOUND_EVENT = 772;


  // Uses message: sns_get_distance_accumulated_event
  // Purpose:
  // This event corresponds to request:
  // SNS_DISTANCE_BOUND_MSGID_SNS_GET_DISTANCE_ACCUMULATED
  // This event reports the distance accumulated at a given
  // instance when the request is received

  SNS_DISTANCE_BOUND_MSGID_SNS_GET_DISTANCE_ACCUMULATED_EVENT = 773;
}


// Gives the state which the algorithm is capable
// of detecting
enum sns_distance_bound_motion_state
{
  option (nanopb_enumopt).long_names = false;

  SNS_DB_MS_UNKNOWN     = 0;
  SNS_DB_MS_STATIONARY  = 1;
  SNS_DB_MS_MOVE        = 2;
  SNS_DB_MS_FIDDLE      = 3;
  SNS_DB_MS_PEDESTRIAN  = 4;
  SNS_DB_MS_VEHICLE     = 5;
  SNS_DB_MS_WALK        = 6;
  SNS_DB_MS_RUN         = 7;
  SNS_DB_MS_BIKE        = 8;
  SNS_DB_MS_MAX         = 9;
}

// Request message
// message associated with SNS_DISTANCE_BOUND_MSGID_SNS_SET_DISTANCE_BOUND
// This message will result in atmost one sns_distance_bound_event when
// the requested distance is covered
// If client resends a fresh sns_set_distance_bound before the older is serviced
// the older request will be lost and new distance will be calculated from that
// instant

message sns_set_distance_bound
{
  //  The distance bound in meters. When the distance travelled exceeds this,
  //  an event is sent to the requestor

  required float distance_bound = 1;

  //  speeds associated with different motion states.
  //  if client does not send any motion state speed,
  //  default values will be taken for that motion state

  message speeds {
    required sns_distance_bound_motion_state state = 1;
    required  float speed = 2;
  }

  repeated speeds speed_bound = 2;
}

// Event message
// message associated with SNS_DISTANCE_BOUND_MSGID_SNS_DISTANCE_BOUND_EVENT
// This event corresponds to request:
// SNS_DISTANCE_BOUND_MSGID_SNS_SET_DISTANCE_BOUND
// This event will be raised after the breach occurs.

message sns_distance_bound_event
{
  // Distance accumulated in meters since the last sns_set_distance_bound
  required float distance_accumulated = 1;
}

// Event message
// message associated with
// SNS_DISTANCE_BOUND_MSGID_SNS_GET_DISTANCE_ACCUMULATED_EVENT
// This event corresponds to request:
// SNS_DISTANCE_BOUND_MSGID_SNS_GET_DISTANCE_ACCUMULATED
// This event will be raised instantly upon receiveing the above request,
// reporting the distance accumulated till that instance.
// NOTE:
// In following situation an error event,
// SNS_STD_MSGID_SNS_STD_ERROR_EVENT, with payload sns_std_error_event, having
// appropriate error code, will be raised:
// 1. In absence of any prior SNS_DISTANCE_BOUND_MSGID_SNS_SET_DISTANCE_BOUND
//    error event with error code SNS_STD_ERROR_FAILED will be raised.
//
// 2. If a breach has already occurred for a prior
//    SNS_DISTANCE_BOUND_MSGID_SNS_SET_DISTANCE_BOUND request, error event
//    with error code  SNS_STD_ERROR_NOT_AVAILABLE will be raised.


message sns_get_distance_accumulated_event
{
  // Distance accumulated in meters since the last sns_set_distance_bound
  required float distance_accumulated = 1;
}

// DB does not publish configuration events.


