Package-level declarations

Types

Link copied to clipboard

Reads the TYPE_ACCELEROMETER sensor (x/y/z acceleration in m/s2). No permissions. With duration_ms (1-5000) it collects a series of samples; otherwise it captures a single reading. See readSensor for the sampling/timeout mechanics. Output: latest x, y, z, accuracy, timestamp, plus a readings list of {x,y,z,timestamp}. Returns ToolResult.error when the device has no accelerometer.

Link copied to clipboard
class GetGyroscopeTool(context: Context) : McpTool

Reads the TYPE_GYROSCOPE sensor (x/y/z angular rate in rad/s). No permissions. With duration_ms (1-5000) it collects a series of samples; otherwise a single reading. See readSensor. Output: latest x, y, z, accuracy, timestamp, plus a readings list of {x,y,z,timestamp}. Returns ToolResult.error when the device has no gyroscope.

Link copied to clipboard

Reads the TYPE_LIGHT ambient-light sensor (illuminance in lux). No permissions. With duration_ms (1-5000) it collects a series of samples; otherwise a single reading. See readSensor. Output: latest lux, accuracy, timestamp, plus a readings list of {lux,timestamp}. Returns ToolResult.error when the device has no light sensor.

Link copied to clipboard
class GetProximityTool(context: Context) : McpTool

Reads the TYPE_PROXIMITY sensor. No permissions. Many devices report only binary near/far rather than a true centimetre distance. With duration_ms (1-5000) it collects a series of samples; otherwise a single reading. See readSensor. Output: latest distance_cm, is_near (distance < 5cm), accuracy, timestamp, plus a readings list of {distance_cm,is_near,timestamp}. Returns ToolResult.error when the device has no proximity sensor.

Link copied to clipboard
data class SensorReading(val values: FloatArray, val accuracy: Int, val timestamp: Long)

A single sensor sample captured by readSensor.

Link copied to clipboard

Provider for the motion/environment sensor tools (accelerometer, gyroscope, light, proximity). None of these require any permission.

Functions

Link copied to clipboard
suspend fun readSensor(context: Context, sensorType: Int, durationMs: Int? = null): List<SensorReading>?

Registers a one-shot listener on the default sensor of sensorType and collects readings.