
回复
泛Sensor服务子系统提供了轻量级sensor服务基础框架,提供了如下功能:
泛Sensor服务框架如下图所示:
图 1 泛Sensor服务框架图
表 1 SensorAgent的主要接口
接口名 | 描述 |
---|---|
GetAllSensors(SensorInfo **sensorInfo, int32_t *count) | 获取系统中所有传感器的信息 |
SubscribeSensor(int32_t sensorTypeId, SensorUser *user) | 订阅传感器数据,系统会将获取到的传感器数据上报给订阅者 |
UnsubscribeSensor(int32_t sensorTypeId, SensorUser *user) | 去订阅传感器数据,系统将取消传感器数据上报给订阅者 |
SetBatch(int32_t sensorTypeId, SensorUser *user, int64_t samplingInterval, int64_t reportInterval) | 设置传感器的数据采样间隔和数据上报间隔 |
ActivateSensor(int32_t sensorTypeId, SensorUser *user) | 使能一个传感器订阅用户,只有在传感器使能之后,订阅该传感器的用户才能获取到数据 |
DeactivateSensor(int32_t sensorTypeId, SensorUser *user) | 去使能一个传感器订阅用户 |
SetMode(int32_t sensorTypeId, SensorUser *user, int32_t mode) | 设置传感器的数据上报模式 |
本节以订阅加速度传感器数据为例进行介绍。
泛Sensor子系统
sensors_sensor_lite
sensors_miscdevice_lite