1e41f4b71Sopenharmony_ci# Service Overview 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Introduction 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThe pan-sensor service subsystem provides a lightweight sensor service framework. You can call APIs offered by this framework to query the sensor list, enable or disable a sensor, and subscribe to or unsubscribe from sensor data. The following figure shows the architecture of the lightweight sensor framework. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci **Figure 1** Sensor service framework 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci  11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci- Sensor API: provides APIs for performing basic operations on sensors, including querying the sensor list, subscribing to or unsubscribing from sensor data, and executing control commands. This module makes application development simpler. 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci- Sensor Framework: manages sensor data subscription, creates and destroys data channels, and implements communication with the Sensor Service module. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci- Sensor Service: interacts with the HDF module to receive, parse, and distribute data, manages sensors on hardware and sensor data reporting, and controls sensor permissions. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## Available APIs 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci **Table 1** APIs of the sensor framework 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci| API| Description| Parameter| 24e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 25e41f4b71Sopenharmony_ci| int32_t **GetAllSensors**( <br> SensorInfo \*\*sensorIn <br> fo, int32_t \*count) | Obtains information about all sensors in the system.<br>**Return value**: Returns **0** if the information is obtained; returns a non-zero value otherwise.| **sensorInfo** (not NULL): information about all sensors in the system<br>**count** (not NULL): total number of sensors in the system| 26e41f4b71Sopenharmony_ci| int32_t **SubscribeSensor** <br> (int32_t sensorTypeId, <br> SensorUser \*user) | Subscribes to sensor data. The system will report the obtained sensor data to the subscriber.<br>**Return value**: Returns **0** if the subscription is successful; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| 27e41f4b71Sopenharmony_ci| int32_t **UnsubscribeSensor** <br> (int32_t sensorTypeId, SensorUser \*user) | Unsubscribes from sensor data. The system will no longer report sensor data to the subscriber.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| 28e41f4b71Sopenharmony_ci| int32_t **SetBatch**(int32_t sensorTypeId, SensorUser <br> \*user, int64_t samplingInterval, int64_t reportInterval) | Sets the data sampling interval and data reporting interval for the specified sensor.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.<br>**samplingInterval**: sensor data sampling interval, in nanoseconds<br>**reportInterval**: sensor data reporting interval, in nanoseconds| 29e41f4b71Sopenharmony_ci| int32_t **ActivateSensor**(int32_t sensorTypeId, <br> SensorUser \*user) | Enables the specified sensor that has been subscribed to.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| 30e41f4b71Sopenharmony_ci| int32_t **DeactivateSensor**(int32_t sensor <br> TypeId, SensorUser \*user) | Disables an enabled sensor.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| 31e41f4b71Sopenharmony_ci| int32_t **SetMode**(int32_t sensorTypeId, <br> SensorUser \*user, int32_t mode) | Sets the data reporting mode for the specified sensor.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.<br>**mode**: data reporting mode of the sensor| 32