blob: 2359fd19fe353a5078da7c0155a245153e023331 [file] [log] [blame] [edit]
// Copyright 2023 The Fuchsia Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@available(added=HEAD)
library fuchsia.sensors;
using fuchsia.sensors.types as types;
using fuchsia.hardware.sensors as playback_types;
/// Errors that may be returned by Manager::Activate.
type ActivateSensorError = flexible enum : uint32 {
/// The SensorManager failed to get a response from the backing driver.
DRIVER_UNAVAILABLE = 1;
/// The provided SensorId does not correspond to an actual sensor.
INVALID_SENSOR_ID = 2;
};
/// Errors that may be returned by Manager::Deactivate.
type DeactivateSensorError = flexible enum : uint32 {
/// The SensorManager failed to get a response from the backing driver.
DRIVER_UNAVAILABLE = 1;
/// The provided SensorId does not correspond to an actual sensor.
INVALID_SENSOR_ID = 2;
};
/// Errors that may be returned by Manager::ConfigureSensorRate.
type ConfigureSensorRateError = flexible enum : uint32 {
/// The SensorManager failed to get a response from the backing driver.
DRIVER_UNAVAILABLE = 1;
/// The provided sensor SensorId does not correspond to an actual sensor.
INVALID_SENSOR_ID = 2;
/// The rate configuration was missing fields or contained an unsupported
/// sample rate and/or maximum reporting latency.
INVALID_CONFIG = 3;
};
/// Errors that may be returned by ConfigurePlayback.
type ConfigurePlaybackError = flexible enum : uint32 {
/// The Playback component was unavailable in this configuration of Fuchsia.
PLAYBACK_UNAVAILABLE = 1;
/// The type of the PlaybackSourceConfig union isn't recognized/supported.
INVALID_CONFIG_TYPE = 2;
/// Some part of the provided playback config is missing fields.
CONFIG_MISSING_FIELDS = 3;
/// A provided SensorInfo has a duplicate SensorId.
DUPLICATE_SENSOR_INFO = 4;
/// No SensorEvents were given for a provided SensorInfo.
NO_EVENTS_FOR_SENSOR = 5;
/// A SensorEvent was seen with a SensorId for which no SensorInfo was
/// provided.
EVENT_FROM_UNKNOWN_SENSOR = 6;
/// A SensorEvent was seen with a SensorType that does not match the
/// corresponding SensorInfo.
EVENT_SENSOR_TYPE_MISMATCH = 7;
/// A SensorEvent was seen with an EventPayload that doesn't match its
/// SensorType.
EVENT_PAYLOAD_TYPE_MISMATCH = 8;
/// The specified data file could not be opened.
FILE_OPEN_FAILED = 9;
/// The data in the specified file was not in the expected format.
///
/// NOTE: Some file types may allow for situations where the file is not
/// fully read by the time configuration is complete. For example a call to
/// ConfigurePlayback may only result in a file's header being read and
/// parsed. Thus ConfigurePlayback not returning this error is not always a
/// guarantee that the whole file contains valid data.
FILE_PARSE_ERROR = 10;
};
@discoverable
open protocol Manager {
/// On Fuchsia configurations with sensor data playback enabled, the Playback protocol should
/// be accessed through this protocol. If the Playback protocol is unavailable on a given
/// Fuchsia configuration, this method will always return PLAYBACK_UNAVAILABLE.
ConfigurePlayback(struct {
source_config playback_types.PlaybackSourceConfig;
}) -> () error ConfigurePlaybackError;
/// Returns the list of sensors managed by the SensorManager.
flexible GetSensorsList() -> (struct {
sensors vector<types.SensorInfo>:MAX;
});
/// Configures the sampling period and reporting latency for a particular sensor.
flexible ConfigureSensorRates(resource struct {
id types.SensorId;
sensor_rate_config types.SensorRateConfig;
}) -> () error ConfigureSensorRateError;
/// Activates a sensor. Events will begin to appear in the stream of sensor events.
flexible Activate(struct {
id types.SensorId;
}) -> () error ActivateSensorError;
/// Deactivates a sensor. Events will no longer appear in the stream of sensor events.
flexible Deactivate(struct {
id types.SensorId;
}) -> () error DeactivateSensorError;
/// The stream of sensor events from all sensors that have been activated.
-> OnSensorEvent(struct {
event types.SensorEvent;
});
};