From 2a7dc453e8123cd62a2b7d72276e076b35e98417 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 23 Nov 2023 08:59:36 +0000 Subject: [PATCH 01/33] update Signed-off-by: hellohyh001 Change-Id: If72571502880714d2073f871f6629518b225b337 --- sensors/sensor/sensor.h | 77 +++++++ sensors/sensor/sensor_type.h | 423 +++++++++++++++++++++++++++++++++++ 2 files changed, 500 insertions(+) create mode 100644 sensors/sensor/sensor.h create mode 100644 sensors/sensor/sensor_type.h diff --git a/sensors/sensor/sensor.h b/sensors/sensor/sensor.h new file mode 100644 index 00000000000..22dca26e7e7 --- /dev/null +++ b/sensors/sensor/sensor.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Sensor + * @{ + * + * @brief 为您提供标准的开放api,以使用传感器的常用功能。比如,您可以调用这些api来获取传感器属性信息、订阅或取消订阅传感器数据等。 + * @since 11 + */ +/** + * @file sensor.h + * + * @brief 声明操作传感器的常用api,用于获取传感器信息、订阅或取消订阅传感器数据等。 + * @library libohsensor.z.so + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + +#ifndef OH_SENSOR_H +#define OH_SENSOR_H + +#include "sensor_type.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief 获取设备上的所有传感器信息。 + * + * @param sensorInfo - 出参,返回设备上的所有传感器信息,详情请参见{@Link Sensor_SensorInfo}。 + * @param count - 出参,返回设备上的传感器数量。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * + * @since 11 + */ +Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, int32_t *count); + +/** + * @brief 订阅传感器数据,系统将按照用户指定的上报频率向用户报告传感器数据。 + * + * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SubscribeId}。 + * @param attribute - 订阅属性,可用于指定传感器的上报频率等,详情请参见{@Link Sensor_SubscribeAttribute}。 + * @param user - 订阅者信息,用于指定传感器数据回调函数等,详情请参见{@Link Sensor_SubscribeUser}。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * + * @since 11 + */ +Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SubscribeId *id, const Sensor_SubscribeAttribute *attribute, + const Sensor_SubscribeUser *user); + +/** + * @brief 取消订阅传感器数据。 + * + * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SubscribeId}。 + * @param user - 订阅者信息,用于指定传感器数据回调函数等,详情请参见{@Link Sensor_SubscribeUser}。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * + * @since 11 + */ +Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SubscribeId *subscribeId, const Sensor_SubscribeUser *user); +#ifdef __cplusplus +} +#endif +#endif // OH_SENSOR_H \ No newline at end of file diff --git a/sensors/sensor/sensor_type.h b/sensors/sensor/sensor_type.h new file mode 100644 index 00000000000..858b9777d74 --- /dev/null +++ b/sensors/sensor/sensor_type.h @@ -0,0 +1,423 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Sensor + * @{ + * + * @brief 为您提供标准的开放api,定义常用传感器属性。 + * + * @since 11 + */ + +/** + * @file sensor_type.h + * + * @brief 定义常用传感器属性。 + * @library libohsensor.z.so + * @syscap SystemCapability.Sensors.Sensor + * + * @since 11 + */ + +#ifndef OH_SENSOR_TYPE_H +#define OH_SENSOR_TYPE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 传感器类型。 + * @syscap SystemCapability.Sensors.Sensor + * + * @since 11 + */ +typedef enum Sensor_SensorType { + /** + * 加速度传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_ACCELEROMETER = 1, + /** + * 陀螺仪传感测器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_GYROSCOPE = 2, + /** + * 环境光传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_AMBIENT_LIGHT = 5, + /** + * 地磁传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_MAGNETIC_FIELD = 6, + /** + * 气压计传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_BAROMETER = 8, + /** + * 霍尔传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_HALL = 10, + /** + * 接近光传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_PROXIMITY = 12, + /** + * 方向传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_ORIENTATION = 256, + /** + * 重力传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_GRAVITY = 257, + /** + * 旋转矢量传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_ROTATION_VECTOR = 259, + /** + * 计步器检测传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_PEDOMETER_DETECTION = 265, + /** + * 计步器传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_PEDOMETER = 266, + /** + * 心率传感器 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_TYPE_HEART_RATE = 278, +} Sensor_SensorType; + +/** + * @brief 定义传感器错误码。 + * @syscap SystemCapability.Sensors.Sensor + * + * @since 11 + */ +typedef enum Sensor_Result { + /** + * 操作成功。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_SUCCESS = 0, + /** + * Permission verification failed. + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_PERMISSION_DENIED = 201, + /** + * Parameter check failed. For example, a mandatory parameter is not passed in, + * or the parameter type passed in is incorrect. + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_PARAMETER_ERROR = 401, + /** + * 传感器服务异常。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + SENSOR_SERVICE_EXCEPTION = 14500101, +} Sensor_Result; + +/** + * @brief 定义传感器错误码。 + * @syscap SystemCapability.Sensors.Sensor + * + * @since 11 + */ +typedef enum Sensor_SensorAccuracy { + /** + * The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure. + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + ACCURACY_UNRELIABLE = 0, + /** + * The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used. + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + ACCURACY_LOW = 1, + /** + * The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment before using it. + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + ACCURACY_MEDIUM = 2, + /** + * The sensor data is at a high accuracy level. The data can be used directly. + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + ACCURACY_HIGH = 3 +} Sensor_SensorAccuracy; + +struct Sensor_Sensor; +/** + * @brief 传感器信息。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ +typedef struct Sensor_Sensor Sensor_Sensor; + +/** + * @brief 获取传感器名称. + * + * @param sensor - 传感器信息. + * @param sensorName - 出参,传感器名称. + * @param length - 出参,字节数. + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorName(Sensor_Sensor* sensor, char *sensorName, size_t *length); + +/** + * @brief 获取传感器厂商. + * + * @param sensor - 传感器信息. + * @param vendorName - 出参,厂商名称. + * @param length - 出参,字节数. + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetVendorName(Sensor_Sensor* sensor, char *vendorName, size_t *length); + +/** + * @brief 获取传感器类型。 + * + * @param sensor - 传感器信息。 + * @param sensorType - 出参,传感器类型。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorType(Sensor_Sensor* sensor, Sensor_SensorType *sensorType); + +/** + * @brief 获取传感器分辨率。 + * + * @param sensor - 传感器信息。 + * @param resolution - 出参,传感器分辨率。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, float *resolution); + +/** + * @brief 获取传感器最小上报时间间隔。 + * + * @param sensor - 传感器信息。 + * @param minSamplePeriod - 出参,传感器最小上报时间间隔。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, int64_t *minSamplePeriod); + +/** + * @brief 获取传感器最大上报时间间隔。 + * + * @param sensor - 传感器信息。 + * @param maxSamplePeriod - 出参,传感器最大上报时间间隔。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, int64_t *maxSamplePeriod); + +struct Sensor_SensorEvent; +/** + * @brief 传感器数据。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ +typedef struct Sensor_SensorEvent Sensor_SensorEvent; + +/** + * @brief 获取传感器类型。 + * + * @param sensor - 传感器信息。 + * @param sensorType - 出参,传感器类型。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorType(Sensor_SensorEvent* sensorEvent, Sensor_SensorType *sensorType); + +/** + * @brief 获取时间戳。 + * + * @param sensor - 传感器信息。 + * @param timestamp - 出参,时间戳。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorTimestamp(Sensor_SensorEvent* sensorEvent, int64_t *timestamp); + +/** + * @brief 获取传感器数据精度。 + * + * @param sensor - 传感器信息。 + * @param accuracy - 出参,传感器数据精度。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_SensorAccuracy *accuracy); + +/** + * @brief 获取传感器数据。数据的长度和内容依赖于监听的传感器类型,如下: + * SENSOR_TYPE_ACCELEROMETER: data[0]、data[1]、data[2]分别表示设备x、y、z轴的加速度分量,单位m/s2; + * SENSOR_TYPE_GYROSCOPE: data[0]、data[1]、data[2]分别表示设备x、y、z轴的旋转角速度,单位弧度/s; + * SENSOR_TYPE_AMBIENT_LIGHT: data[0]表示环境光强度,in lux; + * SENSOR_TYPE_MAGNETIC_FIELD: data[0]、data[1]、data[2]分别表示设备x、y、z轴的地磁分量,单位微特斯拉; + * SENSOR_TYPE_BAROMETER:data[0]表示气压值,单位hPa; + * SENSOR_TYPE_HALL: data[0]表示皮套吸合状态,0表示打开,大于0表示吸附; + * SENSOR_TYPE_PROXIMITY:data[0]表示接近状态,0表示接近,大于0表示远离; + * SENSOR_TYPE_ORIENTATION:data[0]、data[1]、data[2]分别表示设备绕z、x、y轴的角度,单位度; + * SENSOR_TYPE_GRAVITY:data[0]、data[1]、data[2]分别表示设备x、y、z轴的重力加速度分量,单位m/s2; + * SENSOR_TYPE_ROTATION_VECTOR:data[0]、data[1]、data[2]分别表示设备x、y、z轴的旋转角度,单位度,data[3]表示旋转向量元素; + * SENSOR_TYPE_PEDOMETER_DETECTION:data[0]表示几步检测状态,1表示检测到了步数变化 + * SENSOR_TYPE_PEDOMETER:data[0]表示步数; + * SENSOR_TYPE_HEART_RATE:data[0]表示心率数值; + * + * @param sensor - 传感器信息。 + * @param data - 出参,传感器数据数据。 + * @param length - 出参,数组长度。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, size_t *length); + +struct Sensor_SensorSubscribeId; +/** + * @brief 传感器数据。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ +typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; + +/** + * @brief 获取传感器类型。 + * + * @param sensor - 传感器信息。 + * @param sensorType - 出参,传感器类型。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSensorType(Sensor_SensorSubscribeId* subscribeId, Sensor_SensorType *sensorType); + +/** + * @brief 设置传感器类型。 + * + * @param sensor - 传感器信息。 + * @param sensorType - 传感器类型。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_SetSensorType(Sensor_SensorSubscribeId* subscribeId, const Sensor_SensorType sensorType); + +struct Sensor_SubscribeAttribute; +/** + * @brief 订阅属性。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ +typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; + +/** + * @brief 设置上报时间间隔。 + * + * @param attribute - 订阅属性。 + * @param samplingInterval - 上报时间间隔,单位ns。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscribeAttribute* attribute, const int64_t samplingInterval); + +/** + * @brief 获取上报时间间隔。 + * + * @param attribute - 订阅属性。 + * @param samplingInterval - 出参,上报时间间隔,单位ns。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscribeAttribute* attribute, int64_t *samplingInterval); + +/** + * @brief 传感器数据的回调函数。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ +typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); + +struct Sensor_SubscribeUser; +/** + * @brief 订阅者信息。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ +typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; + +/** + * @brief 设置传感器数据的回调函数。 + * + * @param user - 订阅者信息。 + * @param callback - 传感器数据的回调函数。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_SetSensorCallback(Sensor_SubscribeUser* user, const Sensor_RecordSensorCallback callback); + +/** + * @brief 获取传感器数据的回调函数。 + * + * @param user - 订阅者信息。 + * @param callback - 出参,传感器数据的回调函数。 + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscribeAttribute* attribute, Sensor_RecordSensorCallback *callback); +#ifdef __cplusplus +} +#endif +#endif // OH_SENSOR_H \ No newline at end of file -- Gitee From f3827ada897c5e4c0d3b55bfdf7c6d101adccf72 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 23 Nov 2023 09:22:30 +0000 Subject: [PATCH 02/33] update Signed-off-by: hellohyh001 Change-Id: I8241831f5f75f7742b8e97b64c2634463c421d04 --- sensors/sensor/BUILD.gn | 30 ++++++++++++++++ sensors/sensor/libsensor.ndk.json | 11 ++++++ sensors/sensor/sensor.h | 2 +- sensors/sensor/sensor_type.h | 58 +++++++++++++++---------------- 4 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 sensors/sensor/BUILD.gn create mode 100644 sensors/sensor/libsensor.ndk.json diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn new file mode 100644 index 00000000000..5b6564b228a --- /dev/null +++ b/sensors/sensor/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("oh_sensor_header") { + dest_dir = "$ndk_headers_out_dir/sensors/sensor" + sources = [ + "./sensor.h", + ".sensor_type.h", + ] +} + +ohos_ndk_library("libsensor_capi_ndk") { + ndk_description_file = "./libsensor.ndk.json" + output_name = "ohsensor" + output_extension = "z.so" + min_compact_version = "11" +} \ No newline at end of file diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json new file mode 100644 index 00000000000..27cc792afab --- /dev/null +++ b/sensors/sensor/libsensor.ndk.json @@ -0,0 +1,11 @@ +[ + { + "name": "OH_Sensor_GetAllSensors" + }, + { + "name": "OH_Sensor_SubscribeSensor" + }, + { + "name": "OH_Sensor_UnsubscribeSensor" + } +] \ No newline at end of file diff --git a/sensors/sensor/sensor.h b/sensors/sensor/sensor.h index 22dca26e7e7..e8557d2b2ee 100644 --- a/sensors/sensor/sensor.h +++ b/sensors/sensor/sensor.h @@ -40,7 +40,7 @@ extern "C" { /** * @brief 获取设备上的所有传感器信息。 * - * @param sensorInfo - 出参,返回设备上的所有传感器信息,详情请参见{@Link Sensor_SensorInfo}。 + * @param sensorInfo - 出参,返回设备上的所有传感器信息,详情请参见{@Link Sensor_Sensor}。 * @param count - 出参,返回设备上的传感器数量。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * diff --git a/sensors/sensor/sensor_type.h b/sensors/sensor/sensor_type.h index 858b9777d74..996cd538416 100644 --- a/sensors/sensor/sensor_type.h +++ b/sensors/sensor/sensor_type.h @@ -163,7 +163,7 @@ typedef enum Sensor_Result { } Sensor_Result; /** - * @brief 定义传感器错误码。 + * @brief Enumerates the accuracy levels of data reported by a sensor. * @syscap SystemCapability.Sensors.Sensor * * @since 11 @@ -215,7 +215,7 @@ typedef struct Sensor_Sensor Sensor_Sensor; int32_t OH_Sensor_GetSensorName(Sensor_Sensor* sensor, char *sensorName, size_t *length); /** - * @brief 获取传感器厂商. + * @brief 获取传感器厂商名称. * * @param sensor - 传感器信息. * @param vendorName - 出参,厂商名称. @@ -249,25 +249,25 @@ int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, float *resolution); * @brief 获取传感器最小上报时间间隔。 * * @param sensor - 传感器信息。 - * @param minSamplePeriod - 出参,传感器最小上报时间间隔。 + * @param minSamplePeriod - 出参,传感器最小上报时间间隔,单位纳秒。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, int64_t *minSamplePeriod); +int32_t OH_Sensor_GetSensorMinSamplePeriod(Sensor_Sensor* sensor, int64_t *minSamplePeriod); /** * @brief 获取传感器最大上报时间间隔。 * * @param sensor - 传感器信息。 - * @param maxSamplePeriod - 出参,传感器最大上报时间间隔。 + * @param maxSamplePeriod - 出参,传感器最大上报时间间隔,单位纳秒。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, int64_t *maxSamplePeriod); +int32_t OH_Sensor_GetSensorMaxSamplePeriod(Sensor_Sensor* sensor, int64_t *maxSamplePeriod); struct Sensor_SensorEvent; /** - * @brief 传感器数据。 + * @brief 传感器数据信息。 * @syscap SystemCapability.Sensors.Sensor * @since 11 */ @@ -276,35 +276,35 @@ typedef struct Sensor_SensorEvent Sensor_SensorEvent; /** * @brief 获取传感器类型。 * - * @param sensor - 传感器信息。 + * @param sensor - 传感器数据信息。 * @param sensorType - 出参,传感器类型。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSensorType(Sensor_SensorEvent* sensorEvent, Sensor_SensorType *sensorType); +int32_t OH_Sensor_GetEventSensorType(Sensor_SensorEvent* sensorEvent, Sensor_SensorType *sensorType); /** * @brief 获取时间戳。 * - * @param sensor - 传感器信息。 + * @param sensor - 传感器数据信息。 * @param timestamp - 出参,时间戳。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSensorTimestamp(Sensor_SensorEvent* sensorEvent, int64_t *timestamp); +int32_t OH_Sensor_GetEventTimestamp(Sensor_SensorEvent* sensorEvent, int64_t *timestamp); /** * @brief 获取传感器数据精度。 * - * @param sensor - 传感器信息。 + * @param sensor - 传感器数据信息。 * @param accuracy - 出参,传感器数据精度。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSensorAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_SensorAccuracy *accuracy); +int32_t OH_Sensor_GetEventAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_SensorAccuracy *accuracy); /** - * @brief 获取传感器数据。数据的长度和内容依赖于监听的传感器类型,如下: + * @brief 获取传感器数据。数据的长度和内容依赖于监听的传感器类型,传感器上报的数据格式如下: * SENSOR_TYPE_ACCELEROMETER: data[0]、data[1]、data[2]分别表示设备x、y、z轴的加速度分量,单位m/s2; * SENSOR_TYPE_GYROSCOPE: data[0]、data[1]、data[2]分别表示设备x、y、z轴的旋转角速度,单位弧度/s; * SENSOR_TYPE_AMBIENT_LIGHT: data[0]表示环境光强度,in lux; @@ -319,8 +319,8 @@ int32_t OH_Sensor_GetSensorAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_Sens * SENSOR_TYPE_PEDOMETER:data[0]表示步数; * SENSOR_TYPE_HEART_RATE:data[0]表示心率数值; * - * @param sensor - 传感器信息。 - * @param data - 出参,传感器数据数据。 + * @param sensor - 传感器数据信息。 + * @param data - 出参,传感器数据。 * @param length - 出参,数组长度。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 @@ -329,7 +329,7 @@ int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, s struct Sensor_SensorSubscribeId; /** - * @brief 传感器数据。 + * @brief 传感器订阅Id,唯一标识传感器。 * @syscap SystemCapability.Sensors.Sensor * @since 11 */ @@ -338,26 +338,26 @@ typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; /** * @brief 获取传感器类型。 * - * @param sensor - 传感器信息。 + * @param subscribeId - 传感器订阅Id。 * @param sensorType - 出参,传感器类型。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSensorType(Sensor_SensorSubscribeId* subscribeId, Sensor_SensorType *sensorType); +int32_t OH_Sensor_GetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, Sensor_SensorType *sensorType); /** * @brief 设置传感器类型。 * - * @param sensor - 传感器信息。 + * @param subscribeId - 传感器订阅Id。 * @param sensorType - 传感器类型。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_SetSensorType(Sensor_SensorSubscribeId* subscribeId, const Sensor_SensorType sensorType); +int32_t OH_Sensor_SetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, const Sensor_SensorType sensorType); struct Sensor_SubscribeAttribute; /** - * @brief 订阅属性。 + * @brief 传感器订阅属性。 * @syscap SystemCapability.Sensors.Sensor * @since 11 */ @@ -366,7 +366,7 @@ typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; /** * @brief 设置上报时间间隔。 * - * @param attribute - 订阅属性。 + * @param attribute - 传感器订阅属性。 * @param samplingInterval - 上报时间间隔,单位ns。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 @@ -376,7 +376,7 @@ int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscribeAttribute* attribute, cons /** * @brief 获取上报时间间隔。 * - * @param attribute - 订阅属性。 + * @param attribute - 传感器订阅属性。 * @param samplingInterval - 出参,上报时间间隔,单位ns。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 @@ -392,7 +392,7 @@ typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); struct Sensor_SubscribeUser; /** - * @brief 订阅者信息。 + * @brief 传感器订阅者信息。 * @syscap SystemCapability.Sensors.Sensor * @since 11 */ @@ -401,7 +401,7 @@ typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; /** * @brief 设置传感器数据的回调函数。 * - * @param user - 订阅者信息。 + * @param user - 传感器订阅者信息。 * @param callback - 传感器数据的回调函数。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 @@ -411,13 +411,13 @@ int32_t OH_Sensor_SetSensorCallback(Sensor_SubscribeUser* user, const Sensor_Rec /** * @brief 获取传感器数据的回调函数。 * - * @param user - 订阅者信息。 + * @param user - 传感器订阅者信息。 * @param callback - 出参,传感器数据的回调函数。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscribeAttribute* attribute, Sensor_RecordSensorCallback *callback); +int32_t OH_Sensor_GetSensorCallback(Sensor_SubscribeAttribute* attribute, Sensor_RecordSensorCallback *callback); #ifdef __cplusplus } #endif -#endif // OH_SENSOR_H \ No newline at end of file +#endif // OH_SENSOR_TYPE_H \ No newline at end of file -- Gitee From 045d206f49559214e7149af0a9e8840205f22be5 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 23 Nov 2023 09:26:20 +0000 Subject: [PATCH 03/33] update Signed-off-by: hellohyh001 Change-Id: Ic18366bffe0e55fbc7ebbb4b9e0a79f2e03ba6ec --- sensors/sensor/libsensor.ndk.json | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json index 27cc792afab..bed08e402f3 100644 --- a/sensors/sensor/libsensor.ndk.json +++ b/sensors/sensor/libsensor.ndk.json @@ -7,5 +7,53 @@ }, { "name": "OH_Sensor_UnsubscribeSensor" + }, + { + "name": "OH_Sensor_GetSensorName" + }, + { + "name": "OH_Sensor_GetVendorName" + }, + { + "name": "OH_Sensor_GetSensorType" + }, + { + "name": "OH_Sensor_GetSensorResolution" + }, + { + "name": "OH_Sensor_GetSensorMinSamplePeriod" + }, + { + "name": "OH_Sensor_GetSensorMaxSamplePeriod" + }, + { + "name": "OH_Sensor_GetEventSensorType" + }, + { + "name": "OH_Sensor_GetEventTimestamp" + }, + { + "name": "OH_Sensor_GetEventAccuracy" + }, + { + "name": "OH_Sensor_GetSensorData" + }, + { + "name": "OH_Sensor_GetSubscribeSensorType" + }, + { + "name": "OH_Sensor_SetSubscribeSensorType" + }, + { + "name": "OH_Sensor_SetSamplingInterval" + }, + { + "name": "OH_Sensor_GetSamplingInterval" + }, + { + "name": "OH_Sensor_SetSensorCallback" + }, + { + "name": "OH_Sensor_GetSensorCallback" } ] \ No newline at end of file -- Gitee From 867aa96ee91c085e732509149270c194c24d0723 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 23 Nov 2023 11:37:51 +0000 Subject: [PATCH 04/33] update Signed-off-by: hellohyh001 Change-Id: Iad5718e7142fe148acd4a8f6e6fe19f94fc68851 --- sensors/sensor/BUILD.gn | 4 ++-- sensors/sensor/{sensor.h => native_sensor.h} | 6 +++--- sensors/sensor/{sensor_type.h => native_sensor_type.h} | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename sensors/sensor/{sensor.h => native_sensor.h} (97%) rename sensors/sensor/{sensor_type.h => native_sensor_type.h} (99%) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index 5b6564b228a..cd0a3387064 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -17,8 +17,8 @@ import("//build/ohos/ndk/ndk.gni") ohos_ndk_headers("oh_sensor_header") { dest_dir = "$ndk_headers_out_dir/sensors/sensor" sources = [ - "./sensor.h", - ".sensor_type.h", + "./native_sensor.h", + "./native_sensor_type.h", ] } diff --git a/sensors/sensor/sensor.h b/sensors/sensor/native_sensor.h similarity index 97% rename from sensors/sensor/sensor.h rename to sensors/sensor/native_sensor.h index e8557d2b2ee..28be00071f8 100644 --- a/sensors/sensor/sensor.h +++ b/sensors/sensor/native_sensor.h @@ -29,8 +29,8 @@ * @since 11 */ -#ifndef OH_SENSOR_H -#define OH_SENSOR_H +#ifndef OH_NATIVE_SENSOR_H +#define OH_NATIVE_SENSOR_H #include "sensor_type.h" @@ -74,4 +74,4 @@ Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SubscribeId *subscribeId, #ifdef __cplusplus } #endif -#endif // OH_SENSOR_H \ No newline at end of file +#endif // OH_NATIVE_SENSOR_H \ No newline at end of file diff --git a/sensors/sensor/sensor_type.h b/sensors/sensor/native_sensor_type.h similarity index 99% rename from sensors/sensor/sensor_type.h rename to sensors/sensor/native_sensor_type.h index 996cd538416..01f3a519ab5 100644 --- a/sensors/sensor/sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -32,8 +32,8 @@ * @since 11 */ -#ifndef OH_SENSOR_TYPE_H -#define OH_SENSOR_TYPE_H +#ifndef OH_NATIVE_SENSOR_TYPE_H +#define OH_NATIVE_SENSOR_TYPE_H #include @@ -420,4 +420,4 @@ int32_t OH_Sensor_GetSensorCallback(Sensor_SubscribeAttribute* attribute, Sensor #ifdef __cplusplus } #endif -#endif // OH_SENSOR_TYPE_H \ No newline at end of file +#endif // OH_NATIVE_SENSOR_TYPE_H \ No newline at end of file -- Gitee From 76c05897abc16d3c05059723580248f3c24a34db Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 23 Nov 2023 14:10:04 +0000 Subject: [PATCH 05/33] update Signed-off-by: hellohyh001 Change-Id: I6746a71899a5d5c5c18355bcb082633853c3858b --- sensors/sensor/BUILD.gn | 6 +++--- sensors/sensor/native_sensor.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index cd0a3387064..547484116aa 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("oh_sensor_header") { +ohos_ndk_headers("sensor_native") { dest_dir = "$ndk_headers_out_dir/sensors/sensor" sources = [ "./native_sensor.h", @@ -22,9 +22,9 @@ ohos_ndk_headers("oh_sensor_header") { ] } -ohos_ndk_library("libsensor_capi_ndk") { +ohos_ndk_library("libsensor_native") { ndk_description_file = "./libsensor.ndk.json" - output_name = "ohsensor" + output_name = "libsensor_native" output_extension = "z.so" min_compact_version = "11" } \ No newline at end of file diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index 28be00071f8..16c874a619a 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -24,7 +24,7 @@ * @file sensor.h * * @brief 声明操作传感器的常用api,用于获取传感器信息、订阅或取消订阅传感器数据等。 - * @library libohsensor.z.so + * @library libsensor_native.z.so * @syscap SystemCapability.Sensors.Sensor * @since 11 */ -- Gitee From 08c6b7b801695dc887605328182f2ff7f3b9413c Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 23 Nov 2023 14:29:57 +0000 Subject: [PATCH 06/33] update Signed-off-by: hellohyh001 Change-Id: I205c3511883978251c8c91e409853f2912aa14ee --- sensors/sensor/native_sensor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index 16c874a619a..ebb6eaed941 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -21,7 +21,7 @@ * @since 11 */ /** - * @file sensor.h + * @file native_sensor.h * * @brief 声明操作传感器的常用api,用于获取传感器信息、订阅或取消订阅传感器数据等。 * @library libsensor_native.z.so @@ -32,7 +32,7 @@ #ifndef OH_NATIVE_SENSOR_H #define OH_NATIVE_SENSOR_H -#include "sensor_type.h" +#include "native_sensor_type.h" #ifdef __cplusplus extern "C" { -- Gitee From e98a06d225a4ca0aae646a4d6c571a1a8263c6ea Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 23 Nov 2023 14:31:44 +0000 Subject: [PATCH 07/33] update Signed-off-by: hellohyh001 Change-Id: Id419d1765c4fc2c5f1817ad4773b3ce4ca24d443 --- sensors/sensor/native_sensor_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 01f3a519ab5..b8b1aaf9189 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -23,7 +23,7 @@ */ /** - * @file sensor_type.h + * @file native_sensor_type.h * * @brief 定义常用传感器属性。 * @library libohsensor.z.so -- Gitee From c7361e8dbd8a55fbfcd3130a62b114c39d9faaec Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Sat, 25 Nov 2023 02:08:00 +0000 Subject: [PATCH 08/33] update Signed-off-by: hellohyh001 Change-Id: I149717972e189a2d198a4d0417b0e3a24f04ce37 --- sensors/sensor/native_sensor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index ebb6eaed941..d25d03db9aa 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -51,26 +51,26 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, int32_t *count); /** * @brief 订阅传感器数据,系统将按照用户指定的上报频率向用户报告传感器数据。 * - * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SubscribeId}。 + * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SensorSubscribeId}。 * @param attribute - 订阅属性,可用于指定传感器的上报频率等,详情请参见{@Link Sensor_SubscribeAttribute}。 * @param user - 订阅者信息,用于指定传感器数据回调函数等,详情请参见{@Link Sensor_SubscribeUser}。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * * @since 11 */ -Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SubscribeId *id, const Sensor_SubscribeAttribute *attribute, +Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscribeId *id, const Sensor_SubscribeAttribute *attribute, const Sensor_SubscribeUser *user); /** * @brief 取消订阅传感器数据。 * - * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SubscribeId}。 + * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SensorSubscribeId}。 * @param user - 订阅者信息,用于指定传感器数据回调函数等,详情请参见{@Link Sensor_SubscribeUser}。 * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * * @since 11 */ -Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SubscribeId *subscribeId, const Sensor_SubscribeUser *user); +Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SensorSubscribeId *subscribeId, const Sensor_SubscribeUser *user); #ifdef __cplusplus } #endif -- Gitee From 7fee9df93e61f57213dca486a8437dd57f08878e Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Sat, 25 Nov 2023 07:14:05 +0000 Subject: [PATCH 09/33] update Signed-off-by: hellohyh001 Change-Id: I3af2352c4bb26481702422df745705c42a058516 --- sensors/sensor/native_sensor_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index b8b1aaf9189..577befe51b2 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -416,7 +416,7 @@ int32_t OH_Sensor_SetSensorCallback(Sensor_SubscribeUser* user, const Sensor_Rec * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 * @since 11 */ -int32_t OH_Sensor_GetSensorCallback(Sensor_SubscribeAttribute* attribute, Sensor_RecordSensorCallback *callback); +int32_t OH_Sensor_GetSensorCallback(Sensor_SubscribeUser* user, Sensor_RecordSensorCallback *callback); #ifdef __cplusplus } #endif -- Gitee From 738fdb55d88a5eb8f1a8cffc9d97445e2ad3e568 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Mon, 27 Nov 2023 03:53:07 +0000 Subject: [PATCH 10/33] upate Signed-off-by: hellohyh001 Change-Id: I45360777211dcb636544044ddd8b42d742ba8407 --- sensors/sensor/native_sensor_type.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 577befe51b2..b96256a9862 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -174,25 +174,25 @@ typedef enum Sensor_SensorAccuracy { * @syscap SystemCapability.Sensors.Sensor * @since 11 */ - ACCURACY_UNRELIABLE = 0, + SENSOR_ACCURACY_UNRELIABLE = 0, /** * The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used. * @syscap SystemCapability.Sensors.Sensor * @since 11 */ - ACCURACY_LOW = 1, + SENSOR_ACCURACY_LOW = 1, /** * The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment before using it. * @syscap SystemCapability.Sensors.Sensor * @since 11 */ - ACCURACY_MEDIUM = 2, + SENSOR_ACCURACY_MEDIUM = 2, /** * The sensor data is at a high accuracy level. The data can be used directly. * @syscap SystemCapability.Sensors.Sensor * @since 11 */ - ACCURACY_HIGH = 3 + SENSOR_ACCURACY_HIGH = 3 } Sensor_SensorAccuracy; struct Sensor_Sensor; -- Gitee From 34f2a3383eb0ec9211349cdf0f8b3cb488e03f19 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Mon, 27 Nov 2023 13:23:06 +0000 Subject: [PATCH 11/33] update Signed-off-by: hellohyh001 Change-Id: I2bc1950f08460915ad37db2880af7fc1fd39176d --- sensors/sensor/BUILD.gn | 4 ++-- sensors/sensor/native_sensor_type.h | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index 547484116aa..1eba42e25b2 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -14,7 +14,7 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("sensor_native") { +ohos_ndk_headers("sensor_ndk_header") { dest_dir = "$ndk_headers_out_dir/sensors/sensor" sources = [ "./native_sensor.h", @@ -22,7 +22,7 @@ ohos_ndk_headers("sensor_native") { ] } -ohos_ndk_library("libsensor_native") { +ohos_ndk_library("libsensor_ndk") { ndk_description_file = "./libsensor.ndk.json" output_name = "libsensor_native" output_extension = "z.so" diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index b96256a9862..9a131f7df4a 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -327,7 +327,6 @@ int32_t OH_Sensor_GetEventAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_Senso */ int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, size_t *length); -struct Sensor_SensorSubscribeId; /** * @brief 传感器订阅Id,唯一标识传感器。 * @syscap SystemCapability.Sensors.Sensor @@ -335,6 +334,14 @@ struct Sensor_SensorSubscribeId; */ typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; +/** + * @brief 创建传感器订阅Id实例。 + * + * @return 如果创建成功,则返回指向{@link Sensor_SensorSubscribeId} 结构实例的指针,否则返回NULL. + * @since 11 + */ +Sensor_SensorSubscribeId *OH_Sensor_CreateSubscribeId(); + /** * @brief 获取传感器类型。 * @@ -355,7 +362,6 @@ int32_t OH_Sensor_GetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, */ int32_t OH_Sensor_SetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, const Sensor_SensorType sensorType); -struct Sensor_SubscribeAttribute; /** * @brief 传感器订阅属性。 * @syscap SystemCapability.Sensors.Sensor @@ -363,6 +369,14 @@ struct Sensor_SubscribeAttribute; */ typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; +/** + * @brief 创建传感器订阅属性实例。 + * + * @return 如果创建成功,则返回指向{@link Sensor_SubscribeAttribute} 结构实例的指针,否则返回NULL. + * @since 11 + */ +Sensor_SubscribeAttribute *OH_Sensor_CreateAttribute(); + /** * @brief 设置上报时间间隔。 * @@ -390,7 +404,6 @@ int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscribeAttribute* attribute, int6 */ typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); -struct Sensor_SubscribeUser; /** * @brief 传感器订阅者信息。 * @syscap SystemCapability.Sensors.Sensor @@ -398,6 +411,14 @@ struct Sensor_SubscribeUser; */ typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; +/** + * @brief 传感器订阅者实例。 + * + * @return 如果创建成功,则返回指向{@link Sensor_SubscribeUser} 结构实例的指针,否则返回NULL. + * @since 11 + */ +Sensor_SubscribeUser *OH_Sensor_CreateUser(); + /** * @brief 设置传感器数据的回调函数。 * -- Gitee From fe6ab3d6058550e2c48ba1b06b23599bb0b74dba Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Mon, 27 Nov 2023 13:37:40 +0000 Subject: [PATCH 12/33] update Signed-off-by: hellohyh001 Change-Id: I11180e86f20ab0265b0407d8afa52a7b52ce8b30 --- sensors/sensor/native_sensor_type.h | 33 ++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 9a131f7df4a..d6fb4ef5d56 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -335,13 +335,22 @@ int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, s typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; /** - * @brief 创建传感器订阅Id实例。 + * @brief 创建指向{@link Sensor_SensorSubscribeId}实例的指针。 * * @return 如果创建成功,则返回指向{@link Sensor_SensorSubscribeId} 结构实例的指针,否则返回NULL. * @since 11 */ Sensor_SensorSubscribeId *OH_Sensor_CreateSubscribeId(); +/** + * @brief 销毁{@link Sensor_SensorSubscribeId}实例并回收内存。 + * + * @param subscribeId - 表示指向 {@link Sensor_SensorSubscribeId} 实例的指针. + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_DestroySubscribeId(Sensor_SensorSubscribeId *subscribeId); + /** * @brief 获取传感器类型。 * @@ -370,13 +379,22 @@ int32_t OH_Sensor_SetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; /** - * @brief 创建传感器订阅属性实例。 + * @brief 创建指向{@link Sensor_SubscribeAttribute}实例的指针。 * * @return 如果创建成功,则返回指向{@link Sensor_SubscribeAttribute} 结构实例的指针,否则返回NULL. * @since 11 */ Sensor_SubscribeAttribute *OH_Sensor_CreateAttribute(); +/** + * @brief 销毁{@link Sensor_SubscribeAttribute}实例并回收内存。 + * + * @param attribute - 表示指向 {@link Sensor_SubscribeAttribute} 实例的指针. + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_DestroyAttribute(Sensor_SubscribeAttribute *attribute); + /** * @brief 设置上报时间间隔。 * @@ -412,13 +430,22 @@ typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; /** - * @brief 传感器订阅者实例。 + * @brief 创建指向{@link Sensor_SubscribeUser}实例的指针。 * * @return 如果创建成功,则返回指向{@link Sensor_SubscribeUser} 结构实例的指针,否则返回NULL. * @since 11 */ Sensor_SubscribeUser *OH_Sensor_CreateUser(); +/** + * @brief 销毁{@link Sensor_SubscribeUser}实例并回收内存。 + * + * @param user - 表示指向{@link Sensor_SubscribeUser}实例的指针. + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_DestroyUser(Sensor_SubscribeUser *user); + /** * @brief 设置传感器数据的回调函数。 * -- Gitee From f6a1e42c98d4b9f74123641e492fcb7821bb9112 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 28 Nov 2023 06:56:05 +0000 Subject: [PATCH 13/33] update Signed-off-by: hellohyh001 Change-Id: Iae4993f0fe31e7397122012730750026203d23e4 --- sensors/sensor/native_sensor_type.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index d6fb4ef5d56..9e86f4a9ce5 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -195,7 +195,6 @@ typedef enum Sensor_SensorAccuracy { SENSOR_ACCURACY_HIGH = 3 } Sensor_SensorAccuracy; -struct Sensor_Sensor; /** * @brief 传感器信息。 * @syscap SystemCapability.Sensors.Sensor @@ -203,6 +202,25 @@ struct Sensor_Sensor; */ typedef struct Sensor_Sensor Sensor_Sensor; +/** + * @brief 创建给定个数{@link Sensor_Sensor}实例的数组。 + * + * @param count - 表示要创建{@link Sensor_Sensor}实例的个数. + * @return 如果创建成功,则返回{@link Sensor_Sensor}实例的数组,否则返回 NULL。。 + * @since 11 + */ +Sensor_Sensor **OH_Sensor_CreateSensors(uint32_t count); + +/** + * @brief 销毁{@link Sensor_Sensor}实例的数组并回收内存。 + * + * @param sensors - 表示要销毁的{@link Sensor_Sensor}实例的数组. + * @param count - 表示要销毁的{@link Sensor_Sensor}实例的个数. + * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @since 11 + */ +int32_t OH_Sensor_DestroySensors(Sensor_Sensor **sensors, uint32_t count); + /** * @brief 获取传感器名称. * @@ -265,7 +283,6 @@ int32_t OH_Sensor_GetSensorMinSamplePeriod(Sensor_Sensor* sensor, int64_t *minSa */ int32_t OH_Sensor_GetSensorMaxSamplePeriod(Sensor_Sensor* sensor, int64_t *maxSamplePeriod); -struct Sensor_SensorEvent; /** * @brief 传感器数据信息。 * @syscap SystemCapability.Sensors.Sensor -- Gitee From 67805181489bdde16dcd186c0afbc751b03717cf Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 28 Nov 2023 07:44:02 +0000 Subject: [PATCH 14/33] update Signed-off-by: hellohyh001 Change-Id: I5224970157ed8338776d22fa92f5043702cf5fbc --- sensors/sensor/libsensor.ndk.json | 24 +++ sensors/sensor/native_sensor.h | 41 ++-- sensors/sensor/native_sensor_type.h | 279 ++++++++++++++-------------- 3 files changed, 186 insertions(+), 158 deletions(-) diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json index bed08e402f3..98f99149ab4 100644 --- a/sensors/sensor/libsensor.ndk.json +++ b/sensors/sensor/libsensor.ndk.json @@ -55,5 +55,29 @@ }, { "name": "OH_Sensor_GetSensorCallback" + }, + { + "name": "OH_Sensor_CreateSensors" + }, + { + "name": "OH_Sensor_DestroySensors" + }, + { + "name": "OH_Sensor_CreateSubscribeId" + }, + { + "name": "OH_Sensor_DestroySubscribeId" + }, + { + "name": "OH_Sensor_CreateAttribute" + }, + { + "name": "OH_Sensor_DestroyAttribute" + }, + { + "name": "OH_Sensor_CreateUser" + }, + { + "name": "OH_Sensor_DestroyUser" } ] \ No newline at end of file diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index d25d03db9aa..0850a15e1d4 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -17,13 +17,15 @@ * @addtogroup Sensor * @{ * - * @brief 为您提供标准的开放api,以使用传感器的常用功能。比如,您可以调用这些api来获取传感器属性信息、订阅或取消订阅传感器数据等。 + * @brief Provides APIs to use common sensor features. For example, you can call the APIs to obtain sensor information + * and subscribe to or unsubscribe from sensor data. * @since 11 */ /** * @file native_sensor.h * - * @brief 声明操作传感器的常用api,用于获取传感器信息、订阅或取消订阅传感器数据等。 + * @brief Declares the APIs for operating sensors, including obtaining sensor information and subscribing to or + * unsubscribing from sensor data. * @library libsensor_native.z.so * @syscap SystemCapability.Sensors.Sensor * @since 11 @@ -38,23 +40,28 @@ extern "C" { #endif /** - * @brief 获取设备上的所有传感器信息。 + * @brief Obtains information about all sensors on the device. * - * @param sensorInfo - 出参,返回设备上的所有传感器信息,详情请参见{@Link Sensor_Sensor}。 - * @param count - 出参,返回设备上的传感器数量。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensors - Double pointer to the information about all sensors on the device. + * For details, see {@link Sensor_Sensor}. + * @param count - Pointer to the number of sensors on the device. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * * @since 11 */ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, int32_t *count); /** - * @brief 订阅传感器数据,系统将按照用户指定的上报频率向用户报告传感器数据。 + * @brief Subscribes to sensor data. The system will report sensor data to the subscriber at the specified frequency. * - * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SensorSubscribeId}。 - * @param attribute - 订阅属性,可用于指定传感器的上报频率等,详情请参见{@Link Sensor_SubscribeAttribute}。 - * @param user - 订阅者信息,用于指定传感器数据回调函数等,详情请参见{@Link Sensor_SubscribeUser}。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscribeId}. + * @param attribute - Pointer to the subscription attribute, which is used to specify the data reporting frequency. + * For details, see {@link Sensor_SubscribeAttribute}. + * @param user - Pointer to the subscriber information, which is used to specify the callback function for reporting + * the sensor data. For details, see {@link Sensor_SubscribeUser}. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * * @since 11 */ @@ -62,15 +69,17 @@ Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscribeId *id, cons const Sensor_SubscribeUser *user); /** - * @brief 取消订阅传感器数据。 + * @brief Unsubscribes from sensor data. * - * @param id - 标识要订阅的传感器, 详情请参见{@link Sensor_SensorSubscribeId}。 - * @param user - 订阅者信息,用于指定传感器数据回调函数等,详情请参见{@Link Sensor_SubscribeUser}。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscribeId}. + * @param user - Pointer to the subscriber information, which is used to specify the callback function for reporting + * the sensor data. For details, see {@link Sensor_SubscribeUser}. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * * @since 11 */ -Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SensorSubscribeId *subscribeId, const Sensor_SubscribeUser *user); +Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SensorSubscribeId *id, const Sensor_SubscribeUser *user); #ifdef __cplusplus } #endif diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 9e86f4a9ce5..3fdadf111c3 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -17,7 +17,7 @@ * @addtogroup Sensor * @{ * - * @brief 为您提供标准的开放api,定义常用传感器属性。 + * @brief Provides APIs to define common sensor attributes. * * @since 11 */ @@ -25,9 +25,8 @@ /** * @file native_sensor_type.h * - * @brief 定义常用传感器属性。 - * @library libohsensor.z.so - * @syscap SystemCapability.Sensors.Sensor + * @brief Declares the common sensor attributes. + * @library libsensor_native.z.so * * @since 11 */ @@ -42,121 +41,102 @@ extern "C" { #endif /** - * @brief 传感器类型。 - * @syscap SystemCapability.Sensors.Sensor - * + * @brief Enumerates the sensor types. + * * @since 11 */ typedef enum Sensor_SensorType { /** - * 加速度传感器 - * @syscap SystemCapability.Sensors.Sensor + * Acceleration sensor. * @since 11 */ SENSOR_TYPE_ACCELEROMETER = 1, /** - * 陀螺仪传感测器 - * @syscap SystemCapability.Sensors.Sensor + * Gyroscope sensor. * @since 11 */ SENSOR_TYPE_GYROSCOPE = 2, /** - * 环境光传感器 - * @syscap SystemCapability.Sensors.Sensor + * Ambient light sensor. * @since 11 */ SENSOR_TYPE_AMBIENT_LIGHT = 5, /** - * 地磁传感器 - * @syscap SystemCapability.Sensors.Sensor + * Magnetic field sensor. * @since 11 */ SENSOR_TYPE_MAGNETIC_FIELD = 6, /** - * 气压计传感器 - * @syscap SystemCapability.Sensors.Sensor + * Barometer sensor. * @since 11 */ SENSOR_TYPE_BAROMETER = 8, /** - * 霍尔传感器 - * @syscap SystemCapability.Sensors.Sensor + * Hall effect sensor. * @since 11 */ SENSOR_TYPE_HALL = 10, /** - * 接近光传感器 - * @syscap SystemCapability.Sensors.Sensor + * Proximity sensor. * @since 11 */ SENSOR_TYPE_PROXIMITY = 12, /** - * 方向传感器 - * @syscap SystemCapability.Sensors.Sensor + * Orientation sensor. * @since 11 */ SENSOR_TYPE_ORIENTATION = 256, /** - * 重力传感器 - * @syscap SystemCapability.Sensors.Sensor + * Gravity sensor. * @since 11 */ SENSOR_TYPE_GRAVITY = 257, /** - * 旋转矢量传感器 - * @syscap SystemCapability.Sensors.Sensor + * Rotation vector sensor. * @since 11 */ SENSOR_TYPE_ROTATION_VECTOR = 259, /** - * 计步器检测传感器 - * @syscap SystemCapability.Sensors.Sensor + * Pedometer detection sensor. * @since 11 */ SENSOR_TYPE_PEDOMETER_DETECTION = 265, /** - * 计步器传感器 - * @syscap SystemCapability.Sensors.Sensor + * Pedometer sensor. * @since 11 */ SENSOR_TYPE_PEDOMETER = 266, /** - * 心率传感器 - * @syscap SystemCapability.Sensors.Sensor + * Heart rate sensor. * @since 11 */ SENSOR_TYPE_HEART_RATE = 278, } Sensor_SensorType; /** - * @brief 定义传感器错误码。 - * @syscap SystemCapability.Sensors.Sensor + * @brief Enumerates the sensor result codes. * * @since 11 */ typedef enum Sensor_Result { /** - * 操作成功。 - * @syscap SystemCapability.Sensors.Sensor + * The operation is successful. * @since 11 */ SENSOR_SUCCESS = 0, /** * Permission verification failed. - * @syscap SystemCapability.Sensors.Sensor * @since 11 */ SENSOR_PERMISSION_DENIED = 201, /** * Parameter check failed. For example, a mandatory parameter is not passed in, * or the parameter type passed in is incorrect. - * @syscap SystemCapability.Sensors.Sensor * @since 11 */ SENSOR_PARAMETER_ERROR = 401, /** - * 传感器服务异常。 - * @syscap SystemCapability.Sensors.Sensor + * The sensor service is abnormal. * @since 11 */ SENSOR_SERVICE_EXCEPTION = 14500101, @@ -164,40 +144,34 @@ typedef enum Sensor_Result { /** * @brief Enumerates the accuracy levels of data reported by a sensor. - * @syscap SystemCapability.Sensors.Sensor * * @since 11 */ typedef enum Sensor_SensorAccuracy { /** * The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure. - * @syscap SystemCapability.Sensors.Sensor * @since 11 */ SENSOR_ACCURACY_UNRELIABLE = 0, /** * The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used. - * @syscap SystemCapability.Sensors.Sensor * @since 11 */ SENSOR_ACCURACY_LOW = 1, /** * The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment before using it. - * @syscap SystemCapability.Sensors.Sensor * @since 11 */ SENSOR_ACCURACY_MEDIUM = 2, /** * The sensor data is at a high accuracy level. The data can be used directly. - * @syscap SystemCapability.Sensors.Sensor * @since 11 */ SENSOR_ACCURACY_HIGH = 3 } Sensor_SensorAccuracy; /** - * @brief 传感器信息。 - * @syscap SystemCapability.Sensors.Sensor + * @brief Defines the sensor information. * @since 11 */ typedef struct Sensor_Sensor Sensor_Sensor; @@ -222,131 +196,149 @@ Sensor_Sensor **OH_Sensor_CreateSensors(uint32_t count); int32_t OH_Sensor_DestroySensors(Sensor_Sensor **sensors, uint32_t count); /** - * @brief 获取传感器名称. + * @brief Obtains the sensor name. * - * @param sensor - 传感器信息. - * @param sensorName - 出参,传感器名称. - * @param length - 出参,字节数. - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensor - Pointer to the sensor information. + * @param sensorName - Pointer to the sensor name. + * @param length - Pointer to the length, in bytes. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorName(Sensor_Sensor* sensor, char *sensorName, size_t *length); +int32_t OH_Sensor_GetSensorName(Sensor_Sensor* sensor, char *sensorName, uint32_t *length); /** - * @brief 获取传感器厂商名称. + * @brief Obtains the sensor's vendor name. * - * @param sensor - 传感器信息. - * @param vendorName - 出参,厂商名称. - * @param length - 出参,字节数. - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensor - Pointer to the sensor information. + * @param vendorName - Pointer to the vendor name. + * @param length - Pointer to the length, in bytes. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetVendorName(Sensor_Sensor* sensor, char *vendorName, size_t *length); +int32_t OH_Sensor_GetVendorName(Sensor_Sensor* sensor, char *vendorName, uint32_t *length); /** - * @brief 获取传感器类型。 + * @brief Obtains the sensor type. * - * @param sensor - 传感器信息。 - * @param sensorType - 出参,传感器类型。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensor - Pointer to the sensor information. + * @param sensorType - Pointer to the sensor type. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetSensorType(Sensor_Sensor* sensor, Sensor_SensorType *sensorType); /** - * @brief 获取传感器分辨率。 + * @brief Obtains the sensor resolution. * - * @param sensor - 传感器信息。 - * @param resolution - 出参,传感器分辨率。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensor - Pointer to the sensor information. + * @param resolution - Pointer to the sensor resolution. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, float *resolution); /** - * @brief 获取传感器最小上报时间间隔。 + * @brief Obtains the minimum data reporting interval of a sensor. * - * @param sensor - 传感器信息。 - * @param minSamplePeriod - 出参,传感器最小上报时间间隔,单位纳秒。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensor - Pointer to the sensor information. + * @param minSamplePeriod - Pointer to the minimum data reporting interval, in nanoseconds. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetSensorMinSamplePeriod(Sensor_Sensor* sensor, int64_t *minSamplePeriod); /** - * @brief 获取传感器最大上报时间间隔。 + * @brief Obtains the maximum data reporting interval of a sensor. * - * @param sensor - 传感器信息。 - * @param maxSamplePeriod - 出参,传感器最大上报时间间隔,单位纳秒。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensor - Pointer to the sensor information. + * @param maxSamplePeriod - Pointer to the maximum data reporting interval, in nanoseconds. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetSensorMaxSamplePeriod(Sensor_Sensor* sensor, int64_t *maxSamplePeriod); /** - * @brief 传感器数据信息。 - * @syscap SystemCapability.Sensors.Sensor + * @brief Defines the sensor data information. * @since 11 */ typedef struct Sensor_SensorEvent Sensor_SensorEvent; /** - * @brief 获取传感器类型。 + * @brief Obtains the sensor type. * - * @param sensor - 传感器数据信息。 - * @param sensorType - 出参,传感器类型。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensorEvent - Pointer to the sensor data information. + * @param sensorType - Pointer to the sensor type. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetEventSensorType(Sensor_SensorEvent* sensorEvent, Sensor_SensorType *sensorType); /** - * @brief 获取时间戳。 + * @brief Obtains the timestamp of sensor data. * - * @param sensor - 传感器数据信息。 - * @param timestamp - 出参,时间戳。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensorEvent - Pointer to the sensor data information. + * @param timestamp - Pointer to the timestamp. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetEventTimestamp(Sensor_SensorEvent* sensorEvent, int64_t *timestamp); /** - * @brief 获取传感器数据精度。 + * @brief Obtains the accuracy of sensor data. * - * @param sensor - 传感器数据信息。 - * @param accuracy - 出参,传感器数据精度。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensorEvent - Pointer to the sensor data information. + * @param accuracy - Pointer to the accuracy. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetEventAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_SensorAccuracy *accuracy); /** - * @brief 获取传感器数据。数据的长度和内容依赖于监听的传感器类型,传感器上报的数据格式如下: - * SENSOR_TYPE_ACCELEROMETER: data[0]、data[1]、data[2]分别表示设备x、y、z轴的加速度分量,单位m/s2; - * SENSOR_TYPE_GYROSCOPE: data[0]、data[1]、data[2]分别表示设备x、y、z轴的旋转角速度,单位弧度/s; - * SENSOR_TYPE_AMBIENT_LIGHT: data[0]表示环境光强度,in lux; - * SENSOR_TYPE_MAGNETIC_FIELD: data[0]、data[1]、data[2]分别表示设备x、y、z轴的地磁分量,单位微特斯拉; - * SENSOR_TYPE_BAROMETER:data[0]表示气压值,单位hPa; - * SENSOR_TYPE_HALL: data[0]表示皮套吸合状态,0表示打开,大于0表示吸附; - * SENSOR_TYPE_PROXIMITY:data[0]表示接近状态,0表示接近,大于0表示远离; - * SENSOR_TYPE_ORIENTATION:data[0]、data[1]、data[2]分别表示设备绕z、x、y轴的角度,单位度; - * SENSOR_TYPE_GRAVITY:data[0]、data[1]、data[2]分别表示设备x、y、z轴的重力加速度分量,单位m/s2; - * SENSOR_TYPE_ROTATION_VECTOR:data[0]、data[1]、data[2]分别表示设备x、y、z轴的旋转角度,单位度,data[3]表示旋转向量元素; - * SENSOR_TYPE_PEDOMETER_DETECTION:data[0]表示几步检测状态,1表示检测到了步数变化 - * SENSOR_TYPE_PEDOMETER:data[0]表示步数; - * SENSOR_TYPE_HEART_RATE:data[0]表示心率数值; - * - * @param sensor - 传感器数据信息。 - * @param data - 出参,传感器数据。 - * @param length - 出参,数组长度。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @brief Obtains sensor data. The data length and content depend on the sensor type. + * The format of the sensor data reported is as follows: + * SENSOR_TYPE_ACCELEROMETER: data[0], data[1], and data[2], indicating the acceleration around + * the x, y, and z axes of the device, respectively, in m/s2. + * SENSOR_TYPE_GYROSCOPE: data[0], data[1], and data[2], indicating the angular velocity of rotation around + * the x, y, and z axes of the device, respectively, in rad/s. + * SENSOR_TYPE_AMBIENT_LIGHT: data[0], indicating the ambient light intensity, in lux. + * SENSOR_TYPE_MAGNETIC_FIELD: data[0], data[1], and data[2], indicating the magnetic field strength around + * the x, y, and z axes of the device, respectively, in μT. + * SENSOR_TYPE_BAROMETER: data[0], indicating the atmospheric pressure, in hPa. + * 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. + * 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. + * 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. + * 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/s2. + * 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. + * SENSOR_TYPE_PEDOMETER_DETECTION: data[0], indicating the pedometer detection status. + * The value 1 means that the number of detected steps changes. + * SENSOR_TYPE_PEDOMETER: data[0], indicating the number of steps a user has walked. + * SENSOR_TYPE_HEART_RATE: data[0], indicating the heart rate value. + * + * @param sensorEvent - Pointer to the sensor data information. + * @param data - Double pointer to the sensor data. + * @param length - Pointer to the array length. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, size_t *length); +int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, uint32_t *length); /** - * @brief 传感器订阅Id,唯一标识传感器。 - * @syscap SystemCapability.Sensors.Sensor + * @brief Defines the sensor subscription ID, which uniquely identifies a sensor. * @since 11 */ typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; @@ -369,28 +361,29 @@ Sensor_SensorSubscribeId *OH_Sensor_CreateSubscribeId(); int32_t OH_Sensor_DestroySubscribeId(Sensor_SensorSubscribeId *subscribeId); /** - * @brief 获取传感器类型。 + * @brief Obtains the sensor type. * - * @param subscribeId - 传感器订阅Id。 - * @param sensorType - 出参,传感器类型。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param subscribeId - Pointer to the sensor subscription ID. + * @param sensorType - Pointer to the sensor type. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, Sensor_SensorType *sensorType); /** - * @brief 设置传感器类型。 + * @brief Sets the sensor type. * - * @param subscribeId - 传感器订阅Id。 - * @param sensorType - 传感器类型。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param subscribeId - Pointer to the sensor subscription ID. + * @param sensorType - Sensor type to set. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_SetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, const Sensor_SensorType sensorType); /** - * @brief 传感器订阅属性。 - * @syscap SystemCapability.Sensors.Sensor + * @brief Defines the sensor subscription attribute. * @since 11 */ typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; @@ -413,35 +406,35 @@ Sensor_SubscribeAttribute *OH_Sensor_CreateAttribute(); int32_t OH_Sensor_DestroyAttribute(Sensor_SubscribeAttribute *attribute); /** - * @brief 设置上报时间间隔。 + * @brief Sets the sensor data reporting interval. * - * @param attribute - 传感器订阅属性。 - * @param samplingInterval - 上报时间间隔,单位ns。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param attribute - Pointer to the sensor subscription attribute. + * @param samplingInterval - Data reporting interval to set, in nanoseconds. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscribeAttribute* attribute, const int64_t samplingInterval); /** - * @brief 获取上报时间间隔。 + * @brief Obtains the sensor data reporting interval. * - * @param attribute - 传感器订阅属性。 - * @param samplingInterval - 出参,上报时间间隔,单位ns。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param attribute - Pointer to the sensor subscription attribute. + * @param samplingInterval - Pointer to the data reporting interval, in nanoseconds. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscribeAttribute* attribute, int64_t *samplingInterval); /** - * @brief 传感器数据的回调函数。 - * @syscap SystemCapability.Sensors.Sensor + * @brief Defines the callback function used to report sensor data. * @since 11 */ typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); /** - * @brief 传感器订阅者信息。 - * @syscap SystemCapability.Sensors.Sensor + * @brief Defines the sensor subscriber information. * @since 11 */ typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; @@ -464,21 +457,23 @@ Sensor_SubscribeUser *OH_Sensor_CreateUser(); int32_t OH_Sensor_DestroyUser(Sensor_SubscribeUser *user); /** - * @brief 设置传感器数据的回调函数。 + * @brief Sets a callback function to report sensor data. * - * @param user - 传感器订阅者信息。 - * @param callback - 传感器数据的回调函数。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param user - Pointer to the sensor subscriber information. + * @param callback - Callback function to set. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_SetSensorCallback(Sensor_SubscribeUser* user, const Sensor_RecordSensorCallback callback); /** - * @brief 获取传感器数据的回调函数。 + * @brief Obtains the callback function used to report sensor data. * - * @param user - 传感器订阅者信息。 - * @param callback - 出参,传感器数据的回调函数。 - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param user - Pointer to the sensor subscriber information. + * @param callback - Pointer to the callback function. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_GetSensorCallback(Sensor_SubscribeUser* user, Sensor_RecordSensorCallback *callback); -- Gitee From 27b0c13cba42ed72290afc1676c6134fadba4696 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 28 Nov 2023 08:49:24 +0000 Subject: [PATCH 15/33] update Signed-off-by: hellohyh001 Change-Id: I420f9e348a8e4c84290c02c2487e8c144a52e326 --- sensors/sensor/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index 1eba42e25b2..60c8c1863be 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -24,7 +24,7 @@ ohos_ndk_headers("sensor_ndk_header") { ohos_ndk_library("libsensor_ndk") { ndk_description_file = "./libsensor.ndk.json" - output_name = "libsensor_native" + output_name = "sensor_native" output_extension = "z.so" min_compact_version = "11" -} \ No newline at end of file +} -- Gitee From 8bd2647c8398c08cd81c07126f8044a43ec92a3c Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 28 Nov 2023 13:19:43 +0000 Subject: [PATCH 16/33] update Signed-off-by: hellohyh001 Change-Id: Ifdc9001c0e26c4f87cf33d5b5ebd604713228bb4 --- sensors/sensor/native_sensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index 0850a15e1d4..c9985ed981e 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -50,7 +50,7 @@ extern "C" { * * @since 11 */ -Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, int32_t *count); +Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); /** * @brief Subscribes to sensor data. The system will report sensor data to the subscriber at the specified frequency. -- Gitee From 8bba32f8bf2362fe07e3d08ed954e7097af0b98e Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Wed, 29 Nov 2023 06:24:02 +0000 Subject: [PATCH 17/33] upadte Signed-off-by: hellohyh001 Change-Id: Id4a427755e89468d84eaa6527c1e999db165a150 --- sensors/sensor/native_sensor_type.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 3fdadf111c3..952e5c29c3c 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -349,7 +349,7 @@ typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; * @return 如果创建成功,则返回指向{@link Sensor_SensorSubscribeId} 结构实例的指针,否则返回NULL. * @since 11 */ -Sensor_SensorSubscribeId *OH_Sensor_CreateSubscribeId(); +Sensor_SensorSubscribeId *OH_Sensor_CreateSubscribeId(void); /** * @brief 销毁{@link Sensor_SensorSubscribeId}实例并回收内存。 @@ -394,7 +394,7 @@ typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; * @return 如果创建成功,则返回指向{@link Sensor_SubscribeAttribute} 结构实例的指针,否则返回NULL. * @since 11 */ -Sensor_SubscribeAttribute *OH_Sensor_CreateAttribute(); +Sensor_SubscribeAttribute *OH_Sensor_CreateAttribute(void); /** * @brief 销毁{@link Sensor_SubscribeAttribute}实例并回收内存。 @@ -445,7 +445,7 @@ typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; * @return 如果创建成功,则返回指向{@link Sensor_SubscribeUser} 结构实例的指针,否则返回NULL. * @since 11 */ -Sensor_SubscribeUser *OH_Sensor_CreateUser(); +Sensor_SubscribeUser *OH_Sensor_CreateUser(void); /** * @brief 销毁{@link Sensor_SubscribeUser}实例并回收内存。 -- Gitee From 7fb665335da6e8abd38db531383eda1b6ac1afb8 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Wed, 29 Nov 2023 08:12:56 +0000 Subject: [PATCH 18/33] update Signed-off-by: hellohyh001 Change-Id: Ic2b19570250b6b53b5fa287e784a89641bc06b97 --- sensors/sensor/native_sensor_type.h | 58 +++++++++++++++++------------ 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 952e5c29c3c..71b29b2fbc7 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -154,12 +154,14 @@ typedef enum Sensor_SensorAccuracy { */ SENSOR_ACCURACY_UNRELIABLE = 0, /** - * The sensor data is at a low accuracy level. The data must be calibrated based on the environment before being used. + * The sensor data is at a low accuracy level. The data must be calibrated based on + * the environment before being used. * @since 11 */ SENSOR_ACCURACY_LOW = 1, /** - * The sensor data is at a medium accuracy level. You are advised to calibrate the data based on the environment before using it. + * The sensor data is at a medium accuracy level. You are advised to calibrate the data + * based on the environment before using it. * @since 11 */ SENSOR_ACCURACY_MEDIUM = 2, @@ -177,20 +179,22 @@ typedef enum Sensor_SensorAccuracy { typedef struct Sensor_Sensor Sensor_Sensor; /** - * @brief 创建给定个数{@link Sensor_Sensor}实例的数组。 + * @brief Creates an array of {@link Sensor_Sensor} instances with the given number. * - * @param count - 表示要创建{@link Sensor_Sensor}实例的个数. - * @return 如果创建成功,则返回{@link Sensor_Sensor}实例的数组,否则返回 NULL。。 + * @param count - Number of {@link Sensor_Sensor} instances to create. + * @return Returns the double pointer to the array of {@link Sensor_Sensor} instances if the operation is successful; + * returns NULL otherwise. * @since 11 */ Sensor_Sensor **OH_Sensor_CreateSensors(uint32_t count); /** - * @brief 销毁{@link Sensor_Sensor}实例的数组并回收内存。 + * @brief Destroys an array of {@link Sensor_Sensor} instances and reclaims memory. * - * @param sensors - 表示要销毁的{@link Sensor_Sensor}实例的数组. - * @param count - 表示要销毁的{@link Sensor_Sensor}实例的个数. - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param sensors - Double pointer to the array of {@link Sensor_Sensor} instances. + * @param count - Number of {@link Sensor_Sensor} instances to destroy. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_DestroySensors(Sensor_Sensor **sensors, uint32_t count); @@ -344,18 +348,20 @@ int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, u typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; /** - * @brief 创建指向{@link Sensor_SensorSubscribeId}实例的指针。 + * @brief Creates a {@link Sensor_SensorSubscribeId} instance. * - * @return 如果创建成功,则返回指向{@link Sensor_SensorSubscribeId} 结构实例的指针,否则返回NULL. + * @return Returns the pointer to the {@link Sensor_SensorSubscribeId} instance if the operation is successful; + * returns NULL otherwise. * @since 11 */ Sensor_SensorSubscribeId *OH_Sensor_CreateSubscribeId(void); /** - * @brief 销毁{@link Sensor_SensorSubscribeId}实例并回收内存。 + * @brief Destroys a {@link Sensor_SensorSubscribeId} instance and reclaims memory. * - * @param subscribeId - 表示指向 {@link Sensor_SensorSubscribeId} 实例的指针. - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param subscribeId - Pointer to the {@link Sensor_SensorSubscribeId} instance. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_DestroySubscribeId(Sensor_SensorSubscribeId *subscribeId); @@ -389,18 +395,20 @@ int32_t OH_Sensor_SetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; /** - * @brief 创建指向{@link Sensor_SubscribeAttribute}实例的指针。 + * @brief Creates a {@link Sensor_SubscribeAttribute} instance. * - * @return 如果创建成功,则返回指向{@link Sensor_SubscribeAttribute} 结构实例的指针,否则返回NULL. + * @return Returns the pointer to the {@link Sensor_SubscribeAttribute} instance if the operation is successful; + * returns NULL otherwise. * @since 11 */ Sensor_SubscribeAttribute *OH_Sensor_CreateAttribute(void); /** - * @brief 销毁{@link Sensor_SubscribeAttribute}实例并回收内存。 + * @brief Destroys a {@link Sensor_SubscribeAttribute} instance and reclaims memory. * - * @param attribute - 表示指向 {@link Sensor_SubscribeAttribute} 实例的指针. - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param attribute - Pointer to the {@link Sensor_SubscribeAttribute} instance. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_DestroyAttribute(Sensor_SubscribeAttribute *attribute); @@ -440,18 +448,20 @@ typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; /** - * @brief 创建指向{@link Sensor_SubscribeUser}实例的指针。 + * @brief Creates a {@link Sensor_SubscribeUser} instance. * - * @return 如果创建成功,则返回指向{@link Sensor_SubscribeUser} 结构实例的指针,否则返回NULL. + * @return Returns the pointer to the {@link Sensor_SubscribeUser} instance + * if the operation is successful; returns NULL otherwise. * @since 11 */ Sensor_SubscribeUser *OH_Sensor_CreateUser(void); /** - * @brief 销毁{@link Sensor_SubscribeUser}实例并回收内存。 + * @brief Destroys a {@link Sensor_SubscribeUser} instance and reclaims memory. * - * @param user - 表示指向{@link Sensor_SubscribeUser}实例的指针. - * @return 成功返回SENSOR_SUCCESS,否则返回对应的错误码,详情请参见{@Link Sensor_Result}。 + * @param user - Pointer to the {@link Sensor_SubscribeUser} instance. + * @return Returns SENSOR_SUCCESS if the operation is successful; + * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ int32_t OH_Sensor_DestroyUser(Sensor_SubscribeUser *user); -- Gitee From c64d9935714228e8aec01ec2fd557f288ebb8cd3 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 06:28:54 +0000 Subject: [PATCH 19/33] update Signed-off-by: hellohyh001 Change-Id: Ia6ffb4583297a2dbedb04df8767cc474efae05b4 --- sensors/sensor/native_sensor.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index c9985ed981e..753bc2b0f5d 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -54,6 +54,11 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); /** * @brief Subscribes to sensor data. The system will report sensor data to the subscriber at the specified frequency. + * If you need to apply for the ohos.permission.ACCELEROMETER permission when subscribing to the accelerometer sensor, + * you need to apply for the ohos.permission.GYROSCOPE permission when subscribing to the gyroscope sensor, and you need + * to apply for the ohos.permission.ACTIVITY_MOTION permission when subscribing to the pedometer related sensor. Apply + * for ohos.permission.READ_HEALTH_DATA permission when subscribing to health-related sensors, such as heart rate sensors, + * otherwise the subscription fails. Other sensors do not require permissions. * * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscribeId}. * @param attribute - Pointer to the subscription attribute, which is used to specify the data reporting frequency. @@ -62,7 +67,7 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); * the sensor data. For details, see {@link Sensor_SubscribeUser}. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. - * + * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * @since 11 */ Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscribeId *id, const Sensor_SubscribeAttribute *attribute, @@ -70,12 +75,18 @@ Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscribeId *id, cons /** * @brief Unsubscribes from sensor data. + * If you need to apply for the ohos.permission.ACCELEROMETER permission to unsubscribe from the accelerometer sensor, + * you need to request the ohos.permission.GYROSCOPE permission to unsubscribe from the gyroscope sensor, and you need + * to request the ohos.permission.ACTIVITY_MOTION permission to unsubscribe from the pedometer-related sensor. When you + * unsubscribe from health-related sensors, such as heart rate sensors, apply for ohos.permission.READ_HEALTH_DATA permissions, + * otherwise the subscription will fail. Other sensors do not require permissions. * * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscribeId}. * @param user - Pointer to the subscriber information, which is used to specify the callback function for reporting * the sensor data. For details, see {@link Sensor_SubscribeUser}. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. + * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * * @since 11 */ -- Gitee From a520f5c61efaf33b1fc79f6191634f154362889a Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 07:24:42 +0000 Subject: [PATCH 20/33] udpate Signed-off-by: hellohyh001 Change-Id: I7aba00ba69d3a144786d48b833763fc33041eb05 --- sensors/sensor/native_sensor_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 71b29b2fbc7..6e8497731be 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -27,7 +27,7 @@ * * @brief Declares the common sensor attributes. * @library libsensor_native.z.so - * + * @syscap SystemCapability.Sensors.Sensor * @since 11 */ -- Gitee From d13f8c988b9872b79e718073446456ef1925d69f Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 09:10:48 +0000 Subject: [PATCH 21/33] update Signed-off-by: hellohyh001 Change-Id: Ife60fe0b39ede3ad44df23b7908532e9fa70c43a --- sensors/sensor/libsensor.ndk.json | 16 +++---- sensors/sensor/native_sensor.h | 20 ++++---- sensors/sensor/native_sensor_type.h | 72 ++++++++++++++--------------- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json index 98f99149ab4..8a761a0bd78 100644 --- a/sensors/sensor/libsensor.ndk.json +++ b/sensors/sensor/libsensor.ndk.json @@ -21,10 +21,10 @@ "name": "OH_Sensor_GetSensorResolution" }, { - "name": "OH_Sensor_GetSensorMinSamplePeriod" + "name": "OH_Sensor_GetMinSamplingInterval" }, { - "name": "OH_Sensor_GetSensorMaxSamplePeriod" + "name": "OH_Sensor_GetMaxSamplingInterval" }, { "name": "OH_Sensor_GetEventSensorType" @@ -39,10 +39,10 @@ "name": "OH_Sensor_GetSensorData" }, { - "name": "OH_Sensor_GetSubscribeSensorType" + "name": "OH_Sensor_GetSubscriptionSensorType" }, { - "name": "OH_Sensor_SetSubscribeSensorType" + "name": "OH_Sensor_SetSubscriptionSensorType" }, { "name": "OH_Sensor_SetSamplingInterval" @@ -63,10 +63,10 @@ "name": "OH_Sensor_DestroySensors" }, { - "name": "OH_Sensor_CreateSubscribeId" + "name": "OH_Sensor_CreateSubscriptionId" }, { - "name": "OH_Sensor_DestroySubscribeId" + "name": "OH_Sensor_DestroySubscriptionId" }, { "name": "OH_Sensor_CreateAttribute" @@ -75,9 +75,9 @@ "name": "OH_Sensor_DestroyAttribute" }, { - "name": "OH_Sensor_CreateUser" + "name": "OH_Sensor_CreateSubscriber" }, { - "name": "OH_Sensor_DestroyUser" + "name": "OH_Sensor_DestroySubscriber" } ] \ No newline at end of file diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index 753bc2b0f5d..9c49d660cbf 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -60,18 +60,18 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); * for ohos.permission.READ_HEALTH_DATA permission when subscribing to health-related sensors, such as heart rate sensors, * otherwise the subscription fails. Other sensors do not require permissions. * - * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscribeId}. + * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscriptionId}. * @param attribute - Pointer to the subscription attribute, which is used to specify the data reporting frequency. - * For details, see {@link Sensor_SubscribeAttribute}. - * @param user - Pointer to the subscriber information, which is used to specify the callback function for reporting - * the sensor data. For details, see {@link Sensor_SubscribeUser}. + * For details, see {@link Sensor_SubscriptionAttribute}. + * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for reporting + * the sensor data. For details, see {@link Sensor_Subscriber}. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * @since 11 */ -Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscribeId *id, const Sensor_SubscribeAttribute *attribute, - const Sensor_SubscribeUser *user); +Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscriptionId *id, const Sensor_SubscriptionAttribute *attribute, + const Sensor_Subscriber *subscriber); /** * @brief Unsubscribes from sensor data. @@ -81,16 +81,16 @@ Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscribeId *id, cons * unsubscribe from health-related sensors, such as heart rate sensors, apply for ohos.permission.READ_HEALTH_DATA permissions, * otherwise the subscription will fail. Other sensors do not require permissions. * - * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscribeId}. - * @param user - Pointer to the subscriber information, which is used to specify the callback function for reporting - * the sensor data. For details, see {@link Sensor_SubscribeUser}. + * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscriptionId}. + * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for reporting + * the sensor data. For details, see {@link Sensor_Subscriber}. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * * @since 11 */ -Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SensorSubscribeId *id, const Sensor_SubscribeUser *user); +Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SensorSubscriptionId *id, const Sensor_Subscriber *subscriber); #ifdef __cplusplus } #endif diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 6e8497731be..af7373c809d 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -249,23 +249,23 @@ int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, float *resolution); * @brief Obtains the minimum data reporting interval of a sensor. * * @param sensor - Pointer to the sensor information. - * @param minSamplePeriod - Pointer to the minimum data reporting interval, in nanoseconds. + * @param minSamplingInterval - Pointer to the minimum data reporting interval, in nanoseconds. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorMinSamplePeriod(Sensor_Sensor* sensor, int64_t *minSamplePeriod); +int32_t OH_Sensor_GetMinSamplingInterval(Sensor_Sensor* sensor, int64_t *minSamplingInterval); /** * @brief Obtains the maximum data reporting interval of a sensor. * * @param sensor - Pointer to the sensor information. - * @param maxSamplePeriod - Pointer to the maximum data reporting interval, in nanoseconds. + * @param maxSamplingInterval - Pointer to the maximum data reporting interval, in nanoseconds. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorMaxSamplePeriod(Sensor_Sensor* sensor, int64_t *maxSamplePeriod); +int32_t OH_Sensor_GetMaxSamplingInterval(Sensor_Sensor* sensor, int64_t *maxSamplingInterval); /** * @brief Defines the sensor data information. @@ -345,73 +345,73 @@ int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, u * @brief Defines the sensor subscription ID, which uniquely identifies a sensor. * @since 11 */ -typedef struct Sensor_SensorSubscribeId Sensor_SensorSubscribeId; +typedef struct Sensor_SensorSubscriptionId Sensor_SensorSubscriptionId; /** - * @brief Creates a {@link Sensor_SensorSubscribeId} instance. + * @brief Creates a {@link Sensor_SensorSubscriptionId} instance. * - * @return Returns the pointer to the {@link Sensor_SensorSubscribeId} instance if the operation is successful; + * @return Returns the pointer to the {@link Sensor_SensorSubscriptionId} instance if the operation is successful; * returns NULL otherwise. * @since 11 */ -Sensor_SensorSubscribeId *OH_Sensor_CreateSubscribeId(void); +Sensor_SensorSubscriptionId *OH_Sensor_CreateSubscriptionId(void); /** - * @brief Destroys a {@link Sensor_SensorSubscribeId} instance and reclaims memory. + * @brief Destroys a {@link Sensor_SensorSubscriptionId} instance and reclaims memory. * - * @param subscribeId - Pointer to the {@link Sensor_SensorSubscribeId} instance. + * @param subscribeId - Pointer to the {@link Sensor_SensorSubscriptionId} instance. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroySubscribeId(Sensor_SensorSubscribeId *subscribeId); +int32_t OH_Sensor_DestroySubscriptionId(Sensor_SensorSubscriptionId *subscribeId); /** * @brief Obtains the sensor type. * * @param subscribeId - Pointer to the sensor subscription ID. - * @param sensorType - Pointer to the sensor type. + * @param id - Pointer to the sensor type. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, Sensor_SensorType *sensorType); +int32_t OH_Sensor_GetSubscriptionSensorType(Sensor_SensorSubscriptionId* id, Sensor_SensorType *sensorType); /** * @brief Sets the sensor type. * - * @param subscribeId - Pointer to the sensor subscription ID. + * @param id - Pointer to the sensor subscription ID. * @param sensorType - Sensor type to set. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSubscribeSensorType(Sensor_SensorSubscribeId* subscribeId, const Sensor_SensorType sensorType); +int32_t OH_Sensor_SetSubscriptionSensorType(Sensor_SensorSubscriptionId* id, const Sensor_SensorType sensorType); /** * @brief Defines the sensor subscription attribute. * @since 11 */ -typedef struct Sensor_SubscribeAttribute Sensor_SubscribeAttribute; +typedef struct Sensor_SubscriptionAttribute Sensor_SubscriptionAttribute; /** - * @brief Creates a {@link Sensor_SubscribeAttribute} instance. + * @brief Creates a {@link Sensor_SubscriptionAttribute} instance. * - * @return Returns the pointer to the {@link Sensor_SubscribeAttribute} instance if the operation is successful; + * @return Returns the pointer to the {@link Sensor_SubscriptionAttribute} instance if the operation is successful; * returns NULL otherwise. * @since 11 */ -Sensor_SubscribeAttribute *OH_Sensor_CreateAttribute(void); +Sensor_SubscriptionAttribute *OH_Sensor_CreateAttribute(void); /** - * @brief Destroys a {@link Sensor_SubscribeAttribute} instance and reclaims memory. + * @brief Destroys a {@link Sensor_SubscriptionAttribute} instance and reclaims memory. * - * @param attribute - Pointer to the {@link Sensor_SubscribeAttribute} instance. + * @param attribute - Pointer to the {@link Sensor_SubscriptionAttribute} instance. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroyAttribute(Sensor_SubscribeAttribute *attribute); +int32_t OH_Sensor_DestroyAttribute(Sensor_SubscriptionAttribute *attribute); /** * @brief Sets the sensor data reporting interval. @@ -422,7 +422,7 @@ int32_t OH_Sensor_DestroyAttribute(Sensor_SubscribeAttribute *attribute); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscribeAttribute* attribute, const int64_t samplingInterval); +int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, const int64_t samplingInterval); /** * @brief Obtains the sensor data reporting interval. @@ -433,60 +433,60 @@ int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscribeAttribute* attribute, cons * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscribeAttribute* attribute, int64_t *samplingInterval); +int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, int64_t *samplingInterval); /** * @brief Defines the callback function used to report sensor data. * @since 11 */ -typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); +typedef void (*Sensor_SensorCallback)(Sensor_SensorEvent *event); /** * @brief Defines the sensor subscriber information. * @since 11 */ -typedef struct Sensor_SubscribeUser Sensor_SubscribeUser; +typedef struct Sensor_Subscriber Sensor_Subscriber; /** - * @brief Creates a {@link Sensor_SubscribeUser} instance. + * @brief Creates a {@link Sensor_Subscriber} instance. * - * @return Returns the pointer to the {@link Sensor_SubscribeUser} instance + * @return Returns the pointer to the {@link Sensor_Subscriber} instance * if the operation is successful; returns NULL otherwise. * @since 11 */ -Sensor_SubscribeUser *OH_Sensor_CreateUser(void); +Sensor_Subscriber *OH_Sensor_CreateSubscriber(void); /** - * @brief Destroys a {@link Sensor_SubscribeUser} instance and reclaims memory. + * @brief Destroys a {@link Sensor_Subscriber} instance and reclaims memory. * - * @param user - Pointer to the {@link Sensor_SubscribeUser} instance. + * @param subscriber - Pointer to the {@link Sensor_Subscriber} instance. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroyUser(Sensor_SubscribeUser *user); +int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber); /** * @brief Sets a callback function to report sensor data. * - * @param user - Pointer to the sensor subscriber information. + * @param subscriber - Pointer to the sensor subscriber information. * @param callback - Callback function to set. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSensorCallback(Sensor_SubscribeUser* user, const Sensor_RecordSensorCallback callback); +int32_t OH_Sensor_SetSensorCallback(Sensor_Subscriber* subscriber, const Sensor_SensorCallback callback); /** * @brief Obtains the callback function used to report sensor data. * - * @param user - Pointer to the sensor subscriber information. + * @param subscriber - Pointer to the sensor subscriber information. * @param callback - Pointer to the callback function. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorCallback(Sensor_SubscribeUser* user, Sensor_RecordSensorCallback *callback); +int32_t OH_Sensor_GetSensorCallback(Sensor_Subscriber* subscriber, Sensor_SensorCallback *callback); #ifdef __cplusplus } #endif -- Gitee From 1cdf06f645db2d6063484e07a896c2fc2cdea544 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 09:22:49 +0000 Subject: [PATCH 22/33] update Signed-off-by: hellohyh001 Change-Id: I94f2d0ea11912ab0a7a6d8ffc78e621785d6025e --- sensors/sensor/native_sensor_type.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index af7373c809d..e964765f1aa 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -359,17 +359,17 @@ Sensor_SensorSubscriptionId *OH_Sensor_CreateSubscriptionId(void); /** * @brief Destroys a {@link Sensor_SensorSubscriptionId} instance and reclaims memory. * - * @param subscribeId - Pointer to the {@link Sensor_SensorSubscriptionId} instance. + * @param id - Pointer to the {@link Sensor_SensorSubscriptionId} instance. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroySubscriptionId(Sensor_SensorSubscriptionId *subscribeId); +int32_t OH_Sensor_DestroySubscriptionId(Sensor_SensorSubscriptionId *id); /** * @brief Obtains the sensor type. * - * @param subscribeId - Pointer to the sensor subscription ID. + * @param id - Pointer to the sensor subscription ID. * @param id - Pointer to the sensor type. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. -- Gitee From 9b47cf7cd936068953a1d3fae7e9d127fde65935 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 09:59:27 +0000 Subject: [PATCH 23/33] update Signed-off-by: hellohyh001 Change-Id: I885540f9934c75955372596038400e0340e2ba4d --- sensors/sensor/native_sensor.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index 9c49d660cbf..b51f0ebca6c 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -57,36 +57,38 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); * If you need to apply for the ohos.permission.ACCELEROMETER permission when subscribing to the accelerometer sensor, * you need to apply for the ohos.permission.GYROSCOPE permission when subscribing to the gyroscope sensor, and you need * to apply for the ohos.permission.ACTIVITY_MOTION permission when subscribing to the pedometer related sensor. Apply - * for ohos.permission.READ_HEALTH_DATA permission when subscribing to health-related sensors, such as heart rate sensors, - * otherwise the subscription fails. Other sensors do not require permissions. + * for ohos.permission.READ_HEALTH_DATA permission when subscribing to health-related sensors, such as heart rate + * sensors, otherwise the subscription fails. Other sensors do not require permissions. * * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscriptionId}. * @param attribute - Pointer to the subscription attribute, which is used to specify the data reporting frequency. * For details, see {@link Sensor_SubscriptionAttribute}. - * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for reporting - * the sensor data. For details, see {@link Sensor_Subscriber}. + * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for + * reporting the sensor data. For details, see {@link Sensor_Subscriber}. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. - * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA + * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or + * ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * @since 11 */ -Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscriptionId *id, const Sensor_SubscriptionAttribute *attribute, - const Sensor_Subscriber *subscriber); +Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscriptionId *id, + const Sensor_SubscriptionAttribute *attribute, const Sensor_Subscriber *subscriber); /** * @brief Unsubscribes from sensor data. * If you need to apply for the ohos.permission.ACCELEROMETER permission to unsubscribe from the accelerometer sensor, * you need to request the ohos.permission.GYROSCOPE permission to unsubscribe from the gyroscope sensor, and you need * to request the ohos.permission.ACTIVITY_MOTION permission to unsubscribe from the pedometer-related sensor. When you - * unsubscribe from health-related sensors, such as heart rate sensors, apply for ohos.permission.READ_HEALTH_DATA permissions, - * otherwise the subscription will fail. Other sensors do not require permissions. + * unsubscribe from health-related sensors, such as heart rate sensors, apply for ohos.permission.READ_HEALTH_DATA + * permissions, otherwise the subscription will fail. Other sensors do not require permissions. * * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscriptionId}. - * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for reporting - * the sensor data. For details, see {@link Sensor_Subscriber}. + * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for + * reporting the sensor data. For details, see {@link Sensor_Subscriber}. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. - * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA + * @permission ohos.permission.ACCELEROMETER or ohos.permission.GYROSCOPE or + * ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * * @since 11 */ -- Gitee From 7fc382804244d7394a9130ce6a4e9dfb1e742c24 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 11:24:54 +0000 Subject: [PATCH 24/33] update Signed-off-by: hellohyh001 Change-Id: I02a6232ccfc26f4f84bf7a7b6900445f432e5e62 --- sensors/sensor/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index 60c8c1863be..67be6997330 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Huawei Device Co., Ltd. +# Copyright (C) 2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -- Gitee From f5e7338b6d59d1af62a468e2f67567ac482be5db Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 14:11:49 +0000 Subject: [PATCH 25/33] update Signed-off-by: hellohyh001 Change-Id: Id936dbb16c473db714d94bf643a50bbc3ee2bbad --- sensors/sensor/native_sensor.h | 12 ++--- sensors/sensor/native_sensor_type.h | 72 ++++++++++++++--------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/native_sensor.h index b51f0ebca6c..776847cf687 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/native_sensor.h @@ -43,14 +43,14 @@ extern "C" { * @brief Obtains information about all sensors on the device. * * @param sensors - Double pointer to the information about all sensors on the device. - * For details, see {@link Sensor_Sensor}. + * For details, see {@link Sensor_DeviceInfo}. * @param count - Pointer to the number of sensors on the device. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * * @since 11 */ -Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); +Sensor_Result OH_Sensor_GetAllSensors(Sensor_DeviceInfo **sensors, uint32_t *count); /** * @brief Subscribes to sensor data. The system will report sensor data to the subscriber at the specified frequency. @@ -60,7 +60,7 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); * for ohos.permission.READ_HEALTH_DATA permission when subscribing to health-related sensors, such as heart rate * sensors, otherwise the subscription fails. Other sensors do not require permissions. * - * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscriptionId}. + * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SubscriptionId}. * @param attribute - Pointer to the subscription attribute, which is used to specify the data reporting frequency. * For details, see {@link Sensor_SubscriptionAttribute}. * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for @@ -71,7 +71,7 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_Sensor **sensors, uint32_t *count); * ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * @since 11 */ -Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscriptionId *id, +Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SubscriptionId *id, const Sensor_SubscriptionAttribute *attribute, const Sensor_Subscriber *subscriber); /** @@ -82,7 +82,7 @@ Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscriptionId *id, * unsubscribe from health-related sensors, such as heart rate sensors, apply for ohos.permission.READ_HEALTH_DATA * permissions, otherwise the subscription will fail. Other sensors do not require permissions. * - * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SensorSubscriptionId}. + * @param id - Pointer to the sensor subscription ID. For details, see {@link Sensor_SubscriptionId}. * @param subscriber - Pointer to the subscriber information, which is used to specify the callback function for * reporting the sensor data. For details, see {@link Sensor_Subscriber}. * @return Returns SENSOR_SUCCESS if the operation is successful; @@ -92,7 +92,7 @@ Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SensorSubscriptionId *id, * * @since 11 */ -Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SensorSubscriptionId *id, const Sensor_Subscriber *subscriber); +Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SubscriptionId *id, const Sensor_Subscriber *subscriber); #ifdef __cplusplus } #endif diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index e964765f1aa..23dbf23b7aa 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -45,7 +45,7 @@ extern "C" { * * @since 11 */ -typedef enum Sensor_SensorType { +typedef enum Sensor_Type { /** * Acceleration sensor. * @since 11 @@ -111,7 +111,7 @@ typedef enum Sensor_SensorType { * @since 11 */ SENSOR_TYPE_HEART_RATE = 278, -} Sensor_SensorType; +} Sensor_Type; /** * @brief Enumerates the sensor result codes. @@ -147,7 +147,7 @@ typedef enum Sensor_Result { * * @since 11 */ -typedef enum Sensor_SensorAccuracy { +typedef enum Sensor_DataAccuracy { /** * The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure. * @since 11 @@ -170,34 +170,34 @@ typedef enum Sensor_SensorAccuracy { * @since 11 */ SENSOR_ACCURACY_HIGH = 3 -} Sensor_SensorAccuracy; +} Sensor_DataAccuracy; /** * @brief Defines the sensor information. * @since 11 */ -typedef struct Sensor_Sensor Sensor_Sensor; +typedef struct Sensor_DeviceInfo Sensor_DeviceInfo; /** - * @brief Creates an array of {@link Sensor_Sensor} instances with the given number. + * @brief Creates an array of {@link Sensor_DeviceInfo} instances with the given number. * - * @param count - Number of {@link Sensor_Sensor} instances to create. - * @return Returns the double pointer to the array of {@link Sensor_Sensor} instances if the operation is successful; + * @param count - Number of {@link Sensor_DeviceInfo} instances to create. + * @return Returns the double pointer to the array of {@link Sensor_DeviceInfo} instances if the operation is successful; * returns NULL otherwise. * @since 11 */ -Sensor_Sensor **OH_Sensor_CreateSensors(uint32_t count); +Sensor_DeviceInfo **OH_Sensor_CreateSensors(uint32_t count); /** - * @brief Destroys an array of {@link Sensor_Sensor} instances and reclaims memory. + * @brief Destroys an array of {@link Sensor_DeviceInfo} instances and reclaims memory. * - * @param sensors - Double pointer to the array of {@link Sensor_Sensor} instances. - * @param count - Number of {@link Sensor_Sensor} instances to destroy. + * @param sensors - Double pointer to the array of {@link Sensor_DeviceInfo} instances. + * @param count - Number of {@link Sensor_DeviceInfo} instances to destroy. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroySensors(Sensor_Sensor **sensors, uint32_t count); +int32_t OH_Sensor_DestroySensors(Sensor_DeviceInfo **sensors, uint32_t count); /** * @brief Obtains the sensor name. @@ -209,7 +209,7 @@ int32_t OH_Sensor_DestroySensors(Sensor_Sensor **sensors, uint32_t count); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorName(Sensor_Sensor* sensor, char *sensorName, uint32_t *length); +int32_t OH_Sensor_GetSensorName(Sensor_DeviceInfo* sensor, char *sensorName, uint32_t *length); /** * @brief Obtains the sensor's vendor name. @@ -221,7 +221,7 @@ int32_t OH_Sensor_GetSensorName(Sensor_Sensor* sensor, char *sensorName, uint32_ * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetVendorName(Sensor_Sensor* sensor, char *vendorName, uint32_t *length); +int32_t OH_Sensor_GetVendorName(Sensor_DeviceInfo* sensor, char *vendorName, uint32_t *length); /** * @brief Obtains the sensor type. @@ -232,7 +232,7 @@ int32_t OH_Sensor_GetVendorName(Sensor_Sensor* sensor, char *vendorName, uint32_ * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorType(Sensor_Sensor* sensor, Sensor_SensorType *sensorType); +int32_t OH_Sensor_GetSensorType(Sensor_DeviceInfo* sensor, Sensor_Type *sensorType); /** * @brief Obtains the sensor resolution. @@ -243,7 +243,7 @@ int32_t OH_Sensor_GetSensorType(Sensor_Sensor* sensor, Sensor_SensorType *sensor * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, float *resolution); +int32_t OH_Sensor_GetSensorResolution(Sensor_DeviceInfo* sensor, float *resolution); /** * @brief Obtains the minimum data reporting interval of a sensor. @@ -254,7 +254,7 @@ int32_t OH_Sensor_GetSensorResolution(Sensor_Sensor* sensor, float *resolution); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetMinSamplingInterval(Sensor_Sensor* sensor, int64_t *minSamplingInterval); +int32_t OH_Sensor_GetMinSamplingInterval(Sensor_DeviceInfo* sensor, int64_t *minSamplingInterval); /** * @brief Obtains the maximum data reporting interval of a sensor. @@ -265,13 +265,13 @@ int32_t OH_Sensor_GetMinSamplingInterval(Sensor_Sensor* sensor, int64_t *minSamp * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetMaxSamplingInterval(Sensor_Sensor* sensor, int64_t *maxSamplingInterval); +int32_t OH_Sensor_GetMaxSamplingInterval(Sensor_DeviceInfo* sensor, int64_t *maxSamplingInterval); /** * @brief Defines the sensor data information. * @since 11 */ -typedef struct Sensor_SensorEvent Sensor_SensorEvent; +typedef struct Sensor_Event Sensor_Event; /** * @brief Obtains the sensor type. @@ -282,7 +282,7 @@ typedef struct Sensor_SensorEvent Sensor_SensorEvent; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetEventSensorType(Sensor_SensorEvent* sensorEvent, Sensor_SensorType *sensorType); +int32_t OH_Sensor_GetEventSensorType(Sensor_Event* sensorEvent, Sensor_Type *sensorType); /** * @brief Obtains the timestamp of sensor data. @@ -293,7 +293,7 @@ int32_t OH_Sensor_GetEventSensorType(Sensor_SensorEvent* sensorEvent, Sensor_Sen * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetEventTimestamp(Sensor_SensorEvent* sensorEvent, int64_t *timestamp); +int32_t OH_Sensor_GetEventTimestamp(Sensor_Event* sensorEvent, int64_t *timestamp); /** * @brief Obtains the accuracy of sensor data. @@ -304,7 +304,7 @@ int32_t OH_Sensor_GetEventTimestamp(Sensor_SensorEvent* sensorEvent, int64_t *ti * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetEventAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_SensorAccuracy *accuracy); +int32_t OH_Sensor_GetEventAccuracy(Sensor_Event* sensorEvent, Sensor_DataAccuracy *accuracy); /** * @brief Obtains sensor data. The data length and content depend on the sensor type. @@ -339,32 +339,32 @@ int32_t OH_Sensor_GetEventAccuracy(Sensor_SensorEvent* sensorEvent, Sensor_Senso * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorData(Sensor_SensorEvent* sensorEvent, float **data, uint32_t *length); +int32_t OH_Sensor_GetSensorData(Sensor_Event* sensorEvent, float **data, uint32_t *length); /** * @brief Defines the sensor subscription ID, which uniquely identifies a sensor. * @since 11 */ -typedef struct Sensor_SensorSubscriptionId Sensor_SensorSubscriptionId; +typedef struct Sensor_SubscriptionId Sensor_SubscriptionId; /** - * @brief Creates a {@link Sensor_SensorSubscriptionId} instance. + * @brief Creates a {@link Sensor_SubscriptionId} instance. * - * @return Returns the pointer to the {@link Sensor_SensorSubscriptionId} instance if the operation is successful; + * @return Returns the pointer to the {@link Sensor_SubscriptionId} instance if the operation is successful; * returns NULL otherwise. * @since 11 */ -Sensor_SensorSubscriptionId *OH_Sensor_CreateSubscriptionId(void); +Sensor_SubscriptionId *OH_Sensor_CreateSubscriptionId(void); /** - * @brief Destroys a {@link Sensor_SensorSubscriptionId} instance and reclaims memory. + * @brief Destroys a {@link Sensor_SubscriptionId} instance and reclaims memory. * - * @param id - Pointer to the {@link Sensor_SensorSubscriptionId} instance. + * @param id - Pointer to the {@link Sensor_SubscriptionId} instance. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroySubscriptionId(Sensor_SensorSubscriptionId *id); +int32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id); /** * @brief Obtains the sensor type. @@ -375,7 +375,7 @@ int32_t OH_Sensor_DestroySubscriptionId(Sensor_SensorSubscriptionId *id); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSubscriptionSensorType(Sensor_SensorSubscriptionId* id, Sensor_SensorType *sensorType); +int32_t OH_Sensor_GetSubscriptionSensorType(Sensor_SubscriptionId* id, Sensor_Type *sensorType); /** * @brief Sets the sensor type. @@ -386,7 +386,7 @@ int32_t OH_Sensor_GetSubscriptionSensorType(Sensor_SensorSubscriptionId* id, Sen * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSubscriptionSensorType(Sensor_SensorSubscriptionId* id, const Sensor_SensorType sensorType); +int32_t OH_Sensor_SetSubscriptionSensorType(Sensor_SubscriptionId* id, const Sensor_Type sensorType); /** * @brief Defines the sensor subscription attribute. @@ -439,7 +439,7 @@ int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, i * @brief Defines the callback function used to report sensor data. * @since 11 */ -typedef void (*Sensor_SensorCallback)(Sensor_SensorEvent *event); +typedef void (*Sensor_EventCallback)(Sensor_Event *event); /** * @brief Defines the sensor subscriber information. @@ -475,7 +475,7 @@ int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSensorCallback(Sensor_Subscriber* subscriber, const Sensor_SensorCallback callback); +int32_t OH_Sensor_SetSensorCallback(Sensor_Subscriber* subscriber, const Sensor_EventCallback callback); /** * @brief Obtains the callback function used to report sensor data. @@ -486,7 +486,7 @@ int32_t OH_Sensor_SetSensorCallback(Sensor_Subscriber* subscriber, const Sensor_ * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorCallback(Sensor_Subscriber* subscriber, Sensor_SensorCallback *callback); +int32_t OH_Sensor_GetSensorCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback); #ifdef __cplusplus } #endif -- Gitee From ed4ce9d2d90868e7a5e4128e34adb3758c5e6a40 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 30 Nov 2023 14:38:46 +0000 Subject: [PATCH 26/33] update Signed-off-by: hellohyh001 Change-Id: I17e72510bd434492637153c624af054916cc929d --- sensors/sensor/native_sensor_type.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/native_sensor_type.h index 23dbf23b7aa..3ea09ae2ff3 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/native_sensor_type.h @@ -182,7 +182,8 @@ typedef struct Sensor_DeviceInfo Sensor_DeviceInfo; * @brief Creates an array of {@link Sensor_DeviceInfo} instances with the given number. * * @param count - Number of {@link Sensor_DeviceInfo} instances to create. - * @return Returns the double pointer to the array of {@link Sensor_DeviceInfo} instances if the operation is successful; + * @return Returns the double pointer to the array of {@link Sensor_DeviceInfo} instances + * if the operation is successful; * returns NULL otherwise. * @since 11 */ -- Gitee From 61e924ccc11b2f2beaf677f9f05b80de0a0a341a Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Fri, 1 Dec 2023 02:06:12 +0000 Subject: [PATCH 27/33] update Signed-off-by: hellohyh001 Change-Id: I8fab206e29bde01fc4a0d894b9f3b918dab68b1e --- sensors/sensor/BUILD.gn | 7 +- sensors/sensor/libsensor.ndk.json | 54 +++++++------- .../sensor/{native_sensor.h => oh_sensor.h} | 12 ++-- ...{native_sensor_type.h => oh_sensor_type.h} | 70 ++++++++++--------- 4 files changed, 72 insertions(+), 71 deletions(-) rename sensors/sensor/{native_sensor.h => oh_sensor.h} (90%) rename sensors/sensor/{native_sensor_type.h => oh_sensor_type.h} (84%) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index 67be6997330..3629fa7aa58 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -17,14 +17,13 @@ import("//build/ohos/ndk/ndk.gni") ohos_ndk_headers("sensor_ndk_header") { dest_dir = "$ndk_headers_out_dir/sensors/sensor" sources = [ - "./native_sensor.h", - "./native_sensor_type.h", + "./oh_sensor.h", + "./oh_sensor_type.h", ] } ohos_ndk_library("libsensor_ndk") { ndk_description_file = "./libsensor.ndk.json" - output_name = "sensor_native" - output_extension = "z.so" + output_name = "ohsensor" min_compact_version = "11" } diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json index 8a761a0bd78..83f1f65b80b 100644 --- a/sensors/sensor/libsensor.ndk.json +++ b/sensors/sensor/libsensor.ndk.json @@ -1,83 +1,83 @@ [ { - "name": "OH_Sensor_GetAllSensors" + "name": "OH_Sensor_GetInfos" }, { - "name": "OH_Sensor_SubscribeSensor" + "name": "OH_Sensor_Subscribe" }, { - "name": "OH_Sensor_UnsubscribeSensor" + "name": "OH_Sensor_Unsubscribe" }, { - "name": "OH_Sensor_GetSensorName" + "name": "OH_SensorInfo_GetName" }, { - "name": "OH_Sensor_GetVendorName" + "name": "OH_SensorInfo_GetVendorName" }, { - "name": "OH_Sensor_GetSensorType" + "name": "OH_SensorInfo_GetType" }, { - "name": "OH_Sensor_GetSensorResolution" + "name": "OH_SensorInfo_GetResolution" }, { - "name": "OH_Sensor_GetMinSamplingInterval" + "name": "OH_SensorInfo_GetMinSamplingInterval" }, { - "name": "OH_Sensor_GetMaxSamplingInterval" + "name": "OH_SensorInfo_GetMaxSamplingInterval" }, { - "name": "OH_Sensor_GetEventSensorType" + "name": "OH_SensorEvent_GetType" }, { - "name": "OH_Sensor_GetEventTimestamp" + "name": "OH_SensorEvent_GetTimestamp" }, { - "name": "OH_Sensor_GetEventAccuracy" + "name": "OH_SensorEvent_GetAccuracy" }, { - "name": "OH_Sensor_GetSensorData" + "name": "OH_SensorEvent_GetData" }, { - "name": "OH_Sensor_GetSubscriptionSensorType" + "name": "OH_SensorSubscriptionId_GetType" }, { - "name": "OH_Sensor_SetSubscriptionSensorType" + "name": "OH_SensorSubscriptionId_SetType" }, { - "name": "OH_Sensor_SetSamplingInterval" + "name": "OH_SensorSubscriptionAttribute_SetSamplingInterval" }, { - "name": "OH_Sensor_GetSamplingInterval" + "name": "OH_SensorSubscriptionAttribute_GetSamplingInterval" }, { - "name": "OH_Sensor_SetSensorCallback" + "name": "OH_SensorSubscriber_SetCallback" }, { - "name": "OH_Sensor_GetSensorCallback" + "name": "OH_SensorSubscriber_GetCallback" }, { - "name": "OH_Sensor_CreateSensors" + "name": "OH_SensorInfo_Create" }, { - "name": "OH_Sensor_DestroySensors" + "name": "OH_SensorInfo_Destroy" }, { - "name": "OH_Sensor_CreateSubscriptionId" + "name": "OH_SensorSubscriptionId_Create" }, { - "name": "OH_Sensor_DestroySubscriptionId" + "name": "OH_SensorSubscriptionId_Destroy" }, { - "name": "OH_Sensor_CreateAttribute" + "name": "OH_SensorSubscriptionAttribute_Create" }, { - "name": "OH_Sensor_DestroyAttribute" + "name": "OH_SensorSubscriptionAttribute_Destroy" }, { - "name": "OH_Sensor_CreateSubscriber" + "name": "OH_SensorSubscriber_Create" }, { - "name": "OH_Sensor_DestroySubscriber" + "name": "OH_SensorSubscriber_Destroy" } ] \ No newline at end of file diff --git a/sensors/sensor/native_sensor.h b/sensors/sensor/oh_sensor.h similarity index 90% rename from sensors/sensor/native_sensor.h rename to sensors/sensor/oh_sensor.h index 776847cf687..9655d8ecdca 100644 --- a/sensors/sensor/native_sensor.h +++ b/sensors/sensor/oh_sensor.h @@ -26,7 +26,7 @@ * * @brief Declares the APIs for operating sensors, including obtaining sensor information and subscribing to or * unsubscribing from sensor data. - * @library libsensor_native.z.so + * @library libohsensor.so * @syscap SystemCapability.Sensors.Sensor * @since 11 */ @@ -42,15 +42,15 @@ extern "C" { /** * @brief Obtains information about all sensors on the device. * - * @param sensors - Double pointer to the information about all sensors on the device. - * For details, see {@link Sensor_DeviceInfo}. + * @param infos - Double pointer to the information about all sensors on the device. + * For details, see {@link Sensor_Info}. * @param count - Pointer to the number of sensors on the device. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * * @since 11 */ -Sensor_Result OH_Sensor_GetAllSensors(Sensor_DeviceInfo **sensors, uint32_t *count); +Sensor_Result OH_Sensor_GetInfos(Sensor_Info **infos, uint32_t *count); /** * @brief Subscribes to sensor data. The system will report sensor data to the subscriber at the specified frequency. @@ -71,7 +71,7 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_DeviceInfo **sensors, uint32_t *cou * ohos.permission.ACTIVITY_MOTION or ohos.permission.READ_HEALTH_DATA * @since 11 */ -Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SubscriptionId *id, +Sensor_Result OH_Sensor_Subscribe(const Sensor_SubscriptionId *id, const Sensor_SubscriptionAttribute *attribute, const Sensor_Subscriber *subscriber); /** @@ -92,7 +92,7 @@ Sensor_Result OH_Sensor_SubscribeSensor(const Sensor_SubscriptionId *id, * * @since 11 */ -Sensor_Result OH_Sensor_UnsubscribeSensor(const Sensor_SubscriptionId *id, const Sensor_Subscriber *subscriber); +Sensor_Result OH_Sensor_Unsubscribe(const Sensor_SubscriptionId *id, const Sensor_Subscriber *subscriber); #ifdef __cplusplus } #endif diff --git a/sensors/sensor/native_sensor_type.h b/sensors/sensor/oh_sensor_type.h similarity index 84% rename from sensors/sensor/native_sensor_type.h rename to sensors/sensor/oh_sensor_type.h index 3ea09ae2ff3..69204544695 100644 --- a/sensors/sensor/native_sensor_type.h +++ b/sensors/sensor/oh_sensor_type.h @@ -26,7 +26,7 @@ * @file native_sensor_type.h * * @brief Declares the common sensor attributes. - * @library libsensor_native.z.so + * @library libohsensor.so * @syscap SystemCapability.Sensors.Sensor * @since 11 */ @@ -147,7 +147,7 @@ typedef enum Sensor_Result { * * @since 11 */ -typedef enum Sensor_DataAccuracy { +typedef enum Sensor_Accuracy { /** * The sensor data is unreliable. It is possible that the sensor does not contact with the device to measure. * @since 11 @@ -170,35 +170,35 @@ typedef enum Sensor_DataAccuracy { * @since 11 */ SENSOR_ACCURACY_HIGH = 3 -} Sensor_DataAccuracy; +} Sensor_Accuracy; /** * @brief Defines the sensor information. * @since 11 */ -typedef struct Sensor_DeviceInfo Sensor_DeviceInfo; +typedef struct Sensor_Info Sensor_Info; /** - * @brief Creates an array of {@link Sensor_DeviceInfo} instances with the given number. + * @brief Creates an array of {@link Sensor_Info} instances with the given number. * - * @param count - Number of {@link Sensor_DeviceInfo} instances to create. - * @return Returns the double pointer to the array of {@link Sensor_DeviceInfo} instances + * @param count - Number of {@link Sensor_Info} instances to create. + * @return Returns the double pointer to the array of {@link Sensor_Info} instances * if the operation is successful; * returns NULL otherwise. * @since 11 */ -Sensor_DeviceInfo **OH_Sensor_CreateSensors(uint32_t count); +Sensor_Info **OH_SensorInfo_Create(uint32_t count); /** - * @brief Destroys an array of {@link Sensor_DeviceInfo} instances and reclaims memory. + * @brief Destroys an array of {@link Sensor_Info} instances and reclaims memory. * - * @param sensors - Double pointer to the array of {@link Sensor_DeviceInfo} instances. - * @param count - Number of {@link Sensor_DeviceInfo} instances to destroy. + * @param sensors - Double pointer to the array of {@link Sensor_Info} instances. + * @param count - Number of {@link Sensor_Info} instances to destroy. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroySensors(Sensor_DeviceInfo **sensors, uint32_t count); +int32_t OH_SensorInfo_Destroy(Sensor_Info **sensors, uint32_t count); /** * @brief Obtains the sensor name. @@ -210,7 +210,7 @@ int32_t OH_Sensor_DestroySensors(Sensor_DeviceInfo **sensors, uint32_t count); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorName(Sensor_DeviceInfo* sensor, char *sensorName, uint32_t *length); +int32_t OH_SensorInfo_GetName(Sensor_Info* sensor, char *sensorName, uint32_t *length); /** * @brief Obtains the sensor's vendor name. @@ -222,7 +222,7 @@ int32_t OH_Sensor_GetSensorName(Sensor_DeviceInfo* sensor, char *sensorName, uin * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetVendorName(Sensor_DeviceInfo* sensor, char *vendorName, uint32_t *length); +int32_t OH_SensorInfo_GetVendorName(Sensor_Info* sensor, char *vendorName, uint32_t *length); /** * @brief Obtains the sensor type. @@ -233,7 +233,7 @@ int32_t OH_Sensor_GetVendorName(Sensor_DeviceInfo* sensor, char *vendorName, uin * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorType(Sensor_DeviceInfo* sensor, Sensor_Type *sensorType); +int32_t OH_SensorInfo_GetType(Sensor_Info* sensor, Sensor_Type *sensorType); /** * @brief Obtains the sensor resolution. @@ -244,7 +244,7 @@ int32_t OH_Sensor_GetSensorType(Sensor_DeviceInfo* sensor, Sensor_Type *sensorTy * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorResolution(Sensor_DeviceInfo* sensor, float *resolution); +int32_t OH_SensorInfo_GetResolution(Sensor_Info* sensor, float *resolution); /** * @brief Obtains the minimum data reporting interval of a sensor. @@ -255,7 +255,7 @@ int32_t OH_Sensor_GetSensorResolution(Sensor_DeviceInfo* sensor, float *resoluti * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetMinSamplingInterval(Sensor_DeviceInfo* sensor, int64_t *minSamplingInterval); +int32_t OH_SensorInfo_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minSamplingInterval); /** * @brief Obtains the maximum data reporting interval of a sensor. @@ -266,7 +266,7 @@ int32_t OH_Sensor_GetMinSamplingInterval(Sensor_DeviceInfo* sensor, int64_t *min * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetMaxSamplingInterval(Sensor_DeviceInfo* sensor, int64_t *maxSamplingInterval); +int32_t OH_SensorInfo_GetMaxSamplingInterval(Sensor_Info* sensor, int64_t *maxSamplingInterval); /** * @brief Defines the sensor data information. @@ -283,7 +283,7 @@ typedef struct Sensor_Event Sensor_Event; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetEventSensorType(Sensor_Event* sensorEvent, Sensor_Type *sensorType); +int32_t OH_SensorEvent_GetType(Sensor_Event* sensorEvent, Sensor_Type *sensorType); /** * @brief Obtains the timestamp of sensor data. @@ -294,7 +294,7 @@ int32_t OH_Sensor_GetEventSensorType(Sensor_Event* sensorEvent, Sensor_Type *sen * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetEventTimestamp(Sensor_Event* sensorEvent, int64_t *timestamp); +int32_t OH_SensorEvent_GetTimestamp(Sensor_Event* sensorEvent, int64_t *timestamp); /** * @brief Obtains the accuracy of sensor data. @@ -305,7 +305,7 @@ int32_t OH_Sensor_GetEventTimestamp(Sensor_Event* sensorEvent, int64_t *timestam * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetEventAccuracy(Sensor_Event* sensorEvent, Sensor_DataAccuracy *accuracy); +int32_t OH_SensorEvent_GetAccuracy(Sensor_Event* sensorEvent, Sensor_Accuracy *accuracy); /** * @brief Obtains sensor data. The data length and content depend on the sensor type. @@ -340,7 +340,7 @@ int32_t OH_Sensor_GetEventAccuracy(Sensor_Event* sensorEvent, Sensor_DataAccurac * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorData(Sensor_Event* sensorEvent, float **data, uint32_t *length); +int32_t OH_SensorEvent_GetData(Sensor_Event* sensorEvent, float **data, uint32_t *length); /** * @brief Defines the sensor subscription ID, which uniquely identifies a sensor. @@ -355,7 +355,7 @@ typedef struct Sensor_SubscriptionId Sensor_SubscriptionId; * returns NULL otherwise. * @since 11 */ -Sensor_SubscriptionId *OH_Sensor_CreateSubscriptionId(void); +Sensor_SubscriptionId *OH_SensorSubscriptionId_Create(void); /** * @brief Destroys a {@link Sensor_SubscriptionId} instance and reclaims memory. @@ -365,7 +365,7 @@ Sensor_SubscriptionId *OH_Sensor_CreateSubscriptionId(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id); +int32_t OH_SensorSubscriptionId_Destroy(Sensor_SubscriptionId *id); /** * @brief Obtains the sensor type. @@ -376,7 +376,7 @@ int32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSubscriptionSensorType(Sensor_SubscriptionId* id, Sensor_Type *sensorType); +int32_t OH_SensorSubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type *sensorType); /** * @brief Sets the sensor type. @@ -387,7 +387,7 @@ int32_t OH_Sensor_GetSubscriptionSensorType(Sensor_SubscriptionId* id, Sensor_Ty * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSubscriptionSensorType(Sensor_SubscriptionId* id, const Sensor_Type sensorType); +int32_t OH_SensorSubscriptionId_SetType(Sensor_SubscriptionId* id, const Sensor_Type sensorType); /** * @brief Defines the sensor subscription attribute. @@ -402,7 +402,7 @@ typedef struct Sensor_SubscriptionAttribute Sensor_SubscriptionAttribute; * returns NULL otherwise. * @since 11 */ -Sensor_SubscriptionAttribute *OH_Sensor_CreateAttribute(void); +Sensor_SubscriptionAttribute *OH_SensorSubscriptionAttribute_Create(void); /** * @brief Destroys a {@link Sensor_SubscriptionAttribute} instance and reclaims memory. @@ -412,7 +412,7 @@ Sensor_SubscriptionAttribute *OH_Sensor_CreateAttribute(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroyAttribute(Sensor_SubscriptionAttribute *attribute); +int32_t OH_SensorSubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *attribute); /** * @brief Sets the sensor data reporting interval. @@ -423,7 +423,8 @@ int32_t OH_Sensor_DestroyAttribute(Sensor_SubscriptionAttribute *attribute); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, const int64_t samplingInterval); +int32_t OH_SensorSubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, + const int64_t samplingInterval); /** * @brief Obtains the sensor data reporting interval. @@ -434,7 +435,8 @@ int32_t OH_Sensor_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, c * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, int64_t *samplingInterval); +int32_t OH_SensorSubscriptionAttribute_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, + int64_t *samplingInterval); /** * @brief Defines the callback function used to report sensor data. @@ -455,7 +457,7 @@ typedef struct Sensor_Subscriber Sensor_Subscriber; * if the operation is successful; returns NULL otherwise. * @since 11 */ -Sensor_Subscriber *OH_Sensor_CreateSubscriber(void); +Sensor_Subscriber *OH_SensorSubscriber_Create(void); /** * @brief Destroys a {@link Sensor_Subscriber} instance and reclaims memory. @@ -465,7 +467,7 @@ Sensor_Subscriber *OH_Sensor_CreateSubscriber(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber); +int32_t OH_SensorSubscriber_Destroy(Sensor_Subscriber *subscriber); /** * @brief Sets a callback function to report sensor data. @@ -476,7 +478,7 @@ int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SetSensorCallback(Sensor_Subscriber* subscriber, const Sensor_EventCallback callback); +int32_t OH_SensorSubscriber_SetCallback(Sensor_Subscriber* subscriber, const Sensor_EventCallback callback); /** * @brief Obtains the callback function used to report sensor data. @@ -487,7 +489,7 @@ int32_t OH_Sensor_SetSensorCallback(Sensor_Subscriber* subscriber, const Sensor_ * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_GetSensorCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback); +int32_t OH_SensorSubscriber_GetCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback); #ifdef __cplusplus } #endif -- Gitee From 1d8379dd13ca314f6c71b386a69b4f7aa88f056b Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Fri, 1 Dec 2023 02:43:46 +0000 Subject: [PATCH 28/33] upate Signed-off-by: hellohyh001 Change-Id: I997382632e94ee05b253d07714cf6ac38606da0b --- sensors/sensor/libsensor.ndk.json | 48 +++++++++++++------------- sensors/sensor/oh_sensor_type.h | 56 +++++++++++++++---------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json index 83f1f65b80b..eb6d417d96b 100644 --- a/sensors/sensor/libsensor.ndk.json +++ b/sensors/sensor/libsensor.ndk.json @@ -9,75 +9,75 @@ "name": "OH_Sensor_Unsubscribe" }, { - "name": "OH_SensorInfo_GetName" + "name": "OH_Sensor_Info_GetName" }, { - "name": "OH_SensorInfo_GetVendorName" + "name": "OH_Sensor_Info_GetVendorName" }, { - "name": "OH_SensorInfo_GetType" + "name": "OH_Sensor_Info_GetType" }, { - "name": "OH_SensorInfo_GetResolution" + "name": "OH_Sensor_Info_GetResolution" }, { - "name": "OH_SensorInfo_GetMinSamplingInterval" + "name": "OH_Sensor_Info_GetMinSamplingInterval" }, { - "name": "OH_SensorInfo_GetMaxSamplingInterval" + "name": "OH_Sensor_Info_GetMaxSamplingInterval" }, { - "name": "OH_SensorEvent_GetType" + "name": "OH_Sensor_Event_GetType" }, { - "name": "OH_SensorEvent_GetTimestamp" + "name": "OH_Sensor_Event_GetTimestamp" }, { - "name": "OH_SensorEvent_GetAccuracy" + "name": "OH_Sensor_Event_GetAccuracy" }, { - "name": "OH_SensorEvent_GetData" + "name": "OH_Sensor_Event_GetData" }, { - "name": "OH_SensorSubscriptionId_GetType" + "name": "OH_Sensor_SubscriptionId_GetType" }, { - "name": "OH_SensorSubscriptionId_SetType" + "name": "OH_Sensor_SubscriptionId_SetType" }, { - "name": "OH_SensorSubscriptionAttribute_SetSamplingInterval" + "name": "OH_Sensor_SubscriptionAttribute_SetSamplingInterval" }, { - "name": "OH_SensorSubscriptionAttribute_GetSamplingInterval" + "name": "OH_Sensor_SubscriptionAttribute_GetSamplingInterval" }, { - "name": "OH_SensorSubscriber_SetCallback" + "name": "OH_Sensor_Subscriber_SetCallback" }, { - "name": "OH_SensorSubscriber_GetCallback" + "name": "OH_Sensor_Subscriber_GetCallback" }, { - "name": "OH_SensorInfo_Create" + "name": "OH_Sensor_Info_Create" }, { - "name": "OH_SensorInfo_Destroy" + "name": "OH_Sensor_Info_Destroy" }, { - "name": "OH_SensorSubscriptionId_Create" + "name": "OH_Sensor_SubscriptionId_Create" }, { - "name": "OH_SensorSubscriptionId_Destroy" + "name": "OH_Sensor_SubscriptionId_Destroy" }, { - "name": "OH_SensorSubscriptionAttribute_Create" + "name": "OH_Sensor_SubscriptionAttribute_Create" }, { - "name": "OH_SensorSubscriptionAttribute_Destroy" + "name": "OH_Sensor_SubscriptionAttribute_Destroy" }, { - "name": "OH_SensorSubscriber_Create" + "name": "OH_Sensor_Subscriber_Create" }, { - "name": "OH_SensorSubscriber_Destroy" + "name": "OH_Sensor_Subscriber_Destroy" } ] \ No newline at end of file diff --git a/sensors/sensor/oh_sensor_type.h b/sensors/sensor/oh_sensor_type.h index 69204544695..a13c61723c7 100644 --- a/sensors/sensor/oh_sensor_type.h +++ b/sensors/sensor/oh_sensor_type.h @@ -187,7 +187,7 @@ typedef struct Sensor_Info Sensor_Info; * returns NULL otherwise. * @since 11 */ -Sensor_Info **OH_SensorInfo_Create(uint32_t count); +Sensor_Info **OH_Sensor_Info_Create(uint32_t count); /** * @brief Destroys an array of {@link Sensor_Info} instances and reclaims memory. @@ -198,7 +198,7 @@ Sensor_Info **OH_SensorInfo_Create(uint32_t count); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorInfo_Destroy(Sensor_Info **sensors, uint32_t count); +int32_t OH_Sensor_Info_Destroy(Sensor_Info **sensors, uint32_t count); /** * @brief Obtains the sensor name. @@ -210,7 +210,7 @@ int32_t OH_SensorInfo_Destroy(Sensor_Info **sensors, uint32_t count); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorInfo_GetName(Sensor_Info* sensor, char *sensorName, uint32_t *length); +int32_t OH_Sensor_Info_GetName(Sensor_Info* sensor, char *sensorName, uint32_t *length); /** * @brief Obtains the sensor's vendor name. @@ -222,7 +222,7 @@ int32_t OH_SensorInfo_GetName(Sensor_Info* sensor, char *sensorName, uint32_t *l * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorInfo_GetVendorName(Sensor_Info* sensor, char *vendorName, uint32_t *length); +int32_t OH_Sensor_Info_GetVendorName(Sensor_Info* sensor, char *vendorName, uint32_t *length); /** * @brief Obtains the sensor type. @@ -233,7 +233,7 @@ int32_t OH_SensorInfo_GetVendorName(Sensor_Info* sensor, char *vendorName, uint3 * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorInfo_GetType(Sensor_Info* sensor, Sensor_Type *sensorType); +int32_t OH_Sensor_Info_GetType(Sensor_Info* sensor, Sensor_Type *sensorType); /** * @brief Obtains the sensor resolution. @@ -244,7 +244,7 @@ int32_t OH_SensorInfo_GetType(Sensor_Info* sensor, Sensor_Type *sensorType); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorInfo_GetResolution(Sensor_Info* sensor, float *resolution); +int32_t OH_Sensor_Info_GetResolution(Sensor_Info* sensor, float *resolution); /** * @brief Obtains the minimum data reporting interval of a sensor. @@ -255,7 +255,7 @@ int32_t OH_SensorInfo_GetResolution(Sensor_Info* sensor, float *resolution); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorInfo_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minSamplingInterval); +int32_t OH_Sensor_Info_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minSamplingInterval); /** * @brief Obtains the maximum data reporting interval of a sensor. @@ -266,7 +266,7 @@ int32_t OH_SensorInfo_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minSa * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorInfo_GetMaxSamplingInterval(Sensor_Info* sensor, int64_t *maxSamplingInterval); +int32_t OH_Sensor_Info_GetMaxSamplingInterval(Sensor_Info* sensor, int64_t *maxSamplingInterval); /** * @brief Defines the sensor data information. @@ -277,35 +277,35 @@ typedef struct Sensor_Event Sensor_Event; /** * @brief Obtains the sensor type. * - * @param sensorEvent - Pointer to the sensor data information. + * @param Sensor_Event - Pointer to the sensor data information. * @param sensorType - Pointer to the sensor type. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorEvent_GetType(Sensor_Event* sensorEvent, Sensor_Type *sensorType); +int32_t OH_Sensor_Event_GetType(Sensor_Event* Sensor_Event, Sensor_Type *sensorType); /** * @brief Obtains the timestamp of sensor data. * - * @param sensorEvent - Pointer to the sensor data information. + * @param Sensor_Event - Pointer to the sensor data information. * @param timestamp - Pointer to the timestamp. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorEvent_GetTimestamp(Sensor_Event* sensorEvent, int64_t *timestamp); +int32_t OH_Sensor_Event_GetTimestamp(Sensor_Event* Sensor_Event, int64_t *timestamp); /** * @brief Obtains the accuracy of sensor data. * - * @param sensorEvent - Pointer to the sensor data information. + * @param Sensor_Event - Pointer to the sensor data information. * @param accuracy - Pointer to the accuracy. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorEvent_GetAccuracy(Sensor_Event* sensorEvent, Sensor_Accuracy *accuracy); +int32_t OH_Sensor_Event_GetAccuracy(Sensor_Event* Sensor_Event, Sensor_Accuracy *accuracy); /** * @brief Obtains sensor data. The data length and content depend on the sensor type. @@ -333,14 +333,14 @@ int32_t OH_SensorEvent_GetAccuracy(Sensor_Event* sensorEvent, Sensor_Accuracy *a * SENSOR_TYPE_PEDOMETER: data[0], indicating the number of steps a user has walked. * SENSOR_TYPE_HEART_RATE: data[0], indicating the heart rate value. * - * @param sensorEvent - Pointer to the sensor data information. + * @param Sensor_Event - Pointer to the sensor data information. * @param data - Double pointer to the sensor data. * @param length - Pointer to the array length. * @return Returns SENSOR_SUCCESS if the operation is successful; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorEvent_GetData(Sensor_Event* sensorEvent, float **data, uint32_t *length); +int32_t OH_Sensor_Event_GetData(Sensor_Event* Sensor_Event, float **data, uint32_t *length); /** * @brief Defines the sensor subscription ID, which uniquely identifies a sensor. @@ -355,7 +355,7 @@ typedef struct Sensor_SubscriptionId Sensor_SubscriptionId; * returns NULL otherwise. * @since 11 */ -Sensor_SubscriptionId *OH_SensorSubscriptionId_Create(void); +Sensor_SubscriptionId *OH_Sensor_SubscriptionId_Create(void); /** * @brief Destroys a {@link Sensor_SubscriptionId} instance and reclaims memory. @@ -365,7 +365,7 @@ Sensor_SubscriptionId *OH_SensorSubscriptionId_Create(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriptionId_Destroy(Sensor_SubscriptionId *id); +int32_t OH_Sensor_SubscriptionId_Destroy(Sensor_SubscriptionId *id); /** * @brief Obtains the sensor type. @@ -376,7 +376,7 @@ int32_t OH_SensorSubscriptionId_Destroy(Sensor_SubscriptionId *id); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type *sensorType); +int32_t OH_Sensor_SubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type *sensorType); /** * @brief Sets the sensor type. @@ -387,7 +387,7 @@ int32_t OH_SensorSubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type * * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriptionId_SetType(Sensor_SubscriptionId* id, const Sensor_Type sensorType); +int32_t OH_Sensor_SubscriptionId_SetType(Sensor_SubscriptionId* id, const Sensor_Type sensorType); /** * @brief Defines the sensor subscription attribute. @@ -402,7 +402,7 @@ typedef struct Sensor_SubscriptionAttribute Sensor_SubscriptionAttribute; * returns NULL otherwise. * @since 11 */ -Sensor_SubscriptionAttribute *OH_SensorSubscriptionAttribute_Create(void); +Sensor_SubscriptionAttribute *OH_Sensor_SubscriptionAttribute_Create(void); /** * @brief Destroys a {@link Sensor_SubscriptionAttribute} instance and reclaims memory. @@ -412,7 +412,7 @@ Sensor_SubscriptionAttribute *OH_SensorSubscriptionAttribute_Create(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *attribute); +int32_t OH_Sensor_SubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *attribute); /** * @brief Sets the sensor data reporting interval. @@ -423,7 +423,7 @@ int32_t OH_SensorSubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *att * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, +int32_t OH_Sensor_SubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, const int64_t samplingInterval); /** @@ -435,7 +435,7 @@ int32_t OH_SensorSubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionAt * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriptionAttribute_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, +int32_t OH_Sensor_SubscriptionAttribute_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, int64_t *samplingInterval); /** @@ -457,7 +457,7 @@ typedef struct Sensor_Subscriber Sensor_Subscriber; * if the operation is successful; returns NULL otherwise. * @since 11 */ -Sensor_Subscriber *OH_SensorSubscriber_Create(void); +Sensor_Subscriber *OH_Sensor_Subscriber_Create(void); /** * @brief Destroys a {@link Sensor_Subscriber} instance and reclaims memory. @@ -467,7 +467,7 @@ Sensor_Subscriber *OH_SensorSubscriber_Create(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriber_Destroy(Sensor_Subscriber *subscriber); +int32_t OH_Sensor_Subscriber_Destroy(Sensor_Subscriber *subscriber); /** * @brief Sets a callback function to report sensor data. @@ -478,7 +478,7 @@ int32_t OH_SensorSubscriber_Destroy(Sensor_Subscriber *subscriber); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriber_SetCallback(Sensor_Subscriber* subscriber, const Sensor_EventCallback callback); +int32_t OH_Sensor_Subscriber_SetCallback(Sensor_Subscriber* subscriber, const Sensor_EventCallback callback); /** * @brief Obtains the callback function used to report sensor data. @@ -489,7 +489,7 @@ int32_t OH_SensorSubscriber_SetCallback(Sensor_Subscriber* subscriber, const Sen * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_SensorSubscriber_GetCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback); +int32_t OH_Sensor_Subscriber_GetCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback); #ifdef __cplusplus } #endif -- Gitee From 13a0a40bf6a7a31af88028130b27358b7b871761 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Fri, 1 Dec 2023 02:47:32 +0000 Subject: [PATCH 29/33] update Signed-off-by: hellohyh001 Change-Id: I6d660393ff8e43028f6c5c8e44a03816691f9060 --- sensors/sensor/oh_sensor.h | 10 +++++----- sensors/sensor/oh_sensor_type.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sensors/sensor/oh_sensor.h b/sensors/sensor/oh_sensor.h index 9655d8ecdca..ee0d78c6a15 100644 --- a/sensors/sensor/oh_sensor.h +++ b/sensors/sensor/oh_sensor.h @@ -22,7 +22,7 @@ * @since 11 */ /** - * @file native_sensor.h + * @file oh_sensor.h * * @brief Declares the APIs for operating sensors, including obtaining sensor information and subscribing to or * unsubscribing from sensor data. @@ -31,10 +31,10 @@ * @since 11 */ -#ifndef OH_NATIVE_SENSOR_H -#define OH_NATIVE_SENSOR_H +#ifndef OH_SENSOR_H +#define OH_SENSOR_H -#include "native_sensor_type.h" +#include "oh_sensor_type.h" #ifdef __cplusplus extern "C" { @@ -96,4 +96,4 @@ Sensor_Result OH_Sensor_Unsubscribe(const Sensor_SubscriptionId *id, const Senso #ifdef __cplusplus } #endif -#endif // OH_NATIVE_SENSOR_H \ No newline at end of file +#endif // OH_SENSOR_H \ No newline at end of file diff --git a/sensors/sensor/oh_sensor_type.h b/sensors/sensor/oh_sensor_type.h index a13c61723c7..61ae622c063 100644 --- a/sensors/sensor/oh_sensor_type.h +++ b/sensors/sensor/oh_sensor_type.h @@ -23,7 +23,7 @@ */ /** - * @file native_sensor_type.h + * @file oh_sensor_type.h * * @brief Declares the common sensor attributes. * @library libohsensor.so @@ -31,8 +31,8 @@ * @since 11 */ -#ifndef OH_NATIVE_SENSOR_TYPE_H -#define OH_NATIVE_SENSOR_TYPE_H +#ifndef OH_SENSOR_TYPE_H +#define OH_SENSOR_TYPE_H #include @@ -493,4 +493,4 @@ int32_t OH_Sensor_Subscriber_GetCallback(Sensor_Subscriber* subscriber, Sensor_E #ifdef __cplusplus } #endif -#endif // OH_NATIVE_SENSOR_TYPE_H \ No newline at end of file +#endif // OH_SENSOR_TYPE_H \ No newline at end of file -- Gitee From a27592ce22b0b22d8fed0cebad8ab6603130f77b Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Sat, 2 Dec 2023 08:08:48 +0000 Subject: [PATCH 30/33] update Signed-off-by: hellohyh001 Change-Id: I91ab78524fbc2b962315cadedcca5d741c021e30 --- sensors/sensor/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index 3629fa7aa58..aca02c5cd11 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -25,5 +25,6 @@ ohos_ndk_headers("sensor_ndk_header") { ohos_ndk_library("libsensor_ndk") { ndk_description_file = "./libsensor.ndk.json" output_name = "ohsensor" + output_extension = "so" min_compact_version = "11" } -- Gitee From eb7b5fc44143c6a10756f4ffef48ee6a9d017f86 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Sat, 2 Dec 2023 08:24:24 +0000 Subject: [PATCH 31/33] update Signed-off-by: hellohyh001 Change-Id: Ie776fc30f6b079595d832d1a3795fc72df5908da --- sensors/sensor/libsensor.ndk.json | 16 ++++++++-------- sensors/sensor/oh_sensor_type.h | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json index eb6d417d96b..17acb13e899 100644 --- a/sensors/sensor/libsensor.ndk.json +++ b/sensors/sensor/libsensor.ndk.json @@ -57,27 +57,27 @@ "name": "OH_Sensor_Subscriber_GetCallback" }, { - "name": "OH_Sensor_Info_Create" + "name": "OH_Sensor_CreateInfos" }, { - "name": "OH_Sensor_Info_Destroy" + "name": "OH_Sensor_DestroyInfos" }, { - "name": "OH_Sensor_SubscriptionId_Create" + "name": "OH_Sensor_CreateSubscriptionId" }, { - "name": "OH_Sensor_SubscriptionId_Destroy" + "name": "OH_Sensor_DestroySubscriptionId" }, { - "name": "OH_Sensor_SubscriptionAttribute_Create" + "name": "OH_Sensor_CreateSubscriptionAttribute" }, { - "name": "OH_Sensor_SubscriptionAttribute_Destroy" + "name": "OH_Sensor_DestroySubscriptionAttribute" }, { - "name": "OH_Sensor_Subscriber_Create" + "name": "OH_Sensor_CreateSubscriber" }, { - "name": "OH_Sensor_Subscriber_Destroy" + "name": "OH_Sensor_DestroySubscriber" } ] \ No newline at end of file diff --git a/sensors/sensor/oh_sensor_type.h b/sensors/sensor/oh_sensor_type.h index 61ae622c063..8c55a40c79a 100644 --- a/sensors/sensor/oh_sensor_type.h +++ b/sensors/sensor/oh_sensor_type.h @@ -187,7 +187,7 @@ typedef struct Sensor_Info Sensor_Info; * returns NULL otherwise. * @since 11 */ -Sensor_Info **OH_Sensor_Info_Create(uint32_t count); +Sensor_Info **OH_Sensor_CreateInfos(uint32_t count); /** * @brief Destroys an array of {@link Sensor_Info} instances and reclaims memory. @@ -198,7 +198,7 @@ Sensor_Info **OH_Sensor_Info_Create(uint32_t count); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Info_Destroy(Sensor_Info **sensors, uint32_t count); +int32_t OH_Sensor_DestroyInfos(Sensor_Info **sensors, uint32_t count); /** * @brief Obtains the sensor name. @@ -355,7 +355,7 @@ typedef struct Sensor_SubscriptionId Sensor_SubscriptionId; * returns NULL otherwise. * @since 11 */ -Sensor_SubscriptionId *OH_Sensor_SubscriptionId_Create(void); +Sensor_SubscriptionId *OH_Sensor_CreateSubscriptionId(void); /** * @brief Destroys a {@link Sensor_SubscriptionId} instance and reclaims memory. @@ -365,7 +365,7 @@ Sensor_SubscriptionId *OH_Sensor_SubscriptionId_Create(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SubscriptionId_Destroy(Sensor_SubscriptionId *id); +int32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id); /** * @brief Obtains the sensor type. @@ -402,7 +402,7 @@ typedef struct Sensor_SubscriptionAttribute Sensor_SubscriptionAttribute; * returns NULL otherwise. * @since 11 */ -Sensor_SubscriptionAttribute *OH_Sensor_SubscriptionAttribute_Create(void); +Sensor_SubscriptionAttribute *OH_Sensor_CreateSubscriptionAttribute(void); /** * @brief Destroys a {@link Sensor_SubscriptionAttribute} instance and reclaims memory. @@ -412,7 +412,7 @@ Sensor_SubscriptionAttribute *OH_Sensor_SubscriptionAttribute_Create(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SubscriptionAttribute_Destroy(Sensor_SubscriptionAttribute *attribute); +int32_t OH_Sensor_DestroySubscriptionAttribute(Sensor_SubscriptionAttribute *attribute); /** * @brief Sets the sensor data reporting interval. @@ -457,7 +457,7 @@ typedef struct Sensor_Subscriber Sensor_Subscriber; * if the operation is successful; returns NULL otherwise. * @since 11 */ -Sensor_Subscriber *OH_Sensor_Subscriber_Create(void); +Sensor_Subscriber *OH_Sensor_CreateSubscriber(void); /** * @brief Destroys a {@link Sensor_Subscriber} instance and reclaims memory. @@ -467,7 +467,7 @@ Sensor_Subscriber *OH_Sensor_Subscriber_Create(void); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Subscriber_Destroy(Sensor_Subscriber *subscriber); +int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber); /** * @brief Sets a callback function to report sensor data. -- Gitee From 03ff4b164dea92a9ea999442f2b0947d598e980a Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Mon, 4 Dec 2023 09:19:09 +0000 Subject: [PATCH 32/33] update Signed-off-by: hellohyh001 Change-Id: I8f6d9661f672e17039a53850a73a9c794c3811ab --- sensors/sensor/libsensor.ndk.json | 32 +++++++++++++++---------------- sensors/sensor/oh_sensor_type.h | 32 +++++++++++++++---------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/sensors/sensor/libsensor.ndk.json b/sensors/sensor/libsensor.ndk.json index 17acb13e899..a3d5e8f8c51 100644 --- a/sensors/sensor/libsensor.ndk.json +++ b/sensors/sensor/libsensor.ndk.json @@ -9,52 +9,52 @@ "name": "OH_Sensor_Unsubscribe" }, { - "name": "OH_Sensor_Info_GetName" + "name": "OH_SensorInfo_GetName" }, { - "name": "OH_Sensor_Info_GetVendorName" + "name": "OH_SensorInfo_GetVendorName" }, { - "name": "OH_Sensor_Info_GetType" + "name": "OH_SensorInfo_GetType" }, { - "name": "OH_Sensor_Info_GetResolution" + "name": "OH_SensorInfo_GetResolution" }, { - "name": "OH_Sensor_Info_GetMinSamplingInterval" + "name": "OH_SensorInfo_GetMinSamplingInterval" }, { - "name": "OH_Sensor_Info_GetMaxSamplingInterval" + "name": "OH_SensorInfo_GetMaxSamplingInterval" }, { - "name": "OH_Sensor_Event_GetType" + "name": "OH_SensorEvent_GetType" }, { - "name": "OH_Sensor_Event_GetTimestamp" + "name": "OH_SensorEvent_GetTimestamp" }, { - "name": "OH_Sensor_Event_GetAccuracy" + "name": "OH_SensorEvent_GetAccuracy" }, { - "name": "OH_Sensor_Event_GetData" + "name": "OH_SensorEvent_GetData" }, { - "name": "OH_Sensor_SubscriptionId_GetType" + "name": "OH_SensorSubscriptionId_GetType" }, { - "name": "OH_Sensor_SubscriptionId_SetType" + "name": "OH_SensorSubscriptionId_SetType" }, { - "name": "OH_Sensor_SubscriptionAttribute_SetSamplingInterval" + "name": "OH_SensorSubscriptionAttribute_SetSamplingInterval" }, { - "name": "OH_Sensor_SubscriptionAttribute_GetSamplingInterval" + "name": "OH_SensorSubscriptionAttribute_GetSamplingInterval" }, { - "name": "OH_Sensor_Subscriber_SetCallback" + "name": "OH_SensorSubscriber_SetCallback" }, { - "name": "OH_Sensor_Subscriber_GetCallback" + "name": "OH_SensorSubscriber_GetCallback" }, { "name": "OH_Sensor_CreateInfos" diff --git a/sensors/sensor/oh_sensor_type.h b/sensors/sensor/oh_sensor_type.h index 8c55a40c79a..16f05c98c9d 100644 --- a/sensors/sensor/oh_sensor_type.h +++ b/sensors/sensor/oh_sensor_type.h @@ -210,7 +210,7 @@ int32_t OH_Sensor_DestroyInfos(Sensor_Info **sensors, uint32_t count); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Info_GetName(Sensor_Info* sensor, char *sensorName, uint32_t *length); +int32_t OH_SensorInfo_GetName(Sensor_Info* sensor, char *sensorName, uint32_t *length); /** * @brief Obtains the sensor's vendor name. @@ -222,7 +222,7 @@ int32_t OH_Sensor_Info_GetName(Sensor_Info* sensor, char *sensorName, uint32_t * * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Info_GetVendorName(Sensor_Info* sensor, char *vendorName, uint32_t *length); +int32_t OH_SensorInfo_GetVendorName(Sensor_Info* sensor, char *vendorName, uint32_t *length); /** * @brief Obtains the sensor type. @@ -233,7 +233,7 @@ int32_t OH_Sensor_Info_GetVendorName(Sensor_Info* sensor, char *vendorName, uint * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Info_GetType(Sensor_Info* sensor, Sensor_Type *sensorType); +int32_t OH_SensorInfo_GetType(Sensor_Info* sensor, Sensor_Type *sensorType); /** * @brief Obtains the sensor resolution. @@ -244,7 +244,7 @@ int32_t OH_Sensor_Info_GetType(Sensor_Info* sensor, Sensor_Type *sensorType); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Info_GetResolution(Sensor_Info* sensor, float *resolution); +int32_t OH_SensorInfo_GetResolution(Sensor_Info* sensor, float *resolution); /** * @brief Obtains the minimum data reporting interval of a sensor. @@ -255,7 +255,7 @@ int32_t OH_Sensor_Info_GetResolution(Sensor_Info* sensor, float *resolution); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Info_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minSamplingInterval); +int32_t OH_SensorInfo_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minSamplingInterval); /** * @brief Obtains the maximum data reporting interval of a sensor. @@ -266,7 +266,7 @@ int32_t OH_Sensor_Info_GetMinSamplingInterval(Sensor_Info* sensor, int64_t *minS * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Info_GetMaxSamplingInterval(Sensor_Info* sensor, int64_t *maxSamplingInterval); +int32_t OH_SensorInfo_GetMaxSamplingInterval(Sensor_Info* sensor, int64_t *maxSamplingInterval); /** * @brief Defines the sensor data information. @@ -283,7 +283,7 @@ typedef struct Sensor_Event Sensor_Event; * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Event_GetType(Sensor_Event* Sensor_Event, Sensor_Type *sensorType); +int32_t OH_SensorEvent_GetType(Sensor_Event* Sensor_Event, Sensor_Type *sensorType); /** * @brief Obtains the timestamp of sensor data. @@ -294,7 +294,7 @@ int32_t OH_Sensor_Event_GetType(Sensor_Event* Sensor_Event, Sensor_Type *sensorT * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Event_GetTimestamp(Sensor_Event* Sensor_Event, int64_t *timestamp); +int32_t OH_SensorEvent_GetTimestamp(Sensor_Event* Sensor_Event, int64_t *timestamp); /** * @brief Obtains the accuracy of sensor data. @@ -305,7 +305,7 @@ int32_t OH_Sensor_Event_GetTimestamp(Sensor_Event* Sensor_Event, int64_t *timest * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Event_GetAccuracy(Sensor_Event* Sensor_Event, Sensor_Accuracy *accuracy); +int32_t OH_SensorEvent_GetAccuracy(Sensor_Event* Sensor_Event, Sensor_Accuracy *accuracy); /** * @brief Obtains sensor data. The data length and content depend on the sensor type. @@ -340,7 +340,7 @@ int32_t OH_Sensor_Event_GetAccuracy(Sensor_Event* Sensor_Event, Sensor_Accuracy * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Event_GetData(Sensor_Event* Sensor_Event, float **data, uint32_t *length); +int32_t OH_SensorEvent_GetData(Sensor_Event* Sensor_Event, float **data, uint32_t *length); /** * @brief Defines the sensor subscription ID, which uniquely identifies a sensor. @@ -376,7 +376,7 @@ int32_t OH_Sensor_DestroySubscriptionId(Sensor_SubscriptionId *id); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type *sensorType); +int32_t OH_SensorSubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type *sensorType); /** * @brief Sets the sensor type. @@ -387,7 +387,7 @@ int32_t OH_Sensor_SubscriptionId_GetType(Sensor_SubscriptionId* id, Sensor_Type * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SubscriptionId_SetType(Sensor_SubscriptionId* id, const Sensor_Type sensorType); +int32_t OH_SensorSubscriptionId_SetType(Sensor_SubscriptionId* id, const Sensor_Type sensorType); /** * @brief Defines the sensor subscription attribute. @@ -423,7 +423,7 @@ int32_t OH_Sensor_DestroySubscriptionAttribute(Sensor_SubscriptionAttribute *att * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, +int32_t OH_SensorSubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionAttribute* attribute, const int64_t samplingInterval); /** @@ -435,7 +435,7 @@ int32_t OH_Sensor_SubscriptionAttribute_SetSamplingInterval(Sensor_SubscriptionA * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_SubscriptionAttribute_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, +int32_t OH_SensorSubscriptionAttribute_GetSamplingInterval(Sensor_SubscriptionAttribute* attribute, int64_t *samplingInterval); /** @@ -478,7 +478,7 @@ int32_t OH_Sensor_DestroySubscriber(Sensor_Subscriber *subscriber); * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Subscriber_SetCallback(Sensor_Subscriber* subscriber, const Sensor_EventCallback callback); +int32_t OH_SensorSubscriber_SetCallback(Sensor_Subscriber* subscriber, const Sensor_EventCallback callback); /** * @brief Obtains the callback function used to report sensor data. @@ -489,7 +489,7 @@ int32_t OH_Sensor_Subscriber_SetCallback(Sensor_Subscriber* subscriber, const Se * returns an error code defined in {@link Sensor_Result} otherwise. * @since 11 */ -int32_t OH_Sensor_Subscriber_GetCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback); +int32_t OH_SensorSubscriber_GetCallback(Sensor_Subscriber* subscriber, Sensor_EventCallback *callback); #ifdef __cplusplus } #endif -- Gitee From 4f3d29d1b068b4c78f6ff8dd35faf64fe28a9e98 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Thu, 7 Dec 2023 07:24:36 +0000 Subject: [PATCH 33/33] update Signed-off-by: hellohyh001 Change-Id: If44c8d25764dad5499650546a3635db3c3525b9e --- sensors/sensor/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/sensor/BUILD.gn b/sensors/sensor/BUILD.gn index aca02c5cd11..8a12ddf2ac2 100644 --- a/sensors/sensor/BUILD.gn +++ b/sensors/sensor/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") ohos_ndk_headers("sensor_ndk_header") { - dest_dir = "$ndk_headers_out_dir/sensors/sensor" + dest_dir = "$ndk_headers_out_dir/sensors" sources = [ "./oh_sensor.h", "./oh_sensor_type.h", -- Gitee