// @file sns_physical_sensor_test.proto
//
// Defines test API message types for physical sensors.
//
// All physical Sensor drivers are required to use this API to support
// self-test. SNS_PHYSICAL_SENSOR_TEST_TYPE_COM is a mandatory test type and must be
// implemented in all physical Sensor drivers. Any new or device-specific
// test type may be defined in the Sensor-specific API.
//
// Copyright (c) 2016-2017 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.

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

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

  // Test config request to a physical Sensor
  SNS_PHYSICAL_SENSOR_TEST_MSGID_SNS_PHYSICAL_SENSOR_TEST_CONFIG = 515;

  // Test event message from a physical Sensor
  SNS_PHYSICAL_SENSOR_TEST_MSGID_SNS_PHYSICAL_SENSOR_TEST_EVENT  = 1026;
}

// Supported test types for physical sensors
enum sns_physical_sensor_test_type
{
  option (nanopb_enumopt).long_names = false;

  // Software test.
  SNS_PHYSICAL_SENSOR_TEST_TYPE_SW = 0;

  // Sensor Hardware test.
  SNS_PHYSICAL_SENSOR_TEST_TYPE_HW = 1;

  // Factory test used for Sensor calibration.
  SNS_PHYSICAL_SENSOR_TEST_TYPE_FACTORY = 2;

  // Communication bus test.
  SNS_PHYSICAL_SENSOR_TEST_TYPE_COM = 3;
}

// Physical Sensor test configuration request
message sns_physical_sensor_test_config
{
  // Requested test type.
  required sns_physical_sensor_test_type test_type = 1;
}

// Physical Sensor test event
message sns_physical_sensor_test_event
{
  // Result if the test execution was successful:
  // true for success
  // false for failure
  required bool test_passed = 1 [default = true];

  // test_type from sns_physical_sensor_test_config that
  // this event corresponds to
  required sns_physical_sensor_test_type test_type = 2 [default = SNS_PHYSICAL_SENSOR_TEST_TYPE_COM];

  // Driver specific test data. This field can be used
  // to pass additional information like failure codes, debug data, etc.
  optional bytes test_data = 3;
}

// Self-test and streaming concurrency requirements:
// 1. If the sensor is streaming and there is a client request to run
//    self-test (any test type) then the driver:
//      a. Pauses the stream
//      b. Executes the self-test request to completion
//      c. Resumes stream
// 2. If the self-test is running and there is a client request to start
//    a sensor stream then the driver:
//      a. Rejects the stream request
//      b. Continues executing the self-test request to completion

