1e41f4b71Sopenharmony_ci# Sensor
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciThe **Sensor** module provides APIs to manipulate sensors. For example, you can call APIs to obtain sensor information and subscribe to or unsubscribe from sensor data.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ciIt also provides APIs to define common sensor attributes.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci**Since**: 11
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Summary
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci### Files
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci| Name| Description|
19e41f4b71Sopenharmony_ci| -------- | -------- |
20e41f4b71Sopenharmony_ci| [oh_sensor.h](oh_sensor_8h.md) | Declares the APIs for operating sensors, including obtaining sensor information and subscribing to and unsubscribing from sensor data. |
21e41f4b71Sopenharmony_ci| [oh_sensor_type.h](oh_sensor_type_8h.md) | Declares the common sensor attributes. |
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci### Types
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| Name| Description|
27e41f4b71Sopenharmony_ci| -------- | -------- |
28e41f4b71Sopenharmony_ci| [Sensor_Type](#sensor_type) | Defines an enum for sensor types. |
29e41f4b71Sopenharmony_ci| [Sensor_Result](#sensor_result) | Defines an enum for sensor result codes. |
30e41f4b71Sopenharmony_ci| [Sensor_Accuracy](#sensor_accuracy) | Defines an enum for accuracy levels of data reported by a sensor.|
31e41f4b71Sopenharmony_ci| [Sensor_Info](#sensor_info) | Defines a struct for the sensor information. |
32e41f4b71Sopenharmony_ci| [Sensor_Event](#sensor_event) | Defines a struct for the sensor data information. |
33e41f4b71Sopenharmony_ci| [Sensor_SubscriptionId](#sensor_subscriptionid) | Defines a struct for the sensor subscription ID, which uniquely identifies a sensor. |
34e41f4b71Sopenharmony_ci| [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) | Defines a struct for the sensor subscription attribute.|
35e41f4b71Sopenharmony_ci| void ([*Sensor_EventCallback](#sensor_eventcallback)) ([Sensor_Event](#sensor_event) \*event) | Defines the callback function used to report sensor data.|
36e41f4b71Sopenharmony_ci| [Sensor_Subscriber](#sensor_subscriber) | Defines a struct for the sensor subscriber information. |
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci### Enums
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| Name| Description|
42e41f4b71Sopenharmony_ci| -------- | -------- |
43e41f4b71Sopenharmony_ci| [Sensor_Type](#sensor_type) {<br>SENSOR_TYPE_ACCELEROMETER = 1, <br>SENSOR_TYPE_GYROSCOPE = 2,<br> SENSOR_TYPE_AMBIENT_LIGHT = 5, <br>SENSOR_TYPE_MAGNETIC_FIELD = 6,<br>SENSOR_TYPE_BAROMETER = 8,<br> SENSOR_TYPE_HALL = 10, <br>SENSOR_TYPE_PROXIMITY = 12,<br> SENSOR_TYPE_ORIENTATION = 256,<br>SENSOR_TYPE_GRAVITY = 257, <br>SENSOR_TYPE_LINEAR_ACCELERATION = 258,<br>SENSOR_TYPE_ROTATION_VECTOR = 259,<br>SENSOR_TYPE_GAME_ROTATION_VECTOR = 262,<br>SENSOR_TYPE_PEDOMETER_DETECTION = 265,<br> SENSOR_TYPE_PEDOMETER = 266,<br>SENSOR_TYPE_HEART_RATE = 278<br>} | Enumerates the sensor types. |
44e41f4b71Sopenharmony_ci| [Sensor_Result](#sensor_result) { <br>SENSOR_SUCCESS = 0,<br> SENSOR_PERMISSION_DENIED = 201, <br>SENSOR_PARAMETER_ERROR = 401,<br> SENSOR_SERVICE_EXCEPTION = 14500101<br> } | Enumerates the sensor result codes. |
45e41f4b71Sopenharmony_ci| [Sensor_Accuracy](#sensor_accuracy) { <br>SENSOR_ACCURACY_UNRELIABLE = 0, <br>SENSOR_ACCURACY_LOW = 1,<br> SENSOR_ACCURACY_MEDIUM = 2, <br>SENSOR_ACCURACY_HIGH = 3 <br>} | Defines an enum for accuracy levels of data reported by a sensor.|
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci### Functions
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci| Name| Description|
51e41f4b71Sopenharmony_ci| -------- | -------- |
52e41f4b71Sopenharmony_ci| [OH_Sensor_GetInfos](#oh_sensor_getinfos)([Sensor_Info](#sensor_info) **infos, uint32_t *count) | Obtains information about all sensors on the device.                                |
53e41f4b71Sopenharmony_ci| [OH_Sensor_Subscribe](#oh_sensor_subscribe)(const [Sensor_SubscriptionId](#sensor_subscriptionid) *id, const [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) *attribute, const [Sensor_Subscriber](#sensor_subscriber) *subscriber) | Subscribe to sensor data. The system will report sensor data to the subscriber at the specified frequency.<br>To subscribe to data of acceleration sensors, request the **ohos.permission.ACCELEROMETER** permission.<br>To subscribe to data of gyroscope sensors, request the **ohos.permission.GYROSCOPE** permission.<br>To subscribe to data of pedometer-related sensors, request the **ohos.permission.ACTIVITY_MOTION** permission.<br>To subscribe to data of health-related sensors, such as heart rate sensors, request the **ohos.permission.READ_HEALTH_DATA** permission. Otherwise, the subscription fails.<br>You do not need to request any permission to subscribe to data of other types of sensors.|
54e41f4b71Sopenharmony_ci| [OH_Sensor_Unsubscribe](#oh_sensor_unsubscribe)(const [Sensor_SubscriptionId](#sensor_subscriptionid) *id, const [Sensor_Subscriber](#sensor_subscriber) *subscriber) | Unsubscribes from sensor data.<br>To unsubscribe from data of acceleration sensors, request the **ohos.permission.ACCELEROMETER** permission.<br>To unsubscribe from data of gyroscope sensors, request the **ohos.permission.GYROSCOPE** permission.<br>To unsubscribe from data of pedometer-related sensors, request the **ohos.permission.ACTIVITY_MOTION** permission.<br>To unsubscribe from data of health-related sensors, request the **ohos.permission.READ_HEALTH_DATA** permission. Otherwise, the unsubscription fails.<br>You do not need to request any permission to unsubscribe from data of other types of sensors.|
55e41f4b71Sopenharmony_ci| [OH_Sensor_CreateInfos](#oh_sensor_createinfos)(uint32_t count) | Creates an array of [Sensor_Info](#sensor_info) instances with the given number.|
56e41f4b71Sopenharmony_ci| [OH_Sensor_DestroyInfos](#oh_sensor_destroyinfos)([Sensor_Info](#sensor_info) **sensors, uint32_t count) | Destroys an array of [Sensor_Info](#sensor_info) instances and reclaims memory.|
57e41f4b71Sopenharmony_ci| [OH_SensorInfo_GetName](#oh_sensorinfo_getname)([Sensor_Info](#sensor_info) *sensor, char *sensorName, uint32_t *length) | Obtains the sensor name. |
58e41f4b71Sopenharmony_ci| [OH_SensorInfo_GetVendorName](#oh_sensorinfo_getvendorname)([Sensor_Info](#sensor_info)* sensor, char *vendorName, uint32_t *length) | Obtains the sensor's vendor name. |
59e41f4b71Sopenharmony_ci| [OH_SensorInfo_GetType](#oh_sensorinfo_gettype)([Sensor_Info](#sensor_info)* sensor, [Sensor_Type](#sensor_type) *sensorType) | Obtains the sensor type. |
60e41f4b71Sopenharmony_ci| [OH_SensorInfo_GetResolution](#oh_sensorinfo_getresolution)([Sensor_Info](#sensor_info)* sensor, float *resolution) | Obtains the sensor resolution.                                          |
61e41f4b71Sopenharmony_ci| [OH_SensorInfo_GetMinSamplingInterval](#oh_sensorinfo_getminsamplinginterval)([Sensor_Info](#sensor_info)* sensor, int64_t *minSamplingInterval) | Obtains the minimum data reporting interval of a sensor. |
62e41f4b71Sopenharmony_ci| [OH_SensorInfo_GetMaxSamplingInterval](#oh_sensorinfo_getmaxsamplinginterval)([Sensor_Info](#sensor_info)* sensor, int64_t *maxSamplingInterval) | Obtains the maximum data reporting interval of a sensor. |
63e41f4b71Sopenharmony_ci| [OH_SensorEvent_GetType](#oh_sensorevent_gettype)([Sensor_Event](#sensor_event)* sensorEvent, [Sensor_Type](#sensor_type) *sensorType) | Obtains the sensor type. |
64e41f4b71Sopenharmony_ci| [OH_SensorEvent_GetTimestamp](#oh_sensorevent_gettimestamp)([Sensor_Event](#sensor_event)* sensorEvent, int64_t *timestamp) | Obtains the timestamp of sensor data.                                    |
65e41f4b71Sopenharmony_ci| [OH_SensorEvent_GetAccuracy](#oh_sensorevent_getaccuracy)([Sensor_Event](#sensor_event)* sensorEvent, Sensor_Accuracy *accuracy) | Obtains the accuracy of sensor data.                                      |
66e41f4b71Sopenharmony_ci| [OH_SensorEvent_GetData](#oh_sensorevent_getdata)([Sensor_Event](#sensor_event)* sensorEvent, float **data, uint32_t *length) | Obtains sensor data.<br>The data length and content depend on the sensor type. The format of the sensor data reported is as follows:<br>- SENSOR_TYPE_ACCELEROMETER: data[0], data[1], and data[2], indicating the acceleration around the x, y, and z axes of a device, respectively, in m/s².<br>- SENSOR_TYPE_GYROSCOPE: data[0], data[1], and data[2], indicating the angular velocity of rotation around the x, y, and z axes of a device, respectively, in rad/s.<br>- SENSOR_TYPE_AMBIENT_LIGHT: data[0], indicating the ambient light intensity, in lux. Since API version 12, two extra data records are returned, where **data[1]** indicates the color temperature (in kelvin), and **data[2]** indicates the infrared luminance (in cd/m²).<br>4. - SENSOR_TYPE_MAGNETIC_FIELD: data[0], data[1], and data[2], indicating the magnetic field strength around the x, y, and z axes of a device, respectively, in μT.<br>- SENSOR_TYPE_BAROMETER: data[0], indicating the atmospheric pressure, in hPa.<br>- SENSOR_TYPE_HALL: data[0], indicating the opening/closing state of the flip cover. The value **0** means that the flip cover is opened, and a value greater than 0 means that the flip cover is closed.<br>- SENSOR_TYPE_PROXIMITY: data[0], indicates the approaching state. The value **0** means the two objects are close to each other, and a value greater than 0 means that they are far away from each other.<br>- SENSOR_TYPE_ORIENTATION: data[0], data[1], and data[2], indicating the rotation angles of a device around the z, x, and y axes, respectively, in degree.<br>- SENSOR_TYPE_GRAVITY: data[0], data[1], and data[2], indicating the gravitational acceleration around the x, y, and z axes of a device, respectively, in m/s².<br>- SENSOR_TYPE_ROTATION_VECTOR: data[0], data[1] and data[2], indicating the rotation angles of a device around the x, y, and z axes, respectively, in degree. data[3] indicates the rotation vector.<br>- SENSOR_TYPE_PEDOMETER_DETECTION: data[0], indicating the pedometer detection status. The value **1** means that the number of detected steps changes.<br>- SENSOR_TYPE_PEDOMETER: data[0], indicating the number of steps a user has walked.<br>- SENSOR_TYPE_HEART_RATE: data[0], indicating the heart rate value.<br>- SENSOR_TYPE_LINEAR_ACCELERATION: data[0], data[1], and data[2], indicating the acceleration around the x, y, and z axes of a device, respectively, in m/s². This parameter is supported since API version 13.<br>- SENSOR_TYPE_GAME_ROTATION_VECTOR: data[0], data[1] and data[2], indicating the rotation angles of a device around the x, y, and z axes, respectively, in degree; data[3], indicating the rotation vector. This parameter is supported since API version 13.|
67e41f4b71Sopenharmony_ci| [OH_Sensor_CreateSubscriptionId](#oh_sensor_createsubscriptionid)(void) | Creates a [Sensor_SubscriptionId](#sensor_subscriptionid) instance.|
68e41f4b71Sopenharmony_ci| [OH_Sensor_DestroySubscriptionId](#oh_sensor_destroysubscriptionid)([Sensor_SubscriptionId](#sensor_subscriptionid) *id) | Destroys a [Sensor_SubscriptionId](#sensor_subscriptionid) instance and reclaims memory.|
69e41f4b71Sopenharmony_ci| [OH_SensorSubscriptionId_GetType](#oh_sensorsubscriptionid_gettype)([Sensor_SubscriptionId](#sensor_subscriptionid) *id, [Sensor_Type](#sensor_type) *sensorType) | Obtains the sensor type. |
70e41f4b71Sopenharmony_ci| [OH_SensorSubscriptionId_SetType](#oh_sensorsubscriptionid_settype)([Sensor_SubscriptionId](#sensor_subscriptionid)* id, const [Sensor_Type](#sensor_type) sensorType) | Sets the sensor type. |
71e41f4b71Sopenharmony_ci| [OH_Sensor_CreateSubscriptionAttribute](#oh_sensor_createsubscriptionattribute)(void) | Creates a [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) instance.|
72e41f4b71Sopenharmony_ci| [OH_Sensor_DestroySubscriptionAttribute](#oh_sensor_destroysubscriptionattribute)([Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) *attribute) | Destroys a [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) instance and reclaims memory.|
73e41f4b71Sopenharmony_ci| [OH_SensorSubscriptionAttribute_SetSamplingInterval](#oh_sensorsubscriptionattribute_setsamplinginterval)([Sensor_SubscriptionAttribute](#sensor_subscriptionattribute)* attribute, const int64_t samplingInterval) | Sets the interval for reporting sensor data.                                 |
74e41f4b71Sopenharmony_ci| [OH_SensorSubscriptionAttribute_GetSamplingInterval](#oh_sensorsubscriptionattribute_getsamplinginterval) ([Sensor_SubscriptionAttribute](#sensor_subscriptionattribute)* attribute, int64_t *samplingInterval) | Obtains the interval for reporting sensor data.                                  |
75e41f4b71Sopenharmony_ci| [OH_Sensor_CreateSubscriber](#oh_sensor_createsubscriber)(void) | Creates a [Sensor_Subscriber](#sensor_subscriber) instance.     |
76e41f4b71Sopenharmony_ci| [OH_Sensor_DestroySubscriber](#oh_sensor_destroysubscriber)([Sensor_Subscriber](#sensor_subscriber) *subscriber) | Destroys a [Sensor_Subscriber](#sensor_subscriber) instance and reclaims memory.|
77e41f4b71Sopenharmony_ci| [OH_SensorSubscriber_SetCallback](#oh_sensorsubscriber_setcallback)([Sensor_Subscriber](#sensor_subscriber)* subscriber, const [Sensor_EventCallback](#sensor_eventcallback) callback) | Sets a callback function to report sensor data.|
78e41f4b71Sopenharmony_ci| [OH_SensorSubscriber_GetCallback](#oh_sensorsubscriber_getcallback)([Sensor_Subscriber](#sensor_subscriber)* subscriber, [Sensor_EventCallback](#sensor_eventcallback) *callback) | Obtains the callback function used to report sensor data.|
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci## Type Description
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci### Sensor_Accuracy
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci```
87e41f4b71Sopenharmony_citypedef enum Sensor_Accuracy Sensor_Accuracy
88e41f4b71Sopenharmony_ci```
89e41f4b71Sopenharmony_ci**Description**
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ciDefines an enum for accuracy levels of data reported by a sensor.
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci**Since**: 11
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci### Sensor_Event
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci```
99e41f4b71Sopenharmony_citypedef struct Sensor_Event Sensor_Event
100e41f4b71Sopenharmony_ci```
101e41f4b71Sopenharmony_ci**Description**
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ciDefines a struct for the sensor data information.
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci**Since**: 11
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci### Sensor_EventCallback
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci```
111e41f4b71Sopenharmony_citypedef void(*Sensor_EventCallback)(Sensor_Event *event)
112e41f4b71Sopenharmony_ci```
113e41f4b71Sopenharmony_ci**Description**
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ciDefines the callback function used to report sensor data.
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**Since**: 11
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci### Sensor_Info
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci```
123e41f4b71Sopenharmony_citypedef struct Sensor_Info Sensor_Info
124e41f4b71Sopenharmony_ci```
125e41f4b71Sopenharmony_ci**Description**
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ciDefines a struct for the sensor information.
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Since**: 11
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci### Sensor_Result
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci```
135e41f4b71Sopenharmony_citypedef enum Sensor_Result Sensor_Result
136e41f4b71Sopenharmony_ci```
137e41f4b71Sopenharmony_ci**Description**
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciDefines an enum for sensor result codes.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**Since**: 11
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci### Sensor_Subscriber
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci```
147e41f4b71Sopenharmony_citypedef struct Sensor_Subscriber Sensor_Subscriber
148e41f4b71Sopenharmony_ci```
149e41f4b71Sopenharmony_ci**Description**
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ciDefines a struct the sensor subscriber information.
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci**Since**: 11
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci### Sensor_SubscriptionAttribute
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci```
159e41f4b71Sopenharmony_citypedef struct Sensor_SubscriptionAttribute Sensor_SubscriptionAttribute
160e41f4b71Sopenharmony_ci```
161e41f4b71Sopenharmony_ci**Description**
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ciDefines a struct for the sensor subscription attribute.
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci**Since**: 11
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci### Sensor_SubscriptionId
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci```
171e41f4b71Sopenharmony_citypedef struct Sensor_SubscriptionId Sensor_SubscriptionId
172e41f4b71Sopenharmony_ci```
173e41f4b71Sopenharmony_ci**Description**
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ciDefines a struct for the sensor subscription ID, which uniquely identifies a sensor.
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci**Since**: 11
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci### Sensor_Type
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci```
183e41f4b71Sopenharmony_citypedef enum Sensor_Type Sensor_Type
184e41f4b71Sopenharmony_ci```
185e41f4b71Sopenharmony_ci**Description**
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ciDefines an enum for sensor types.
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci**Since**: 11
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci## Enum Description
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci### Sensor_Accuracy
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci```
198e41f4b71Sopenharmony_cienum Sensor_Accuracy
199e41f4b71Sopenharmony_ci```
200e41f4b71Sopenharmony_ci**Description**
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ciDefines an enum for accuracy levels of data reported by a sensor.
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**Since**: 11
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci| Value| Description|
207e41f4b71Sopenharmony_ci| -------- | -------- |
208e41f4b71Sopenharmony_ci| SENSOR_ACCURACY_UNRELIABLE  | The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure.|
209e41f4b71Sopenharmony_ci| SENSOR_ACCURACY_LOW  | The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used.|
210e41f4b71Sopenharmony_ci| SENSOR_ACCURACY_MEDIUM  | The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment before using it.|
211e41f4b71Sopenharmony_ci| SENSOR_ACCURACY_HIGH  | The sensor data is at a high accuracy level. The data can be used directly.|
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci### Sensor_Result
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci```
217e41f4b71Sopenharmony_cienum Sensor_Result
218e41f4b71Sopenharmony_ci```
219e41f4b71Sopenharmony_ci**Description**
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ciDefines an enum for sensor result codes.
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci**Since**: 11
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci| Value| Description|
226e41f4b71Sopenharmony_ci| -------- | -------- |
227e41f4b71Sopenharmony_ci| SENSOR_SUCCESS  | The operation is successful.|
228e41f4b71Sopenharmony_ci| SENSOR_PERMISSION_DENIED  | Permission verification failed.|
229e41f4b71Sopenharmony_ci| SENSOR_PARAMETER_ERROR  | Parameter check failed. For example, a mandatory parameter is not passed in, or the parameter type passed in is incorrect.|
230e41f4b71Sopenharmony_ci| SENSOR_SERVICE_EXCEPTION  | The sensor service is abnormal.|
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci### Sensor_Type
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci```
236e41f4b71Sopenharmony_cienum Sensor_Type
237e41f4b71Sopenharmony_ci```
238e41f4b71Sopenharmony_ci**Description**
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ciDefines an enum for sensor types.
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**Since**: 11
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci| Value| Description|
245e41f4b71Sopenharmony_ci| -------- | -------- |
246e41f4b71Sopenharmony_ci| SENSOR_TYPE_ACCELEROMETER  | Acceleration sensor.|
247e41f4b71Sopenharmony_ci| SENSOR_TYPE_GYROSCOPE  | Gyroscope sensor.|
248e41f4b71Sopenharmony_ci| SENSOR_TYPE_AMBIENT_LIGHT  | Ambient light sensor.|
249e41f4b71Sopenharmony_ci| SENSOR_TYPE_MAGNETIC_FIELD  | Magnetic field sensor.|
250e41f4b71Sopenharmony_ci| SENSOR_TYPE_BAROMETER  | Barometer sensor|
251e41f4b71Sopenharmony_ci| SENSOR_TYPE_HALL  | Hall effect sensor.|
252e41f4b71Sopenharmony_ci| SENSOR_TYPE_PROXIMITY  | Proximity sensor.|
253e41f4b71Sopenharmony_ci| SENSOR_TYPE_ORIENTATION  | Orientation sensor.|
254e41f4b71Sopenharmony_ci| SENSOR_TYPE_GRAVITY  | Gravity sensor.|
255e41f4b71Sopenharmony_ci| SENSOR_TYPE_ROTATION_VECTOR  | Rotation vector sensor.|
256e41f4b71Sopenharmony_ci| SENSOR_TYPE_PEDOMETER_DETECTION  | Pedometer detection sensor.|
257e41f4b71Sopenharmony_ci| SENSOR_TYPE_PEDOMETER  | Pedometer sensor.|
258e41f4b71Sopenharmony_ci| SENSOR_TYPE_HEART_RATE  | Heart rate sensor.|
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci## Function Description
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci### OH_Sensor_CreateInfos()
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci```
267e41f4b71Sopenharmony_ciSensor_Info **OH_Sensor_CreateInfos(uint32_t count)
268e41f4b71Sopenharmony_ci```
269e41f4b71Sopenharmony_ci**Description**
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ciCreates an array of [Sensor_Info](#sensor_info) instances with the given number.
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci**Since**: 11
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci**Parameters**
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci| Name| Description|
278e41f4b71Sopenharmony_ci| -------- | -------- |
279e41f4b71Sopenharmony_ci| count | Number of [Sensor_Info](#sensor_info) instances to create.|
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci**Returns**
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ciReturns the double pointer to the array of [Sensor_Info](#sensor_info) instances if the operation is successful; returns **NULL** otherwise.
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci### OH_Sensor_CreateSubscriber()
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci```
289e41f4b71Sopenharmony_ciSensor_Subscriber *OH_Sensor_CreateSubscriber(void)
290e41f4b71Sopenharmony_ci```
291e41f4b71Sopenharmony_ci**Description**
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ciCreates a [Sensor_Subscriber](#sensor_subscriber) instance.
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**Since**: 11
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci**Returns**
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ciReturns the pointer to the [Sensor_Subscriber](#sensor_subscriber) instances if the operation is successful; returns **NULL** otherwise.
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci### OH_Sensor_CreateSubscriptionAttribute()
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci```
305e41f4b71Sopenharmony_ciSensor_SubscriptionAttribute *OH_Sensor_CreateSubscriptionAttribute(void)
306e41f4b71Sopenharmony_ci```
307e41f4b71Sopenharmony_ci**Description**
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ciCreates a [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) instance.
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci**Since**: 11
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci**Returns**
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ciReturns the pointer to the [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) instances if the operation is successful; returns **NULL** otherwise.
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci### OH_Sensor_CreateSubscriptionId()
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci```
321e41f4b71Sopenharmony_ciSensor_SubscriptionId *OH_Sensor_CreateSubscriptionId(void)
322e41f4b71Sopenharmony_ci```
323e41f4b71Sopenharmony_ci**Description**
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ciCreates a [Sensor_SubscriptionId](#sensor_subscriptionid) instance.
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci**Since**: 11
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**Returns**
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ciReturns the pointer to the [Sensor_SubscriptionId](#sensor_subscriptionid) instances if the operation is successful; returns **NULL** otherwise.
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci### OH_Sensor_DestroyInfos()
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci```
337e41f4b71Sopenharmony_ciint32_t OH_Sensor_DestroyInfos(Sensor_Info **sensors, uint32_t count)
338e41f4b71Sopenharmony_ci```
339e41f4b71Sopenharmony_ci**Description**
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ciDestroys an array of [Sensor_Info](#sensor_info) instances and reclaims memory.
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci**Since**: 11
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**Parameters**
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci| Name| Description|
348e41f4b71Sopenharmony_ci| -------- | -------- |
349e41f4b71Sopenharmony_ci| sensors | Double pointer to the array of [Sensor_Info](#sensor_info) instances.|
350e41f4b71Sopenharmony_ci| count | Number of [Sensor_Info](#sensor_info) instances to destroy.|
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci**Returns**
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci### OH_Sensor_DestroySubscriber()
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci```
360e41f4b71Sopenharmony_ciint32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber)
361e41f4b71Sopenharmony_ci```
362e41f4b71Sopenharmony_ci**Description**
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ciDestroys a [Sensor_Subscriber](#sensor_subscriber) instance and reclaims memory.
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**Since**: 11
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci**Parameters**
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci| Name| Description|
371e41f4b71Sopenharmony_ci| -------- | -------- |
372e41f4b71Sopenharmony_ci| subscriber | Pointer to the [Sensor_Subscriber](#sensor_subscriber) instance.|
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci**Returns**
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci### OH_Sensor_DestroySubscriptionAttribute()
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci```
382e41f4b71Sopenharmony_ciint32_t OH_Sensor_DestroySubscriptionAttribute(Sensor_SubscriptionAttribute *attribute)
383e41f4b71Sopenharmony_ci```
384e41f4b71Sopenharmony_ci**Description**
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ciDestroys a [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) instance and reclaims memory.
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**Since**: 11
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**Parameters**
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci| Name| Description|
393e41f4b71Sopenharmony_ci| -------- | -------- |
394e41f4b71Sopenharmony_ci| attribute | Pointer to the [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute) instance.|
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci**Returns**
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci### OH_Sensor_DestroySubscriptionId()
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci```
404e41f4b71Sopenharmony_ciint32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id)
405e41f4b71Sopenharmony_ci```
406e41f4b71Sopenharmony_ci**Description**
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ciDestroys a [Sensor_SubscriptionId](#sensor_subscriptionid) instance and reclaims memory.
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci**Since**: 11
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci**Parameters**
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci| Name| Description|
415e41f4b71Sopenharmony_ci| -------- | -------- |
416e41f4b71Sopenharmony_ci| id | Pointer to the [Sensor_SubscriptionId](#sensor_subscriptionid) instance.|
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci**Returns**
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci### OH_Sensor_GetInfos()
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci```
426e41f4b71Sopenharmony_ciSensor_Result OH_Sensor_GetInfos(Sensor_Info **infos, uint32_t *count)
427e41f4b71Sopenharmony_ci```
428e41f4b71Sopenharmony_ci**Description**
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ciObtains information about all sensors on the device.
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**Since**: 11
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci**Parameters**
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci| Name| Description|
437e41f4b71Sopenharmony_ci| -------- | -------- |
438e41f4b71Sopenharmony_ci| infos | Double pointers to the information about all sensors on the device. For details, see [Sensor_Info](#sensor_info).|
439e41f4b71Sopenharmony_ci| count | Pointer to the number of sensors on the device. |
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci**Returns**
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci### OH_Sensor_Subscribe()
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci```
449e41f4b71Sopenharmony_ciSensor_Result OH_Sensor_Subscribe(const Sensor_SubscriptionId *id, const Sensor_SubscriptionAttribute *attribute, const Sensor_Subscriber *subscriber)
450e41f4b71Sopenharmony_ci```
451e41f4b71Sopenharmony_ci**Description**
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ciSubscribe to sensor data. The system will report sensor data to the subscriber at the specified frequency. To subscribe to data of acceleration sensors, request the **ohos.permission.ACCELEROMETER** permission. To subscribe to data of gyroscope sensors, request the **ohos.permission.GYROSCOPE** permission. To subscribe to data of pedometer-related sensors, request the **ohos.permission.ACTIVITY_MOTION** permission. To subscribe to data of health-related sensors, such as heart rate sensors, request the **ohos.permission.READ_HEALTH_DATA** permission. Otherwise, the subscription fails. You do not need to request any permission to subscribe to data of other types of sensors.
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ci**Since**: 11
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci**Parameters**
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci| Name| Description|
460e41f4b71Sopenharmony_ci| -------- | -------- |
461e41f4b71Sopenharmony_ci| id | Pointer to the sensor subscription ID. For details, see [Sensor_SubscriptionId](#sensor_subscriptionid).|
462e41f4b71Sopenharmony_ci| attribute | Pointer to the subscription attribute, which is used to specify the data reporting frequency. For details, see [Sensor_SubscriptionAttribute](#sensor_subscriptionattribute).|
463e41f4b71Sopenharmony_ci| subscriber | Pointer to the subscriber information, which is used by the callback function to report sensor data. For details, see [Sensor_Subscriber](#sensor_subscriber).|
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_ci**Returns**
466e41f4b71Sopenharmony_ci
467e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
468e41f4b71Sopenharmony_ci
469e41f4b71Sopenharmony_ci**Required Permissions**
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ciohos.permission.ACCELEROMETER, ohos.permission.GYROSCOPE, ohos.permission.ACTIVITY_MOTION, or ohos.permission.READ_HEALTH_DATA
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci### OH_Sensor_Unsubscribe()
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci```
477e41f4b71Sopenharmony_ciSensor_Result OH_Sensor_Unsubscribe(const Sensor_SubscriptionId *id, const Sensor_Subscriber *subscriber)
478e41f4b71Sopenharmony_ci```
479e41f4b71Sopenharmony_ci**Description**
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ciUnsubscribes from sensor data. To unsubscribe from data of acceleration sensors, request the **ohos.permission.ACCELEROMETER** permission. To unsubscribe from data of gyroscope sensors, request the **ohos.permission.GYROSCOPE** permission. To unsubscribe from data of pedometer-related sensors, request the **ohos.permission.ACTIVITY_MOTION** permission. To unsubscribe from data of health-related sensors, request the **ohos.permission.READ_HEALTH_DATA** permission. Otherwise, the unsubscription fails. You do not need to request any permission to unsubscribe from data of other types of sensors.
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ci**Since**: 11
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ci**Parameters**
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ci| Name| Description|
488e41f4b71Sopenharmony_ci| -------- | -------- |
489e41f4b71Sopenharmony_ci| id | Pointer to the sensor subscription ID. For details, see [Sensor_SubscriptionId](#sensor_subscriptionid).|
490e41f4b71Sopenharmony_ci| subscriber | Pointer to the subscriber information, which is used by the callback function to report sensor data. For details, see [Sensor_Subscriber](#sensor_subscriber).|
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci**Returns**
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci**Required Permissions**
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ciohos.permission.ACCELEROMETER, ohos.permission.GYROSCOPE, ohos.permission.ACTIVITY_MOTION, or ohos.permission.READ_HEALTH_DATA
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci### OH_SensorEvent_GetAccuracy()
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci```
504e41f4b71Sopenharmony_ciint32_t OH_SensorEvent_GetAccuracy(Sensor_Event* sensorEvent, Sensor_Accuracy *accuracy)
505e41f4b71Sopenharmony_ci```
506e41f4b71Sopenharmony_ci**Description**
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ciObtains the accuracy of sensor data.
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci**Since**: 11
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci**Parameters**
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci| Name| Description|
515e41f4b71Sopenharmony_ci| -------- | -------- |
516e41f4b71Sopenharmony_ci| sensorEvent | Pointer to the sensor data information. |
517e41f4b71Sopenharmony_ci| accuracy | Pointer to the accuracy. |
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci**Returns**
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci### OH_SensorEvent_GetData()
525e41f4b71Sopenharmony_ci
526e41f4b71Sopenharmony_ci```
527e41f4b71Sopenharmony_ciint32_t OH_SensorEvent_GetData(Sensor_Event* sensorEvent, float **data, uint32_t *length)
528e41f4b71Sopenharmony_ci```
529e41f4b71Sopenharmony_ci**Description**
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ciObtains sensor data. The data length and content depend on the sensor type. The format of the sensor data reported is as follows:
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci- SENSOR_TYPE_ACCELEROMETER: data[0], data[1], and data[2], indicating the acceleration around the x, y, and z axes of a device, respectively, in m/s².
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci- SENSOR_TYPE_GYROSCOPE: data[0], data[1], and data[2], indicating the angular velocity of rotation around the x, y, and z axes of a device, respectively, in rad/s.
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci- SENSOR_TYPE_AMBIENT_LIGHT: data[0], indicating the ambient light intensity, in lux.
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci- SENSOR_TYPE_MAGNETIC_FIELD: data[0], data[1], and data[2], indicating the magnetic field strength around the x, y, and z axes of a device, respectively, in μT.
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ci- SENSOR_TYPE_BAROMETER: data[0], indicating the atmospheric pressure, in hPa.
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci- SENSOR_TYPE_HALL: data[0], indicating the opening/closing state of the flip cover. The value **0** means that the flip cover is opened, and a value greater than 0 means that the flip cover is closed.
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_ci- SENSOR_TYPE_PROXIMITY: data[0], indicates the approaching state. The value **0** means the two objects are close to each other, and a value greater than 0 means that they are far away from each other.
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ci- SENSOR_TYPE_ORIENTATION: data[0], data[1], and data[2], indicating the rotation angles of a device around the z, x, and y axes, respectively, in degree.
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci- SENSOR_TYPE_GRAVITY: data[0], data[1], and data[2], indicating the gravitational acceleration around the x, y, and z axes of a device, respectively, in m/s².
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci- SENSOR_TYPE_ROTATION_VECTOR: data[0], data[1] and data[2], indicating the rotation angles of a device around the x, y, and z axes, respectively, in degree. data[3] indicates the rotation vector.
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci- SENSOR_TYPE_PEDOMETER_DETECTION: data[0], indicating the pedometer detection status. The value **1** means that the number of detected steps changes.
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci- SENSOR_TYPE_PEDOMETER: data[0], indicating the number of steps a user has walked.
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci- SENSOR_TYPE_HEART_RATE: data[0], indicating the heart rate value.
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_ci- SENSOR_TYPE_LINEAR_ACCELERATION: data[0], data[1], and data[2], indicating the acceleration around the x, y, and z axes of a device, respectively, in m/s². This parameter is supported since API version 13.
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ci- SENSOR_TYPE_GAME_ROTATION_VECTOR: data[0], data[1] and data[2], indicating the rotation angles of a device around the x, y, and z axes, respectively, in degree; data[3], indicating the rotation vector. This parameter is supported since API version 13.
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ci**Since**: 11
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ci**Parameters**
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ci| Name| Description|
568e41f4b71Sopenharmony_ci| -------- | -------- |
569e41f4b71Sopenharmony_ci| sensorEvent | Pointer to the sensor data information. |
570e41f4b71Sopenharmony_ci| data | Double pointer to the sensor data. |
571e41f4b71Sopenharmony_ci| length | Pointer to the array length. |
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci**Returns**
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci
578e41f4b71Sopenharmony_ci### OH_SensorEvent_GetTimestamp()
579e41f4b71Sopenharmony_ci
580e41f4b71Sopenharmony_ci```
581e41f4b71Sopenharmony_ciint32_t OH_SensorEvent_GetTimestamp(Sensor_Event* sensorEvent, int64_t *timestamp)
582e41f4b71Sopenharmony_ci```
583e41f4b71Sopenharmony_ci**Description**
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ciObtains the timestamp of sensor data.
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**Since**: 11
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci**Parameters**
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci| Name| Description|
592e41f4b71Sopenharmony_ci| -------- | -------- |
593e41f4b71Sopenharmony_ci| sensorEvent | Pointer to the sensor data information. |
594e41f4b71Sopenharmony_ci| timestamp | Pointer to the timestamp. |
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci**Returns**
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci### OH_SensorEvent_GetType()
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci```
604e41f4b71Sopenharmony_ciint32_t OH_SensorEvent_GetType(Sensor_Event* sensorEvent, Sensor_Type *sensorType)
605e41f4b71Sopenharmony_ci```
606e41f4b71Sopenharmony_ci**Description**
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ciObtains the sensor type.
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_ci**Since**: 11
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci**Parameters**
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci| Name| Description|
615e41f4b71Sopenharmony_ci| -------- | -------- |
616e41f4b71Sopenharmony_ci| sensorEvent | Pointer to the sensor data information. |
617e41f4b71Sopenharmony_ci| sensorType | Pointer to the sensor type. |
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_ci**Returns**
620e41f4b71Sopenharmony_ci
621e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci### OH_SensorInfo_GetMaxSamplingInterval()
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ci```
627e41f4b71Sopenharmony_ciint32_t OH_SensorInfo_GetMaxSamplingInterval(Sensor_Info* sensor, int64_t *maxSamplingInterval)
628e41f4b71Sopenharmony_ci```
629e41f4b71Sopenharmony_ci**Description**
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ciObtains the maximum data reporting interval of a sensor.
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci**Since**: 11
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci**Parameters**
636e41f4b71Sopenharmony_ci
637e41f4b71Sopenharmony_ci| Name| Description|
638e41f4b71Sopenharmony_ci| -------- | -------- |
639e41f4b71Sopenharmony_ci| sensor | Pointer to the sensor information. |
640e41f4b71Sopenharmony_ci| maxSamplingInterval | Pointer to the maximum data reporting interval, in nanoseconds. |
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci**Returns**
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci
647e41f4b71Sopenharmony_ci### OH_SensorInfo_GetMinSamplingInterval()
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci```
650e41f4b71Sopenharmony_ciint32_t OH_SensorInfo_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minSamplingInterval)
651e41f4b71Sopenharmony_ci```
652e41f4b71Sopenharmony_ci**Description**
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ciObtains the minimum data reporting interval of a sensor.
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci**Since**: 11
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci**Parameters**
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci| Name| Description|
661e41f4b71Sopenharmony_ci| -------- | -------- |
662e41f4b71Sopenharmony_ci| sensor | Pointer to the sensor information. |
663e41f4b71Sopenharmony_ci| minSamplingInterval | Pointer to the minimum data reporting interval, in nanoseconds. |
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci**Returns**
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ci### OH_SensorInfo_GetName()
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci```
673e41f4b71Sopenharmony_ciint32_t OH_SensorInfo_GetName (Sensor_Info* sensor, char *sensorName, uint32_t *length)
674e41f4b71Sopenharmony_ci```
675e41f4b71Sopenharmony_ci**Description**
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ciObtains the sensor name.
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci**Since**: 11
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_ci**Parameters**
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci| Name| Description|
684e41f4b71Sopenharmony_ci| -------- | -------- |
685e41f4b71Sopenharmony_ci| sensor | Pointer to the sensor information. |
686e41f4b71Sopenharmony_ci| sensorName | Pointer to the sensor data. |
687e41f4b71Sopenharmony_ci| length | Pointer to the length, in bytes. |
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**Returns**
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci
694e41f4b71Sopenharmony_ci### OH_SensorInfo_GetResolution()
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_ci```
697e41f4b71Sopenharmony_ciint32_t OH_SensorInfo_GetResolution(Sensor_Info* sensor, float *resolution)
698e41f4b71Sopenharmony_ci```
699e41f4b71Sopenharmony_ci**Description**
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ciObtains the sensor resolution.
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_ci**Since**: 11
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ci**Parameters**
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci| Name| Description|
708e41f4b71Sopenharmony_ci| -------- | -------- |
709e41f4b71Sopenharmony_ci| sensor | Pointer to the sensor information. |
710e41f4b71Sopenharmony_ci| resolution | Pointer to the sensor resolution. |
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**Returns**
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci### OH_SensorInfo_GetType()
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci```
720e41f4b71Sopenharmony_ciint32_t OH_SensorInfo_GetType(Sensor_Info* sensor, Sensor_Type *sensorType)
721e41f4b71Sopenharmony_ci```
722e41f4b71Sopenharmony_ci**Description**
723e41f4b71Sopenharmony_ci
724e41f4b71Sopenharmony_ciObtains the sensor type.
725e41f4b71Sopenharmony_ci
726e41f4b71Sopenharmony_ci**Since**: 11
727e41f4b71Sopenharmony_ci
728e41f4b71Sopenharmony_ci**Parameters**
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ci| Name| Description|
731e41f4b71Sopenharmony_ci| -------- | -------- |
732e41f4b71Sopenharmony_ci| sensor | Pointer to the sensor information. |
733e41f4b71Sopenharmony_ci| sensorType | Pointer to the sensor type. |
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci**Returns**
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci
740e41f4b71Sopenharmony_ci### OH_SensorInfo_GetVendorName()
741e41f4b71Sopenharmony_ci
742e41f4b71Sopenharmony_ci```
743e41f4b71Sopenharmony_ciint32_t OH_SensorInfo_GetVendorName(Sensor_Info* sensor, char *vendorName, uint32_t *length)
744e41f4b71Sopenharmony_ci```
745e41f4b71Sopenharmony_ci**Description**
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ciObtains the sensor's vendor name.
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci**Since**: 11
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ci**Parameters**
752e41f4b71Sopenharmony_ci
753e41f4b71Sopenharmony_ci| Name| Description|
754e41f4b71Sopenharmony_ci| -------- | -------- |
755e41f4b71Sopenharmony_ci| sensor | Pointer to the sensor information. |
756e41f4b71Sopenharmony_ci| vendorName | Pointer to the vendor name. |
757e41f4b71Sopenharmony_ci| length | Pointer to the length, in bytes. |
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ci**Returns**
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_ci### OH_SensorSubscriber_GetCallback()
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci```
767e41f4b71Sopenharmony_ciint32_t OH_SensorSubscriber_GetCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback)
768e41f4b71Sopenharmony_ci```
769e41f4b71Sopenharmony_ci**Description**
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ciObtains the callback function used to report sensor data.
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci**Since**: 11
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ci**Parameters**
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci| Name| Description|
778e41f4b71Sopenharmony_ci| -------- | -------- |
779e41f4b71Sopenharmony_ci| subscriber | Pointer to the sensor subscriber information. |
780e41f4b71Sopenharmony_ci| callback | Pointer to the callback function. |
781e41f4b71Sopenharmony_ci
782e41f4b71Sopenharmony_ci**Returns**
783e41f4b71Sopenharmony_ci
784e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
785e41f4b71Sopenharmony_ci
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci### OH_SensorSubscriber_SetCallback()
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci```
790e41f4b71Sopenharmony_ciint32_t OH_SensorSubscriber_SetCallback (Sensor_Subscriber* subscriber, const Sensor_EventCallback callback )
791e41f4b71Sopenharmony_ci```
792e41f4b71Sopenharmony_ci**Description**
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_ciSets a callback function to report sensor data.
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ci**Since**: 11
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci**Parameters**
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci| Name| Description|
801e41f4b71Sopenharmony_ci| -------- | -------- |
802e41f4b71Sopenharmony_ci| subscriber | Pointer to the sensor subscriber information. |
803e41f4b71Sopenharmony_ci| callback | Callback function to set. |
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci**Returns**
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ci### OH_SensorSubscriptionAttribute_GetSamplingInterval()
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci```
813e41f4b71Sopenharmony_ciint32_t OH_SensorSubscriptionAttribute_GetSamplingInterval (Sensor_SubscriptionAttribute * attribute, int64_t * samplingInterval )
814e41f4b71Sopenharmony_ci```
815e41f4b71Sopenharmony_ci**Description**
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ciObtains the interval for reporting sensor data.
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ci**Since**: 11
820e41f4b71Sopenharmony_ci
821e41f4b71Sopenharmony_ci**Parameters**
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci| Name| Description|
824e41f4b71Sopenharmony_ci| -------- | -------- |
825e41f4b71Sopenharmony_ci| attribute | Pointer to the sensor subscription attribute. |
826e41f4b71Sopenharmony_ci| samplingInterval | Pointer to the data reporting interval, in nanoseconds. |
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci**Returns**
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_ci### OH_SensorSubscriptionAttribute_SetSamplingInterval()
834e41f4b71Sopenharmony_ci
835e41f4b71Sopenharmony_ci```
836e41f4b71Sopenharmony_ciint32_t OH_SensorSubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, const int64_t samplingInterval)
837e41f4b71Sopenharmony_ci```
838e41f4b71Sopenharmony_ci**Description**
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ciSets the interval for reporting sensor data.
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci**Since**: 11
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci**Parameters**
845e41f4b71Sopenharmony_ci
846e41f4b71Sopenharmony_ci| Name| Description|
847e41f4b71Sopenharmony_ci| -------- | -------- |
848e41f4b71Sopenharmony_ci| attribute | Pointer to the sensor subscription attribute. |
849e41f4b71Sopenharmony_ci| samplingInterval | Data reporting interval to set, in nanoseconds. |
850e41f4b71Sopenharmony_ci
851e41f4b71Sopenharmony_ci**Returns**
852e41f4b71Sopenharmony_ci
853e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
854e41f4b71Sopenharmony_ci
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_ci### OH_SensorSubscriptionId_GetType()
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci```
859e41f4b71Sopenharmony_ciint32_t OH_SensorSubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type *sensorType)
860e41f4b71Sopenharmony_ci```
861e41f4b71Sopenharmony_ci**Description**
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ciObtains the sensor type.
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci**Since**: 11
866e41f4b71Sopenharmony_ci
867e41f4b71Sopenharmony_ci**Parameters**
868e41f4b71Sopenharmony_ci
869e41f4b71Sopenharmony_ci| Name| Description|
870e41f4b71Sopenharmony_ci| -------- | -------- |
871e41f4b71Sopenharmony_ci| id | Pointer to the sensor subscription ID. |
872e41f4b71Sopenharmony_ci| sensorType | Pointer to the sensor type. |
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ci**Returns**
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci
879e41f4b71Sopenharmony_ci### OH_SensorSubscriptionId_SetType()
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_ci```
882e41f4b71Sopenharmony_ciint32_t OH_SensorSubscriptionId_SetType(Sensor_SubscriptionId* id, const Sensor_Type sensorType)
883e41f4b71Sopenharmony_ci```
884e41f4b71Sopenharmony_ci**Description**
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ciSets the sensor type.
887e41f4b71Sopenharmony_ci
888e41f4b71Sopenharmony_ci**Since**: 11
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ci**Parameters**
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci| Name| Description|
893e41f4b71Sopenharmony_ci| -------- | -------- |
894e41f4b71Sopenharmony_ci| id | Pointer to the sensor subscription ID. |
895e41f4b71Sopenharmony_ci| sensorType | Sensor type to set. |
896e41f4b71Sopenharmony_ci
897e41f4b71Sopenharmony_ci**Returns**
898e41f4b71Sopenharmony_ci
899e41f4b71Sopenharmony_ciReturns **SENSOR_SUCCESS** if the operation is successful; returns an error code defined in [Sensor_Result](#sensor_result) otherwise.
900