同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
The 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.
Figure 1 Sensor service framework
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.
Sensor Framework: manages sensor data subscription, creates and destroys data channels, and implements communication with the Sensor Service module.
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.
Table 1 APIs of the sensor framework
API | Description | Parameter |
---|---|---|
int32_t GetAllSensors( SensorInfo **sensorIn fo, int32_t *count) |
Obtains information about all sensors in the system. 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 count (not NULL): total number of sensors in the system |
int32_t SubscribeSensor (int32_t sensorTypeId, SensorUser *user) |
Subscribes to sensor data. The system will report the obtained sensor data to the subscriber. Return value: Returns 0 if the subscription is successful; returns a non-zero value otherwise. |
sensorTypeId: ID of a sensor type user (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor. |
int32_t UnsubscribeSensor (int32_t sensorTypeId, SensorUser *user) |
Unsubscribes from sensor data. The system will no longer report sensor data to the subscriber. 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 user (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor. |
int32_t SetBatch(int32_t sensorTypeId, SensorUser *user, int64_t samplingInterval, int64_t reportInterval) |
Sets the data sampling interval and data reporting interval for the specified sensor. 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 user (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor. samplingInterval: sensor data sampling interval, in nanoseconds reportInterval: sensor data reporting interval, in nanoseconds |
int32_t ActivateSensor(int32_t sensorTypeId, SensorUser *user) |
Enables the specified sensor that has been subscribed to. 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 user (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor. |
int32_t DeactivateSensor(int32_t sensor TypeId, SensorUser *user) |
Disables an enabled sensor. 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 user (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor. |
int32_t SetMode(int32_t sensorTypeId, SensorUser *user, int32_t mode) |
Sets the data reporting mode for the specified sensor. 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 user (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor. mode: data reporting mode of the sensor |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。