From 15fca695e094c475e86a30ef42a6b7dfde0e5b85 Mon Sep 17 00:00:00 2001 From: cff Date: Tue, 10 Oct 2023 02:47:42 +0000 Subject: [PATCH 1/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi.h | 88 ++++ zh-cn/native_sdk/sensor/sensor_capi_base.h | 481 +++++++++++++++++++++ 2 files changed, 569 insertions(+) create mode 100644 zh-cn/native_sdk/sensor/sensor_capi.h create mode 100644 zh-cn/native_sdk/sensor/sensor_capi_base.h diff --git a/zh-cn/native_sdk/sensor/sensor_capi.h b/zh-cn/native_sdk/sensor/sensor_capi.h new file mode 100644 index 00000000..c9df23fa --- /dev/null +++ b/zh-cn/native_sdk/sensor/sensor_capi.h @@ -0,0 +1,88 @@ +/* + * 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 传感器 + * @{ + * + * @brief 为您提供标准的开放api,以使用传感器的常用功能。 + * + * 例如,您可以调用这些api来获取传感器属性信息、订阅或取消订阅传感器数据等。 + * @since 11 + */ + +/** + * @file sensor_capi.h + * + * @brief 声明操作传感器的常用api,用于获取传感器信息、订阅或取消订阅传感器数据等。 + * @syscap SystemCapability.Sensors.Sensor + * @since 11 + */ + +#ifndef SENSOR_CAPI_H +#define SENSOR_CAPI_H + +#include + +#include "sensor_capi_base.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_SensorInfo **sensorInfo, int32_t *count); + +/** + * @brief 订阅传感器数据,系统将按照用户指定的上报频率向用户报告传感器数据。 + * + * @param subscribeId 传感器类型, 详情请参见{@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(Sensor_SubscribeId subscribeId, Sensor_SubscribeAttribute attribute, + const Sensor_SubscribeUser *user); + +/** + * @brief 取消订阅传感器数据。 + * + * @param subscribeId 传感器类型, 详情请参见{@link Sensor_SubscribeId}。 + * @param user 订阅者信息,指定传感器数据回调函数, + * 详情请参见{@Link Sensor_SubscribeUser}。 + * @return 取消订阅传感器成功返回SENSOR_SUCCESS,否则返回对应的错误码, + * 详情请参见{@Link Sensor_Result}。 + * + * @since 11 + */ +Sensor_Result OH_Sensor_UnsubscribeSensor(Sensor_SubscribeId subscribeId, const Sensor_SubscribeUser *user); + +#ifdef __cplusplus +} +#endif +#endif // SENSOR_CAPI_H \ No newline at end of file diff --git a/zh-cn/native_sdk/sensor/sensor_capi_base.h b/zh-cn/native_sdk/sensor/sensor_capi_base.h new file mode 100644 index 00000000..883bbd8f --- /dev/null +++ b/zh-cn/native_sdk/sensor/sensor_capi_base.h @@ -0,0 +1,481 @@ +/* + * 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 传感器 + * @{ + * + * @brief 为您提供标准的开放api,定义常用传感器属性。 + * + * @since 11 + */ + +/** + * @file sensor_capi_base.h + * + * @brief 定义常用传感器属性。 + * @syscap SystemCapability.Sensors.Sensor + * + * @since 11 + */ +#ifndef SENSOR_CAPI_BASE_H +#define SENSOR_CAPI_BASE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif +/** 传感器名称的最大长度 */ +#ifndef NAME_MAX_LEN +#define NAME_MAX_LEN 128 +#endif /* NAME_MAX_LEN */ +/** 传感器数据大小 */ +#ifndef SENSOR_USER_DATA_SIZE +#define SENSOR_USER_DATA_SIZE 104 +#endif /* SENSOR_USER_DATA_SIZE */ +/** 传感器版本的最大长度 */ +#ifndef VERSION_MAX_LEN +#define VERSION_MAX_LEN 16 +#endif /* SENSOR_USER_DATA_SIZE */ + +/** + * @brief 传感器类型。 + * + * @since 11 + */ +typedef enum Sensor_SensorTypeId { + ACCELEROMETER = 1, /**< 加速度传感器 */ + GYROSCOPE = 2, /**< 陀螺仪传感测器 */ + AMBIENT_LIGHT = 5, /**< 环境光传感器 */ + MAGNETIC_FIELD = 6, /**< 地磁传感器 */ + BAROMETER = 8, /**< 气压计传感器 */ + HALL = 10, /**< 霍尔传感器 */ + PROXIMITY = 12, /**< 接近光传感器 */ + HUMIDITY = 13, /**< 湿度传感器 */ + COLOR = 14, /**< 颜色传感器 */ + SAR = 15, /**< 吸收比率传感器 */ + ORIENTATION = 256, /**< 方向传感器 */ + GRAVITY = 257, /**< 重力传感器 */ + LINEAR_ACCELEROMETER = 258, /**< 线性加速度传感器 */ + ROTATION_VECTOR = 259, /**< 旋转矢量传感器 */ + AMBIENT_TEMPERATURE = 260, /**< 温度传感器 */ + MAGNETIC_FIELD_UNCALIBRATED = 261, /**< 未校准地磁传感器 */ + GYROSCOPE_UNCALIBRATED = 263, /**< 未校准陀螺仪传感器 */ + SIGNIFICANT_MOTION = 264, /**< 大幅动作检测传感器 */ + PEDOMETER_DETECTION = 265, /**< 计步器检测传感器 */ + PEDOMETER = 266, /**< 计步器传感器 */ + HEART_RATE = 278, /**< 心率传感器 */ + WEAR_DETECTION = 280, /**< 佩戴检测传感器 */ + ACCELEROMETER_UNCALIBRATED = 281, /**< 未校准加速度传感器 */ +} Sensor_SensorTypeId; + +/** + * @brief 定义传感器操作错误码。 + * + * @since 11 + */ +typedef enum Sensor_Result { + SENSOR_SUCCESS = 0, /**< 操作成功时返回该值 */ + SENSOR_PERMISSION_DENIED = 201, /**< 当权限被拒绝时使用此错误代码 */ + SENSOR_PARAMETER_ERROR = 401, /**< 当输入参数类型或范围不匹配时使用此错误代码 */ + SENSOR_SERVICE_EXCEPTION = 14500101, /**< 当服务异常时使用此错误代码 */ +} Sensor_Result; + +/** + * @brief 传感器属性信息。 + * + * @since 11 + */ +typedef struct Sensor_SensorInfo { + char sensorName[NAME_MAX_LEN]; /**< 传感器名字 */ + char vendorName[NAME_MAX_LEN]; /**< 传感器供应商 */ + char firmwareVersion[VERSION_MAX_LEN]; /**< 传感器固件版本 */ + char hardwareVersion[VERSION_MAX_LEN]; /**< 传感器硬件版本 */ + int32_t sensorTypeId; /**< 传感器类型 ID */ + int32_t index; /**< 传感器编号,表示同类传感器的第几个器件,从0开始,默认是0, 0表示默认器件(主传感器)*/ + float maxRange; /**< 传感器的最大测量范围 */ + float precision; /**< 传感器精度 */ + float power; /**< 传感器功率 */ + int64_t minSamplePeriod; /**< 允许的最小采样周期,以纳秒为单位 */ + int64_t maxSamplePeriod; /**< 允许的最大采样周期,以纳秒为单位 */ +} Sensor_SensorInfo; + +/** + * @brief 列举传感器的数据报告模式。 + * + * @since 11 + */ +typedef enum Sensor_SensorMode { + DEFAULT_MODE = 0, /**< 默认数据报告模式 */ + REALTIME_MODE = 1, /**< 实时数据上报模式,每次上报一组数据 */ + ON_CHANGE = 2, /**< 数据实时上报模式,在状态发生变化时上报数据 */ + ONE_SHOT = 3, /**< 数据实时上报模式,只上报一次数据 */ + FIFO_MODE = 4, /**< 基于fifo的数据上报模式,根据BatchCnt设置上报数据 */ + MODE_MAX2, /**< 最大传感器数据上报模式 */ +} Sensor_SensorMode; + +/** + * @brief 上报的传感器数据信息。 + * + * @since 11 + */ +typedef struct Sensor_SensorEvent { + int32_t sensorTypeId; /**< 传感器类型 ID */ + int32_t version; /**< 传感器算法版本 */ + int64_t timestamp; /**< 报告传感器数据的时间 */ + int32_t option; /**< 传感器数据选项,包括测量范围和精度 */ + int32_t mode; /**< 传感器数据上报方式 (详细参考{@link Sensor_SensorMode}) */ + uint8_t *data = nullptr; /**< 传感器数据 */ + uint32_t dataLen; /**< 传感器数据长度 */ +} Sensor_SensorEvent; + +/** + * @brief 列举传感器的数据报告模式。 + * + * @since 11 + */ +typedef struct Sensor_SubscribeId { + Sensor_SensorTypeId sensorTypeId; /**< 用于报告传感器的类型 */ + int32_t sensorIndex; /**< 表示同类型的第几个传感器,0表示默认值 */ + char networkId[NETWORK_ID_MAX_LEN]; /**< 分布式设备的networkId,默认值 "local",用户什么都不传或者用户主动传了"local", + 都表示本地设备只有用户主动传其他设备的networkId,networkID是预留字段,暂无实现 */ +} Sensor_SubscribeId; + +/** + * @brief 传感器订阅属性。 + * + * @since 11 + */ +typedef struct Sensor_SubscribeAttribute { + int64_t samplingInterval; /**< 传感器采样周期 */ + int64_t reportInterval; /**< 传感器上报频率 */ +} Sensor_SubscribeAttribute; + +/** + * @brief 定义传感器代理报告数据的回调。 + * + * @since 11 + */ +typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); + +/** + * @brief 为传感器数据订阅者定义保留字段。 + * + * @since 11 + */ +typedef struct Sensor_UserData { + char userData[SENSOR_USER_DATA_SIZE]; /**< 为传感器数据订阅者保留 */ +} Sensor_UserData; + +/** + * @brief 定义有关传感器数据订阅者的信息。 + * + * @since 11 + */ +typedef struct Sensor_SubscribeUser { + char name[NAME_MAX_LEN]; /**< 传感器数据订阅者的名称 */ + Sensor_RecordSensorCallback callback; /**< 用于报告传感器数据的回调 */ + Sensor_UserData *userData = nullptr; /**< 传感器数据订阅者的保留字段 */ +} Sensor_SubscribeUser; + +/** + * @brief 加速度传感器数据格式, + * 设备在m/s2的三个物理轴(x、y、z)上。 + * + * @since 11 + */ +typedef struct Sensor_AccelerometerData { + float x; /**< 施加在设备x轴的加速度,单位 : m/s² */ + float y; /**< 施加在设备y轴的加速度,单位 : m/s² */ + float z; /**< 施加在设备z轴的加速度,单位 : m/s² */ +} Sensor_AccelerometerData; + +/** + * @brief 定义线性加速度计的数据结构。测量施加于的线性加速度 + * 设备在m/s2的三个物理轴(x、y、z)上。 + * + * @since 11 + */ +typedef struct Sensor_LinearAccelData { + float x; /**< 施加在设备x轴的线性加速度,单位 : m/s² */ + float y; /**< 施加在设备y轴的线性加速度,单位 : m/s² */ + float z; /**< 施加在设备z轴的线性加速度,单位 : m/s² */ +} Sensor_LinearAccelData; + +/** + * @brief 定义陀螺仪传感器数据结构。测量物体的旋转角速度 + * 三个物理轴(x, y和z)上的设备,单位为rad/s。 + * + * @since 11 + */ +typedef struct Sensor_GyroscopeData { + float x; /**< 设备x轴的旋转角速度,单位rad/s */ + float y; /**< 设备y轴的旋转角速度,单位rad/s */ + float z; /**< 设备z轴的旋转角速度,单位rad/s */ +} Sensor_GyroscopeData; + +/** + * @brief 定义重力传感器数据结构。测量重力加速度 + * 在m/s2的三个物理轴(x, y和z)上到设备。 + * + * @since 11 + */ +typedef struct Sensor_GravityData { + float x; /**< 施加在设备x轴的重力加速度,单位 : m/s² */ + float y; /**< 施加在设备y轴的重力加速度,单位 : m/s² */ + float z; /**< 施加在设备z轴的重力加速度,单位 : m/s² */ +} Sensor_GravityData; + +/** + * @brief 定义未校准加速度计数据结构。测量应用于的未校准加速度计 + * 设备在m/s2的三个物理轴(x、y、z)上。 + * + * @since 11 + */ +typedef struct Sensor_AccelUncalibratedData { + float x; /**< 施加在设备x轴未校准的加速度,单位 : m/s² */ + float y; /**< 施加在设备y轴未校准的加速度,单位 : m/s² */ + float z; /**< 施加在设备z轴未校准的加速度,单位 : m/s² */ + float biasX; /**< 施加在设备x轴未校准的加速度偏量,单位 : m/s² */ + float biasY; /**< 施加在设备上y轴未校准的加速度偏量,单位 : m/s² */ + float biasZ; /**< 施加在设备z轴未校准的加速度偏量,单位 : m/s² */ +} Sensor_AccelUncalibratedData; + +/** + * @brief 定义未校准陀螺仪传感器数据结构。测量未校准的旋转角速度 + * 三个物理轴(x, y和z)上的设备,单位为rad/s。 + * + * @since 11 + */ +typedef struct Sensor_GyroUncalibratedData { + float x; /**< 设备x轴未校准的旋转角速度,单位rad/s */ + float y; /**< 设备y轴未校准的旋转角速度,单位rad/s */ + float z; /**< 设备z轴未校准的旋转角速度,单位rad/s */ + float biasX; /**< 设备x轴未校准的旋转角速度偏量,单位rad/s */ + float biasY; /**< 设备y轴未校准的旋转角速度偏量,单位rad/s */ + float biasZ; /**< 设备z轴未校准的旋转角速度偏量,单位rad/s */ +} Sensor_GyroUncalibratedData; + +/** + * @brief 定义大幅动作检测传感器数据结构。测量设备上是否有实质性的运动 + * 三个物理轴(x, y和z);值为1表示存在较大的运动;0表示这个值没有大的变动。 + * + * @since 11 + */ +typedef struct Sensor_SignificantMotionData { + float scalar; /**< 表示剧烈运动程度。如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动 */ +} Sensor_SignificantMotionData; + +/** + * @brief 定义计步器检测传感器数据结构。检测用户的计步动作;如果值为1, + * 它表示用户产生了计数行走的动作; 如果该值为0,则表示用户没有移动。 + * + * @since 11 + */ +typedef struct Sensor_PedometerDetectData { + float scalar; /**< 计步器检测状态,1表示有行走动作,0表示没有动作 */ +} Sensor_PedometerDetectData; + +/** + * @brief 定义计步器传感器数据结构。统计用户走过的步数。 + * + * @since 11 + */ +typedef struct Sensor_PedometerData { + float steps; /**< 用户的行走步数 */ +} Sensor_PedometerData; + +/** + * @brief 定义温度传感器数据结构。测量环境温度,单位为摄氏度。 + * + * @since 11 + */ +typedef struct Sensor_AmbientTemperatureData { + float temperature; /**< 环境温度,单位为摄氏度 */ +} Sensor_AmbientTemperatureData; + +/** + * @brief 定义颜色传感器数据结构。 + * + * @since 11 + */ +typedef struct Sensor_ColorData { + float lightIntensity; /**< 表示光的强度,单位 : 勒克斯 */ + float colorTemperature; /**< 表示色温,单位是开尔文(k) */ +} Sensor_ColorData; + +/** + * @brief 定义吸收比率传感器数据结构。 + * + * @since 11 + */ +typedef struct Sensor_SarData { + float absorptionRatio; /**< 表示具体的吸收率,单位 : W/kg */ +} Sensor_SarData; + +/** + * @brief 定义湿度传感器数据结构。测量环境的相对湿度,以百分比(%)表示。 + * + * @since 11 + */ +typedef struct Sensor_HumidityData { + float humidity; /**< 湿度值。测量环境的相对湿度,以百分比 (%) 表示 */ +} Sensor_HumidityData; + +/** + * @brief 定义温度传感器数据结构。测量环境的相对温度,单位为摄氏度。 + * + * @since 11 + */ +typedef struct Sensor_TemperatureData { + float temperature; /**< 显示环境温度,单位为摄氏度 */ +} Sensor_TemperatureData; + +/** + * @brief 定义地磁传感器数据结构。 + * 三次测量周围的地磁场物理轴(x, y, z),单位为μT。 + * + * @since 11 + */ +typedef struct Sensor_MagneticFieldData { + float x; /**< x轴环境磁场强度,单位 : μT */ + float y; /**< y轴环境磁场强度,单位 : μT */ + float z; /**< z轴环境磁场强度,单位 : μT */ +} Sensor_MagneticFieldData; + +/** + * @brief 义未校准地磁传感器数据结构。 + * 测量未校准的环境地磁场在三个物理轴(x, y, z)上以μT为单位。 + * + * @since 11 + */ +typedef struct Sensor_MagneticFieldUncalibratedData { + float x; /**< x轴未校准环境磁场强度,单位 : μT */ + float y; /**< y轴未校准环境磁场强度,单位 : μT */ + float z; /**< z轴未校准环境磁场强度,单位 : μT */ + float biasX; /**< x轴未校准环境磁场强度偏量,单位 : μT */ + float biasY; /**< y轴未校准环境磁场强度偏量,单位 : μT */ + float biasZ; /**< z轴未校准环境磁场强度偏量,单位 : μT */ +} Sensor_MagneticFieldUncalibratedData; + +/** + * @brief 定义气压计传感器数据结构。测量环境气压,单位:hPa或mbar。 + * + * @since 11 + */ +typedef struct Sensor_BarometerData { + float pressure; /**< 压力值,单位:帕斯卡 */ +} Sensor_BarometerData; + +/** + * @brief 定义设备方向传感器数据结构。测量设备的旋转方向,单位为rad。 + * + * @since 11 + */ +typedef struct Sensor_DeviceOrientationData { + float scalar; /**< 表示设备的方向 */ +} Sensor_DeviceOrientationData; + +/** + * @brief 定义方向传感器数据结构。 + * 测量设备围绕所有三个物理轴(z, x, y)旋转的角度值,单位为rad。 + * + * @since 11 + */ +typedef struct Sensor_OrientationData { + float alpha; /**< 设备围绕Z轴的旋转角度,单位:度 */ + float beta; /**< 设备围绕X轴的旋转角度,单位:度 */ + float gamma; /**< 设备围绕Y轴的旋转角度,单位:度 */ +} Sensor_OrientationData; + +/** + * @brief 定义旋转矢量传感器数据结构。测量设备游戏旋转矢量,复合传感器: + * 由加速度传感器、陀螺仪传感器合成。 + * + * @since 11 + */ +typedef struct Sensor_RotationVectorData { + float x; /**< 旋转矢量x轴分量 */ + float y; /**< 旋转矢量y轴分量 */ + float z; /**< 旋转矢量z轴分量 */ + float w; /**< 标量 */ +} Sensor_RotationVectorData; + +/** + * @brief 定义了地磁旋转矢量传感器的数据结构。 测量装置地磁旋转矢量,复合传感器: + * 由加速度传感器和磁场传感器合成。 + * + * @since 11 + */ +typedef struct Sensor_GeomagneticRotaVectorData { + float x; /**< 地磁旋转矢量x轴分量 */ + float y; /**< 地磁旋转矢量y轴分量 */ + float z; /**< 地磁旋转矢量z轴分量 */ + float w; /**< 标量 */ +} Sensor_GeomagneticRotaVectorData; + +/** + * @brief 定义接近光传感器数据结构。 测量相对于设备显示的可见物体的接近度或距离; + * 其中0表示接近,1表示距离。 + * + * @since 11 + */ +typedef struct Sensor_ProximityData { + float distance; /**< 可见物体与设备显示器的接近程度。0表示接近,1表示远离 */ +} Sensor_ProximityData; + +/** + * @brief 定义环境光传感器数据结构。以勒克斯为单位测量设备周围的光强度。 + * + * @since 11 + */ +typedef struct Sensor_AmbientLightData { + float intensity; /**< 表示光强度,单位为:勒克斯 */ +} Sensor_AmbientLightData; + +/** + * @brief 定义霍尔传感器数据结构。测量设备周围是否有磁力, + * 0表示没有磁力,1表示有磁力。 + * + * @since 11 + */ +typedef struct Sensor_HallData { + float status; /**< 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示没有,大于0表示有 */ +} Sensor_HallData; + +/** + * @brief 定义心率传感器数据结构。测量用户的心率,以bpm为单位。 + * + * @since 11 + */ +typedef struct Sensor_HeartRateData { + float heartRate; /**< 心率值。测量用户的心率数值,单位:bpm */ +} Sensor_HeartRateData; + +/** + * @brief 定义佩戴检测传感器数据结构。表示设备是否被穿戴, + * 1表示已穿戴,0表示未穿戴。 + * + * @since 11 + */ +typedef struct Sensor_WearDetectionData { + float value; /**< 佩戴检测状态,磨损为1,不磨损为0 */ +} Sensor_WearDetectionData; + +#ifdef __cplusplus +} +#endif +#endif // SENSOR_CAPI_BASE_H \ No newline at end of file -- Gitee From 2966f0a3a81d1b157627416ae33a9832e7a6c791 Mon Sep 17 00:00:00 2001 From: cff Date: Tue, 10 Oct 2023 03:02:29 +0000 Subject: [PATCH 2/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi_base.h | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) mode change 100644 => 100755 zh-cn/native_sdk/sensor/sensor_capi_base.h diff --git a/zh-cn/native_sdk/sensor/sensor_capi_base.h b/zh-cn/native_sdk/sensor/sensor_capi_base.h old mode 100644 new mode 100755 index 883bbd8f..b0a0efb0 --- a/zh-cn/native_sdk/sensor/sensor_capi_base.h +++ b/zh-cn/native_sdk/sensor/sensor_capi_base.h @@ -193,31 +193,31 @@ typedef struct Sensor_SubscribeUser { /** * @brief 加速度传感器数据格式, - * 设备在m/s2的三个物理轴(x、y、z)上。 + * 表示施加在设备三个物理轴向(x、y 和 z)上的加速度(包含重力加速度),以 m/s2 为单位。 * * @since 11 */ typedef struct Sensor_AccelerometerData { - float x; /**< 施加在设备x轴的加速度,单位 : m/s² */ - float y; /**< 施加在设备y轴的加速度,单位 : m/s² */ - float z; /**< 施加在设备z轴的加速度,单位 : m/s² */ + float x; /**< 施加在设备x轴的加速度(包含重力加速度),单位 : m/s² */ + float y; /**< 施加在设备y轴的加速度(包含重力加速度),单位 : m/s² */ + float z; /**< 施加在设备z轴的加速度(包含重力加速度),单位 : m/s² */ } Sensor_AccelerometerData; /** - * @brief 定义线性加速度计的数据结构。测量施加于的线性加速度 - * 设备在m/s2的三个物理轴(x、y、z)上。 + * @brief 线性加速度传感器数据格式。 + * 表示施加在设备三个物理轴向(x、y 和 z)上除去重力影响的线性加速度,以 m/s2 为单位。 * * @since 11 */ typedef struct Sensor_LinearAccelData { - float x; /**< 施加在设备x轴的线性加速度,单位 : m/s² */ - float y; /**< 施加在设备y轴的线性加速度,单位 : m/s² */ - float z; /**< 施加在设备z轴的线性加速度,单位 : m/s² */ + float x; /**< 施加在设备x轴的线性加速度(不包含重力加速度),单位 : m/s² */ + float y; /**< 施加在设备y轴的线性加速度(不包含重力加速度),单位 : m/s² */ + float z; /**< 施加在设备z轴的线性加速度(不包含重力加速度),单位 : m/s² */ } Sensor_LinearAccelData; /** - * @brief 定义陀螺仪传感器数据结构。测量物体的旋转角速度 - * 三个物理轴(x, y和z)上的设备,单位为rad/s。 + * @brief 陀螺仪传感器数据格式。 + * 表示设备在三个物理轴向(x、y 和 z)上的旋转角速度,以 rad/s 为单位。 * * @since 11 */ @@ -228,8 +228,8 @@ typedef struct Sensor_GyroscopeData { } Sensor_GyroscopeData; /** - * @brief 定义重力传感器数据结构。测量重力加速度 - * 在m/s2的三个物理轴(x, y和z)上到设备。 + * @brief 重力传感器数据格式。 + * 表示设备在三个物理轴向(x、y 和 z)上的重力加速度,以 m/s2 为单位。 * * @since 11 */ -- Gitee From 19b0e549484b0e292611066fee69beedf8bb1cc7 Mon Sep 17 00:00:00 2001 From: cff Date: Tue, 10 Oct 2023 07:30:29 +0000 Subject: [PATCH 3/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi_base.h | 171 +++++++++++---------- 1 file changed, 89 insertions(+), 82 deletions(-) diff --git a/zh-cn/native_sdk/sensor/sensor_capi_base.h b/zh-cn/native_sdk/sensor/sensor_capi_base.h index b0a0efb0..dcc2ed22 100755 --- a/zh-cn/native_sdk/sensor/sensor_capi_base.h +++ b/zh-cn/native_sdk/sensor/sensor_capi_base.h @@ -143,15 +143,14 @@ typedef struct Sensor_SensorEvent { } Sensor_SensorEvent; /** - * @brief 列举传感器的数据报告模式。 + * @brief 传感器的数据报告模式。 * * @since 11 */ typedef struct Sensor_SubscribeId { Sensor_SensorTypeId sensorTypeId; /**< 用于报告传感器的类型 */ - int32_t sensorIndex; /**< 表示同类型的第几个传感器,0表示默认值 */ - char networkId[NETWORK_ID_MAX_LEN]; /**< 分布式设备的networkId,默认值 "local",用户什么都不传或者用户主动传了"local", - 都表示本地设备只有用户主动传其他设备的networkId,networkID是预留字段,暂无实现 */ + int32_t sensorIndex; /**< 表示同类型的第几个传感器,默认值为0 */ + char networkId[NETWORK_ID_MAX_LEN]; /**< 分布式设备的networkId,默认值 "local"。 */ } Sensor_SubscribeId; /** @@ -165,7 +164,7 @@ typedef struct Sensor_SubscribeAttribute { } Sensor_SubscribeAttribute; /** - * @brief 定义传感器代理报告数据的回调。 + * @brief 传感器代理报告数据的回调。 * * @since 11 */ @@ -198,9 +197,9 @@ typedef struct Sensor_SubscribeUser { * @since 11 */ typedef struct Sensor_AccelerometerData { - float x; /**< 施加在设备x轴的加速度(包含重力加速度),单位 : m/s² */ - float y; /**< 施加在设备y轴的加速度(包含重力加速度),单位 : m/s² */ - float z; /**< 施加在设备z轴的加速度(包含重力加速度),单位 : m/s² */ + float x; /**< 施加在设备x轴的加速度(包含重力加速度),单位:m/s² */ + float y; /**< 施加在设备y轴的加速度(包含重力加速度),单位:m/s² */ + float z; /**< 施加在设备z轴的加速度(包含重力加速度),单位:m/s² */ } Sensor_AccelerometerData; /** @@ -210,9 +209,9 @@ typedef struct Sensor_AccelerometerData { * @since 11 */ typedef struct Sensor_LinearAccelData { - float x; /**< 施加在设备x轴的线性加速度(不包含重力加速度),单位 : m/s² */ - float y; /**< 施加在设备y轴的线性加速度(不包含重力加速度),单位 : m/s² */ - float z; /**< 施加在设备z轴的线性加速度(不包含重力加速度),单位 : m/s² */ + float x; /**< 施加在设备x轴的线性加速度(不包含重力加速度),单位:m/s² */ + float y; /**< 施加在设备y轴的线性加速度(不包含重力加速度),单位:m/s² */ + float z; /**< 施加在设备z轴的线性加速度(不包含重力加速度),单位:m/s² */ } Sensor_LinearAccelData; /** @@ -222,9 +221,9 @@ typedef struct Sensor_LinearAccelData { * @since 11 */ typedef struct Sensor_GyroscopeData { - float x; /**< 设备x轴的旋转角速度,单位rad/s */ - float y; /**< 设备y轴的旋转角速度,单位rad/s */ - float z; /**< 设备z轴的旋转角速度,单位rad/s */ + float x; /**< 设备x轴的旋转角速度,单位:rad/s */ + float y; /**< 设备y轴的旋转角速度,单位:rad/s */ + float z; /**< 设备z轴的旋转角速度,单位:rad/s */ } Sensor_GyroscopeData; /** @@ -234,63 +233,64 @@ typedef struct Sensor_GyroscopeData { * @since 11 */ typedef struct Sensor_GravityData { - float x; /**< 施加在设备x轴的重力加速度,单位 : m/s² */ - float y; /**< 施加在设备y轴的重力加速度,单位 : m/s² */ - float z; /**< 施加在设备z轴的重力加速度,单位 : m/s² */ + float x; /**< 施加在设备x轴的重力加速度,单位:m/s² */ + float y; /**< 施加在设备y轴的重力加速度,单位:m/s² */ + float z; /**< 施加在设备z轴的重力加速度,单位:m/s² */ } Sensor_GravityData; /** - * @brief 定义未校准加速度计数据结构。测量应用于的未校准加速度计 - * 设备在m/s2的三个物理轴(x、y、z)上。 + * @brief 未校准加速度计数据结构。 + * 表示设备在三个物理轴(x、y 和 z)上的未校准加速度,以 m/s2 为单位。 * * @since 11 */ typedef struct Sensor_AccelUncalibratedData { - float x; /**< 施加在设备x轴未校准的加速度,单位 : m/s² */ - float y; /**< 施加在设备y轴未校准的加速度,单位 : m/s² */ - float z; /**< 施加在设备z轴未校准的加速度,单位 : m/s² */ - float biasX; /**< 施加在设备x轴未校准的加速度偏量,单位 : m/s² */ - float biasY; /**< 施加在设备上y轴未校准的加速度偏量,单位 : m/s² */ - float biasZ; /**< 施加在设备z轴未校准的加速度偏量,单位 : m/s² */ + float x; /**< 施加在设备x轴未校准的加速度,单位:m/s² */ + float y; /**< 施加在设备y轴未校准的加速度,单位:m/s² */ + float z; /**< 施加在设备z轴未校准的加速度,单位:m/s² */ + float biasX; /**< 施加在设备x轴未校准的加速度偏量,单位:m/s² */ + float biasY; /**< 施加在设备上y轴未校准的加速度偏量,单位:m/s² */ + float biasZ; /**< 施加在设备z轴未校准的加速度偏量,单位:m/s² */ } Sensor_AccelUncalibratedData; /** - * @brief 定义未校准陀螺仪传感器数据结构。测量未校准的旋转角速度 - * 三个物理轴(x, y和z)上的设备,单位为rad/s。 + * @brief 未校准陀螺仪传感器数据结构。 + * 表示设备在三个物理轴(x, y 和 z)上未校准陀螺仪,以 rad/s 为单位。 * * @since 11 */ typedef struct Sensor_GyroUncalibratedData { - float x; /**< 设备x轴未校准的旋转角速度,单位rad/s */ - float y; /**< 设备y轴未校准的旋转角速度,单位rad/s */ - float z; /**< 设备z轴未校准的旋转角速度,单位rad/s */ - float biasX; /**< 设备x轴未校准的旋转角速度偏量,单位rad/s */ - float biasY; /**< 设备y轴未校准的旋转角速度偏量,单位rad/s */ - float biasZ; /**< 设备z轴未校准的旋转角速度偏量,单位rad/s */ + float x; /**< 设备x轴未校准的旋转角速度,单位:rad/s */ + float y; /**< 设备y轴未校准的旋转角速度,单位:rad/s */ + float z; /**< 设备z轴未校准的旋转角速度,单位:rad/s */ + float biasX; /**< 设备x轴未校准的旋转角速度偏量,单位:rad/s */ + float biasY; /**< 设备y轴未校准的旋转角速度偏量,单位:rad/s */ + float biasZ; /**< 设备z轴未校准的旋转角速度偏量,单位:rad/s */ } Sensor_GyroUncalibratedData; /** - * @brief 定义大幅动作检测传感器数据结构。测量设备上是否有实质性的运动 - * 三个物理轴(x, y和z);值为1表示存在较大的运动;0表示这个值没有大的变动。 + * @brief 大幅动作检测传感器数据结构。 + * 表示设备在三个物理轴(x, y 和 z)是否有实质性的运动,1 表示存在较大的运动;0 表示没有较大的运动。 * * @since 11 */ typedef struct Sensor_SignificantMotionData { - float scalar; /**< 表示剧烈运动程度。如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动 */ + float scalar; /**< 表示剧烈运动程度。1 表示存在大幅度运动,0 表示没有大幅度运动 */ } Sensor_SignificantMotionData; /** - * @brief 定义计步器检测传感器数据结构。检测用户的计步动作;如果值为1, - * 它表示用户产生了计数行走的动作; 如果该值为0,则表示用户没有移动。 + * @brief 计步器检测传感器数据结构。 + * 检测用户的计步动作;1 表示用户产生了计数行走的动作;0 则表示用户没有行走的动作。 * * @since 11 */ typedef struct Sensor_PedometerDetectData { - float scalar; /**< 计步器检测状态,1表示有行走动作,0表示没有动作 */ + float scalar; /**< 计步器检测状态,1 表示有行走动作,0 表示没有动作 */ } Sensor_PedometerDetectData; /** - * @brief 定义计步器传感器数据结构。统计用户走过的步数。 + * @brief 计步器传感器数据结构。 + * 统计用户走过的步数。 * * @since 11 */ @@ -299,35 +299,37 @@ typedef struct Sensor_PedometerData { } Sensor_PedometerData; /** - * @brief 定义温度传感器数据结构。测量环境温度,单位为摄氏度。 + * @brief 温度传感器数据结构。 + * 测量环境温度,以摄氏度为单位。 * * @since 11 */ typedef struct Sensor_AmbientTemperatureData { - float temperature; /**< 环境温度,单位为摄氏度 */ + float temperature; /**< 环境温度,单位:摄氏度 */ } Sensor_AmbientTemperatureData; /** - * @brief 定义颜色传感器数据结构。 + * @brief 颜色传感器数据结构。 * * @since 11 */ typedef struct Sensor_ColorData { - float lightIntensity; /**< 表示光的强度,单位 : 勒克斯 */ - float colorTemperature; /**< 表示色温,单位是开尔文(k) */ + float lightIntensity; /**< 表示光的强度,单位:勒克斯 */ + float colorTemperature; /**< 表示色温,单位:开尔文(k) */ } Sensor_ColorData; /** - * @brief 定义吸收比率传感器数据结构。 + * @brief 吸收比率传感器数据结构。 * * @since 11 */ typedef struct Sensor_SarData { - float absorptionRatio; /**< 表示具体的吸收率,单位 : W/kg */ + float absorptionRatio; /**< 表示具体的吸收率,单位:W/kg */ } Sensor_SarData; /** - * @brief 定义湿度传感器数据结构。测量环境的相对湿度,以百分比(%)表示。 + * @brief 湿度传感器数据结构。 + * 测量环境的相对湿度,以百分比(%)表示。 * * @since 11 */ @@ -336,43 +338,45 @@ typedef struct Sensor_HumidityData { } Sensor_HumidityData; /** - * @brief 定义温度传感器数据结构。测量环境的相对温度,单位为摄氏度。 + * @brief 温度传感器数据结构。 + * 测量环境的相对温度,单位为摄氏度。 * * @since 11 */ typedef struct Sensor_TemperatureData { - float temperature; /**< 显示环境温度,单位为摄氏度 */ + float temperature; /**< 显示环境温度,单位:摄氏度 */ } Sensor_TemperatureData; /** - * @brief 定义地磁传感器数据结构。 - * 三次测量周围的地磁场物理轴(x, y, z),单位为μT。 + * @brief 地磁传感器数据结构。 + * 表示设备在物理轴(x, y 和 z)上三次测量周围的地磁,以 μT 为单位。 * * @since 11 */ typedef struct Sensor_MagneticFieldData { - float x; /**< x轴环境磁场强度,单位 : μT */ - float y; /**< y轴环境磁场强度,单位 : μT */ - float z; /**< z轴环境磁场强度,单位 : μT */ + float x; /**< x轴环境磁场强度,单位:μT */ + float y; /**< y轴环境磁场强度,单位:μT */ + float z; /**< z轴环境磁场强度,单位:μT */ } Sensor_MagneticFieldData; /** - * @brief 义未校准地磁传感器数据结构。 - * 测量未校准的环境地磁场在三个物理轴(x, y, z)上以μT为单位。 + * @brief 未校准地磁传感器数据结构。 + * 表示设备在三个物理轴(x, y 和 z)上的未校准地磁,以 μT 为单位。 * * @since 11 */ typedef struct Sensor_MagneticFieldUncalibratedData { - float x; /**< x轴未校准环境磁场强度,单位 : μT */ - float y; /**< y轴未校准环境磁场强度,单位 : μT */ - float z; /**< z轴未校准环境磁场强度,单位 : μT */ - float biasX; /**< x轴未校准环境磁场强度偏量,单位 : μT */ - float biasY; /**< y轴未校准环境磁场强度偏量,单位 : μT */ - float biasZ; /**< z轴未校准环境磁场强度偏量,单位 : μT */ + float x; /**< x轴未校准环境磁场强度,单位:μT */ + float y; /**< y轴未校准环境磁场强度,单位:μT */ + float z; /**< z轴未校准环境磁场强度,单位:μT */ + float biasX; /**< x轴未校准环境磁场强度偏量,单位:μT */ + float biasY; /**< y轴未校准环境磁场强度偏量,单位:μT */ + float biasZ; /**< z轴未校准环境磁场强度偏量,单位:μT */ } Sensor_MagneticFieldUncalibratedData; /** - * @brief 定义气压计传感器数据结构。测量环境气压,单位:hPa或mbar。 + * @brief 气压计传感器数据结构。 + * 测量环境气压,以 hPa或mbar 为单位。 * * @since 11 */ @@ -381,7 +385,8 @@ typedef struct Sensor_BarometerData { } Sensor_BarometerData; /** - * @brief 定义设备方向传感器数据结构。测量设备的旋转方向,单位为rad。 + * @brief 设备方向传感器数据结构。 + * 测量设备的旋转方向,以 rad 为单位。 * * @since 11 */ @@ -390,8 +395,8 @@ typedef struct Sensor_DeviceOrientationData { } Sensor_DeviceOrientationData; /** - * @brief 定义方向传感器数据结构。 - * 测量设备围绕所有三个物理轴(z, x, y)旋转的角度值,单位为rad。 + * @brief 方向传感器数据结构。 + * 表示设备在三个物理轴(z, x 和 y)上旋转的角度值,以 rad 为单位。 * * @since 11 */ @@ -402,8 +407,8 @@ typedef struct Sensor_OrientationData { } Sensor_OrientationData; /** - * @brief 定义旋转矢量传感器数据结构。测量设备游戏旋转矢量,复合传感器: - * 由加速度传感器、陀螺仪传感器合成。 + * @brief 旋转矢量传感器数据结构。 + * 表示设备游戏旋转矢量,由加速度传感器和陀螺仪传感器合成。 * * @since 11 */ @@ -415,8 +420,8 @@ typedef struct Sensor_RotationVectorData { } Sensor_RotationVectorData; /** - * @brief 定义了地磁旋转矢量传感器的数据结构。 测量装置地磁旋转矢量,复合传感器: - * 由加速度传感器和磁场传感器合成。 + * @brief 地磁旋转矢量传感器的数据结构。 + * 表示测量装置地磁旋转矢量,由加速度传感器和磁场传感器合成。 * * @since 11 */ @@ -428,17 +433,18 @@ typedef struct Sensor_GeomagneticRotaVectorData { } Sensor_GeomagneticRotaVectorData; /** - * @brief 定义接近光传感器数据结构。 测量相对于设备显示的可见物体的接近度或距离; - * 其中0表示接近,1表示距离。 + * @brief 定义接近光传感器数据结构。 + * 表示设备显示的可见物体的接近度或距离,0 表示接近,1 表示距离。 * * @since 11 */ typedef struct Sensor_ProximityData { - float distance; /**< 可见物体与设备显示器的接近程度。0表示接近,1表示远离 */ + float distance; /**< 可见物体与设备显示器的接近程度。0 表示接近,1 表示远离 */ } Sensor_ProximityData; /** - * @brief 定义环境光传感器数据结构。以勒克斯为单位测量设备周围的光强度。 + * @brief 定义环境光传感器数据结构。 + * 表示设备周围的光强度,以勒克斯为单位。 * * @since 11 */ @@ -447,17 +453,18 @@ typedef struct Sensor_AmbientLightData { } Sensor_AmbientLightData; /** - * @brief 定义霍尔传感器数据结构。测量设备周围是否有磁力, - * 0表示没有磁力,1表示有磁力。 + * @brief 定义霍尔传感器数据结构。 + * 表示设备周围是否有磁力,0 表示没有磁力,1 表示有磁力。 * * @since 11 */ typedef struct Sensor_HallData { - float status; /**< 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示没有,大于0表示有 */ + float status; /**< 显示霍尔状态。测量设备周围是否存在磁力吸引,0 表示没有,大于0表示有 */ } Sensor_HallData; /** - * @brief 定义心率传感器数据结构。测量用户的心率,以bpm为单位。 + * @brief 定义心率传感器数据结构。 + * 表示设备测量用户的心率,以 bpm 为单位。 * * @since 11 */ @@ -466,13 +473,13 @@ typedef struct Sensor_HeartRateData { } Sensor_HeartRateData; /** - * @brief 定义佩戴检测传感器数据结构。表示设备是否被穿戴, - * 1表示已穿戴,0表示未穿戴。 + * @brief 定义佩戴检测传感器数据结构。 + * 表示设备是否被穿戴,1 表示已穿戴,0 表示未穿戴。 * * @since 11 */ typedef struct Sensor_WearDetectionData { - float value; /**< 佩戴检测状态,磨损为1,不磨损为0 */ + float value; /**< 佩戴检测状态,1 表示已穿戴,0 表示未穿戴 */ } Sensor_WearDetectionData; #ifdef __cplusplus -- Gitee From b19fb3c10b985ce55d5e70678a38ea64860621ed Mon Sep 17 00:00:00 2001 From: cff Date: Thu, 12 Oct 2023 01:57:00 +0000 Subject: [PATCH 4/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi_base.h | 116 +++++++++------------ 1 file changed, 48 insertions(+), 68 deletions(-) diff --git a/zh-cn/native_sdk/sensor/sensor_capi_base.h b/zh-cn/native_sdk/sensor/sensor_capi_base.h index dcc2ed22..f3d4df28 100755 --- a/zh-cn/native_sdk/sensor/sensor_capi_base.h +++ b/zh-cn/native_sdk/sensor/sensor_capi_base.h @@ -68,7 +68,7 @@ typedef enum Sensor_SensorTypeId { COLOR = 14, /**< 颜色传感器 */ SAR = 15, /**< 吸收比率传感器 */ ORIENTATION = 256, /**< 方向传感器 */ - GRAVITY = 257, /**< 重力传感器 */ + GRAVITY = 257, /**< 重力加速度传感器 */ LINEAR_ACCELEROMETER = 258, /**< 线性加速度传感器 */ ROTATION_VECTOR = 259, /**< 旋转矢量传感器 */ AMBIENT_TEMPERATURE = 260, /**< 温度传感器 */ @@ -143,14 +143,14 @@ typedef struct Sensor_SensorEvent { } Sensor_SensorEvent; /** - * @brief 传感器的数据报告模式。 + * @brief 传感器订阅Id。 * * @since 11 */ typedef struct Sensor_SubscribeId { - Sensor_SensorTypeId sensorTypeId; /**< 用于报告传感器的类型 */ - int32_t sensorIndex; /**< 表示同类型的第几个传感器,默认值为0 */ - char networkId[NETWORK_ID_MAX_LEN]; /**< 分布式设备的networkId,默认值 "local"。 */ + Sensor_SensorTypeId sensorTypeId; /**< 传感器订阅Id */ + int32_t sensorIndex; /**< 当前类型的第几个传感器,默认值为0 */ + char networkId[NETWORK_ID_MAX_LEN]; /**< 分布式设备的networkId,默认值 "local" */ } Sensor_SubscribeId; /** @@ -164,19 +164,19 @@ typedef struct Sensor_SubscribeAttribute { } Sensor_SubscribeAttribute; /** - * @brief 传感器代理报告数据的回调。 + * @brief 上报传感器数据的回调函数。 * * @since 11 */ typedef void (*Sensor_RecordSensorCallback)(Sensor_SensorEvent *event); /** - * @brief 为传感器数据订阅者定义保留字段。 + * @brief 为传感器订阅者预留的字段。 * * @since 11 */ typedef struct Sensor_UserData { - char userData[SENSOR_USER_DATA_SIZE]; /**< 为传感器数据订阅者保留 */ + char userData[SENSOR_USER_DATA_SIZE]; /**< 为传感器数据订阅者预留的字段 */ } Sensor_UserData; /** @@ -227,7 +227,7 @@ typedef struct Sensor_GyroscopeData { } Sensor_GyroscopeData; /** - * @brief 重力传感器数据格式。 + * @brief 重力加速度传感器数据格式。 * 表示设备在三个物理轴向(x、y 和 z)上的重力加速度,以 m/s2 为单位。 * * @since 11 @@ -239,7 +239,7 @@ typedef struct Sensor_GravityData { } Sensor_GravityData; /** - * @brief 未校准加速度计数据结构。 + * @brief 未校准加速度传感器。 * 表示设备在三个物理轴(x、y 和 z)上的未校准加速度,以 m/s2 为单位。 * * @since 11 @@ -255,7 +255,7 @@ typedef struct Sensor_AccelUncalibratedData { /** * @brief 未校准陀螺仪传感器数据结构。 - * 表示设备在三个物理轴(x, y 和 z)上未校准陀螺仪,以 rad/s 为单位。 + * 表示设备在三个物理轴(x, y 和 z)上未校准旋转角速度,以 rad/s 为单位。 * * @since 11 */ @@ -270,7 +270,7 @@ typedef struct Sensor_GyroUncalibratedData { /** * @brief 大幅动作检测传感器数据结构。 - * 表示设备在三个物理轴(x, y 和 z)是否有实质性的运动,1 表示存在较大的运动;0 表示没有较大的运动。 + * 表示设备在三个物理轴(x, y 和 z)是否存在大幅的运动,1 表示存在大幅的运动;0 表示没有大幅的运动。 * * @since 11 */ @@ -279,8 +279,8 @@ typedef struct Sensor_SignificantMotionData { } Sensor_SignificantMotionData; /** - * @brief 计步器检测传感器数据结构。 - * 检测用户的计步动作;1 表示用户产生了计数行走的动作;0 则表示用户没有行走的动作。 + * @brief 计步器检测传感器数 + * 检测用户的计行走的状态;1 表示有行走的动作;0 则表示没有行走的动作。 * * @since 11 */ @@ -310,6 +310,8 @@ typedef struct Sensor_AmbientTemperatureData { /** * @brief 颜色传感器数据结构。 + * 测量光的强度,以勒克斯为单位; + * 测量光的色温,以开尔文为单位。 * * @since 11 */ @@ -320,6 +322,7 @@ typedef struct Sensor_ColorData { /** * @brief 吸收比率传感器数据结构。 + * 测量吸收比率,以 W/kg 为单位。 * * @since 11 */ @@ -337,46 +340,36 @@ typedef struct Sensor_HumidityData { float humidity; /**< 湿度值。测量环境的相对湿度,以百分比 (%) 表示 */ } Sensor_HumidityData; -/** - * @brief 温度传感器数据结构。 - * 测量环境的相对温度,单位为摄氏度。 - * - * @since 11 - */ -typedef struct Sensor_TemperatureData { - float temperature; /**< 显示环境温度,单位:摄氏度 */ -} Sensor_TemperatureData; - /** * @brief 地磁传感器数据结构。 - * 表示设备在物理轴(x, y 和 z)上三次测量周围的地磁,以 μT 为单位。 + * 表示设备在三个物理轴(x, y 和 z)上的环境磁场强度,以 μT 为单位。 * * @since 11 */ typedef struct Sensor_MagneticFieldData { - float x; /**< x轴环境磁场强度,单位:μT */ - float y; /**< y轴环境磁场强度,单位:μT */ - float z; /**< z轴环境磁场强度,单位:μT */ + float x; /**< 设备在x轴上的环境磁场强度,单位:μT */ + float y; /**< 设备在y轴上的环境磁场强度,单位:μT */ + float z; /**< 设备在z轴上的环境磁场强度,单位:μT */ } Sensor_MagneticFieldData; /** * @brief 未校准地磁传感器数据结构。 - * 表示设备在三个物理轴(x, y 和 z)上的未校准地磁,以 μT 为单位。 + * 表示设备在三个物理轴(x, y 和 z)上的未校准环境磁场强度,以 μT 为单位。 * * @since 11 */ typedef struct Sensor_MagneticFieldUncalibratedData { - float x; /**< x轴未校准环境磁场强度,单位:μT */ - float y; /**< y轴未校准环境磁场强度,单位:μT */ - float z; /**< z轴未校准环境磁场强度,单位:μT */ - float biasX; /**< x轴未校准环境磁场强度偏量,单位:μT */ - float biasY; /**< y轴未校准环境磁场强度偏量,单位:μT */ - float biasZ; /**< z轴未校准环境磁场强度偏量,单位:μT */ + float x; /**< 设备在x轴上的未校准环境磁场强度,单位:μT */ + float y; /**< 设备在y轴上的未校准环境磁场强度,单位:μT */ + float z; /**< 设备在z轴上的未校准环境磁场强度,单位:μT */ + float biasX; /**< 设备在x轴上的未校准环境磁场强度偏量,单位:μT */ + float biasY; /**< 设备在y轴上的未校准环境磁场强度偏量,单位:μT */ + float biasZ; /**< 设备在z轴上的未校准环境磁场强度偏量,单位:μT */ } Sensor_MagneticFieldUncalibratedData; /** * @brief 气压计传感器数据结构。 - * 测量环境气压,以 hPa或mbar 为单位。 + * 测量环境气压,以帕斯卡为单位。 * * @since 11 */ @@ -391,7 +384,7 @@ typedef struct Sensor_BarometerData { * @since 11 */ typedef struct Sensor_DeviceOrientationData { - float scalar; /**< 表示设备的方向 */ + float scalar; /**< 表示设备的选择方向,单位:rad */ } Sensor_DeviceOrientationData; /** @@ -401,14 +394,14 @@ typedef struct Sensor_DeviceOrientationData { * @since 11 */ typedef struct Sensor_OrientationData { - float alpha; /**< 设备围绕Z轴的旋转角度,单位:度 */ - float beta; /**< 设备围绕X轴的旋转角度,单位:度 */ - float gamma; /**< 设备围绕Y轴的旋转角度,单位:度 */ + float alpha; /**< 设备在Z轴的旋转角度值,单位:rad */ + float beta; /**< 设备在X轴的旋转角度值,单位:rad */ + float gamma; /**< 设备在Y轴的旋转角度值,单位:rad */ } Sensor_OrientationData; /** * @brief 旋转矢量传感器数据结构。 - * 表示设备游戏旋转矢量,由加速度传感器和陀螺仪传感器合成。 + * 表示设备在三个物理轴(z, x 和 y)上旋转矢量,由加速度传感器和陀螺仪传感器合成。 * * @since 11 */ @@ -420,66 +413,53 @@ typedef struct Sensor_RotationVectorData { } Sensor_RotationVectorData; /** - * @brief 地磁旋转矢量传感器的数据结构。 - * 表示测量装置地磁旋转矢量,由加速度传感器和磁场传感器合成。 - * - * @since 11 - */ -typedef struct Sensor_GeomagneticRotaVectorData { - float x; /**< 地磁旋转矢量x轴分量 */ - float y; /**< 地磁旋转矢量y轴分量 */ - float z; /**< 地磁旋转矢量z轴分量 */ - float w; /**< 标量 */ -} Sensor_GeomagneticRotaVectorData; - -/** - * @brief 定义接近光传感器数据结构。 - * 表示设备显示的可见物体的接近度或距离,0 表示接近,1 表示距离。 + * @brief 接近光传感器数据结构。 + * 表示设备显示的可见物体的接近度或距离,0 表示接近,大于 0 表示距离。 * * @since 11 */ typedef struct Sensor_ProximityData { - float distance; /**< 可见物体与设备显示器的接近程度。0 表示接近,1 表示远离 */ + float distance; /**< 可见物体与设备显示器的接近程度。0 表示接近,大于 0 表示距离 */ } Sensor_ProximityData; /** - * @brief 定义环境光传感器数据结构。 - * 表示设备周围的光强度,以勒克斯为单位。 + * @brief 环境光传感器数据结构。 + * 表示环境光的强度,以勒克斯为单位。 * * @since 11 */ typedef struct Sensor_AmbientLightData { - float intensity; /**< 表示光强度,单位为:勒克斯 */ + float intensity; /**< 表示光的强度,单位为:勒克斯 */ } Sensor_AmbientLightData; /** - * @brief 定义霍尔传感器数据结构。 - * 表示设备周围是否有磁力,0 表示没有磁力,1 表示有磁力。 + * @brief 霍尔传感器数据结构。 + * 表示设备周围是否有磁力,0 表示没有磁力,大于 0 表示有磁力。 * * @since 11 */ typedef struct Sensor_HallData { - float status; /**< 显示霍尔状态。测量设备周围是否存在磁力吸引,0 表示没有,大于0表示有 */ + float status; /**< 显示霍尔状态。测量设备周围是否存在磁力吸引,0 表示没有,大于 0 表示有 */ } Sensor_HallData; /** - * @brief 定义心率传感器数据结构。 + * @brief 心率传感器数据结构。 * 表示设备测量用户的心率,以 bpm 为单位。 * * @since 11 */ typedef struct Sensor_HeartRateData { - float heartRate; /**< 心率值。测量用户的心率数值,单位:bpm */ + float heartRate; /**< 用户的心率,单位:bpm */ } Sensor_HeartRateData; /** - * @brief 定义佩戴检测传感器数据结构。 - * 表示设备是否被穿戴,1 表示已穿戴,0 表示未穿戴。 + * @brief 佩戴检测传感器数据结构。 + * 表示设备佩戴状态,1 表示已穿戴,0 表示未穿戴。 * * @since 11 */ typedef struct Sensor_WearDetectionData { - float value; /**< 佩戴检测状态,1 表示已穿戴,0 表示未穿戴 */ + float value; /**< 佩戴状态,1 表示已穿戴,0 表示未穿戴 */ } Sensor_WearDetectionData; #ifdef __cplusplus -- Gitee From 7a70ba4165e0076eaff0259c81969c4bae94eba3 Mon Sep 17 00:00:00 2001 From: cff Date: Thu, 12 Oct 2023 07:16:09 +0000 Subject: [PATCH 5/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi.h | 4 ++-- zh-cn/native_sdk/sensor/sensor_capi_base.h | 24 +++++++--------------- 2 files changed, 9 insertions(+), 19 deletions(-) mode change 100644 => 100755 zh-cn/native_sdk/sensor/sensor_capi.h diff --git a/zh-cn/native_sdk/sensor/sensor_capi.h b/zh-cn/native_sdk/sensor/sensor_capi.h old mode 100644 new mode 100755 index c9df23fa..0308c81c --- a/zh-cn/native_sdk/sensor/sensor_capi.h +++ b/zh-cn/native_sdk/sensor/sensor_capi.h @@ -58,7 +58,7 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_SensorInfo **sensorInfo, int32_t *c /** * @brief 订阅传感器数据,系统将按照用户指定的上报频率向用户报告传感器数据。 * - * @param subscribeId 传感器类型, 详情请参见{@link Sensor_SubscribeId}。 + * @param subscribeId 订阅Id, 详情请参见{@link Sensor_SubscribeId}。 * @param attribute 订阅属性,用于指定传感器的上报频率,详情请参见{@Link Sensor_SubscribeAttribute}。 * @param user 订阅者信息,指定传感器数据回调函数,详情请参见{@Link Sensor_SubscribeUser}。 * @return 订阅传感器成功返回SENSOR_SUCCESS,否则返回对应的错误码, @@ -72,7 +72,7 @@ Sensor_Result OH_Sensor_SubscribeSensor(Sensor_SubscribeId subscribeId, Sensor_S /** * @brief 取消订阅传感器数据。 * - * @param subscribeId 传感器类型, 详情请参见{@link Sensor_SubscribeId}。 + * @param subscribeId 订阅Id, 详情请参见{@link Sensor_SubscribeId}。 * @param user 订阅者信息,指定传感器数据回调函数, * 详情请参见{@Link Sensor_SubscribeUser}。 * @return 取消订阅传感器成功返回SENSOR_SUCCESS,否则返回对应的错误码, diff --git a/zh-cn/native_sdk/sensor/sensor_capi_base.h b/zh-cn/native_sdk/sensor/sensor_capi_base.h index f3d4df28..6173b1d8 100755 --- a/zh-cn/native_sdk/sensor/sensor_capi_base.h +++ b/zh-cn/native_sdk/sensor/sensor_capi_base.h @@ -120,9 +120,9 @@ typedef struct Sensor_SensorInfo { */ typedef enum Sensor_SensorMode { DEFAULT_MODE = 0, /**< 默认数据报告模式 */ - REALTIME_MODE = 1, /**< 实时数据上报模式,每次上报一组数据 */ - ON_CHANGE = 2, /**< 数据实时上报模式,在状态发生变化时上报数据 */ - ONE_SHOT = 3, /**< 数据实时上报模式,只上报一次数据 */ + REALTIME_MODE = 1, /**< 实时上报数据模式,每次上报一组数据 */ + ON_CHANGE = 2, /**< 实时上报数据模式,在状态发生变化时上报数据 */ + ONE_SHOT = 3, /**< 实时上报数据模式,只上报一次数据 */ FIFO_MODE = 4, /**< 基于fifo的数据上报模式,根据BatchCnt设置上报数据 */ MODE_MAX2, /**< 最大传感器数据上报模式 */ } Sensor_SensorMode; @@ -148,7 +148,7 @@ typedef struct Sensor_SensorEvent { * @since 11 */ typedef struct Sensor_SubscribeId { - Sensor_SensorTypeId sensorTypeId; /**< 传感器订阅Id */ + Sensor_SensorTypeId sensorTypeId; /**< 传感器类型ID */ int32_t sensorIndex; /**< 当前类型的第几个传感器,默认值为0 */ char networkId[NETWORK_ID_MAX_LEN]; /**< 分布式设备的networkId,默认值 "local" */ } Sensor_SubscribeId; @@ -377,16 +377,6 @@ typedef struct Sensor_BarometerData { float pressure; /**< 压力值,单位:帕斯卡 */ } Sensor_BarometerData; -/** - * @brief 设备方向传感器数据结构。 - * 测量设备的旋转方向,以 rad 为单位。 - * - * @since 11 - */ -typedef struct Sensor_DeviceOrientationData { - float scalar; /**< 表示设备的选择方向,单位:rad */ -} Sensor_DeviceOrientationData; - /** * @brief 方向传感器数据结构。 * 表示设备在三个物理轴(z, x 和 y)上旋转的角度值,以 rad 为单位。 @@ -414,12 +404,12 @@ typedef struct Sensor_RotationVectorData { /** * @brief 接近光传感器数据结构。 - * 表示设备显示的可见物体的接近度或距离,0 表示接近,大于 0 表示距离。 + * 表示设备显示的可见物体的接近度或距离,0 表示接近,大于 0 表示远离。 * * @since 11 */ typedef struct Sensor_ProximityData { - float distance; /**< 可见物体与设备显示器的接近程度。0 表示接近,大于 0 表示距离 */ + float distance; /**< 可见物体与设备显示器的接近程度。0 表示接近,大于 0 表示远离 */ } Sensor_ProximityData; /** @@ -444,7 +434,7 @@ typedef struct Sensor_HallData { /** * @brief 心率传感器数据结构。 - * 表示设备测量用户的心率,以 bpm 为单位。 + * 表示用户的心率,以 bpm 为单位。 * * @since 11 */ -- Gitee From 107bd4695a45caa8ee2140c48875f6be2c87f528 Mon Sep 17 00:00:00 2001 From: cff Date: Thu, 12 Oct 2023 07:16:37 +0000 Subject: [PATCH 6/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 zh-cn/native_sdk/sensor/sensor_capi.h diff --git a/zh-cn/native_sdk/sensor/sensor_capi.h b/zh-cn/native_sdk/sensor/sensor_capi.h old mode 100755 new mode 100644 -- Gitee From 74eb478541c54ac4094b4bd5be2e25374de8d094 Mon Sep 17 00:00:00 2001 From: cff Date: Thu, 12 Oct 2023 09:24:53 +0000 Subject: [PATCH 7/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 zh-cn/native_sdk/sensor/sensor_capi.h diff --git a/zh-cn/native_sdk/sensor/sensor_capi.h b/zh-cn/native_sdk/sensor/sensor_capi.h old mode 100644 new mode 100755 index 0308c81c..0fbb2bc3 --- a/zh-cn/native_sdk/sensor/sensor_capi.h +++ b/zh-cn/native_sdk/sensor/sensor_capi.h @@ -58,7 +58,7 @@ Sensor_Result OH_Sensor_GetAllSensors(Sensor_SensorInfo **sensorInfo, int32_t *c /** * @brief 订阅传感器数据,系统将按照用户指定的上报频率向用户报告传感器数据。 * - * @param subscribeId 订阅Id, 详情请参见{@link Sensor_SubscribeId}。 + * @param subscribeId 订阅ID, 详情请参见{@link Sensor_SubscribeId}。 * @param attribute 订阅属性,用于指定传感器的上报频率,详情请参见{@Link Sensor_SubscribeAttribute}。 * @param user 订阅者信息,指定传感器数据回调函数,详情请参见{@Link Sensor_SubscribeUser}。 * @return 订阅传感器成功返回SENSOR_SUCCESS,否则返回对应的错误码, @@ -72,7 +72,7 @@ Sensor_Result OH_Sensor_SubscribeSensor(Sensor_SubscribeId subscribeId, Sensor_S /** * @brief 取消订阅传感器数据。 * - * @param subscribeId 订阅Id, 详情请参见{@link Sensor_SubscribeId}。 + * @param subscribeId 订阅ID, 详情请参见{@link Sensor_SubscribeId}。 * @param user 订阅者信息,指定传感器数据回调函数, * 详情请参见{@Link Sensor_SubscribeUser}。 * @return 取消订阅传感器成功返回SENSOR_SUCCESS,否则返回对应的错误码, -- Gitee From c4d567566b0fa0579359f11d06de51c3a85305be Mon Sep 17 00:00:00 2001 From: cff Date: Tue, 17 Oct 2023 08:13:28 +0000 Subject: [PATCH 8/8] =?UTF-8?q?sensor=20C-API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff --- zh-cn/native_sdk/sensor/sensor_capi.h | 0 zh-cn/native_sdk/sensor/sensor_capi_base.h | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) mode change 100755 => 100644 zh-cn/native_sdk/sensor/sensor_capi.h diff --git a/zh-cn/native_sdk/sensor/sensor_capi.h b/zh-cn/native_sdk/sensor/sensor_capi.h old mode 100755 new mode 100644 diff --git a/zh-cn/native_sdk/sensor/sensor_capi_base.h b/zh-cn/native_sdk/sensor/sensor_capi_base.h index 6173b1d8..1422d0d4 100755 --- a/zh-cn/native_sdk/sensor/sensor_capi_base.h +++ b/zh-cn/native_sdk/sensor/sensor_capi_base.h @@ -68,7 +68,7 @@ typedef enum Sensor_SensorTypeId { COLOR = 14, /**< 颜色传感器 */ SAR = 15, /**< 吸收比率传感器 */ ORIENTATION = 256, /**< 方向传感器 */ - GRAVITY = 257, /**< 重力加速度传感器 */ + GRAVITY = 257, /**< 重力传感器 */ LINEAR_ACCELEROMETER = 258, /**< 线性加速度传感器 */ ROTATION_VECTOR = 259, /**< 旋转矢量传感器 */ AMBIENT_TEMPERATURE = 260, /**< 温度传感器 */ @@ -227,15 +227,15 @@ typedef struct Sensor_GyroscopeData { } Sensor_GyroscopeData; /** - * @brief 重力加速度传感器数据格式。 - * 表示设备在三个物理轴向(x、y 和 z)上的重力加速度,以 m/s2 为单位。 + * @brief 重力传感器数据格式。 + * 表示设备在三个物理轴向(x、y 和 z)上的重力,以 m/s2 为单位。 * * @since 11 */ typedef struct Sensor_GravityData { - float x; /**< 施加在设备x轴的重力加速度,单位:m/s² */ - float y; /**< 施加在设备y轴的重力加速度,单位:m/s² */ - float z; /**< 施加在设备z轴的重力加速度,单位:m/s² */ + float x; /**< 施加在设备x轴的重力,单位:m/s² */ + float y; /**< 施加在设备y轴的重力,单位:m/s² */ + float z; /**< 施加在设备z轴的重力,单位:m/s² */ } Sensor_GravityData; /** -- Gitee