# 传感器接口

Source: [https://docs.qualcomm.com/doc/80-PK177-134Y/topic/sensor_interfaces.html](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/sensor_interfaces.html)

- **[发送请求](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/send_request.html)**  

通过会话向传感器子系统发送请求消息。客户端可发送的消息如[编码和解码 protobuf 消息](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/encoding_and_decoding_protobuf_messages.html)所述。如果客户端尝试向不可用的传感器发送消息，则客户端将获得的返回结果为错误。
- **[register_event_callback](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/register_event_callback.html)**  

针对传感器事件注册回调接口 Ievent\_callback\_type。每当客户端激活的传感器生成传感器事件时，都会调用已注册的回调。
- **[register_error_callback](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/register_error_callback.html)**  

针对错误事件注册回调接口 cb。出现错误时将调用已注册的回调，并且必须从传感器子系统向客户端报告错误。
- **[Ierror_callback_type.onValues](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/ierror_callback_type_onvalues.html)**  

在处理传感器数据时，如果底层模块出现错误，将异步调用此回调。客户端必须停止正在进行的操作并清理资源，然后应从头开始启动传感器会话。
- **[Ievent_callback_type.onValues](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/ievent_callback_type_onvalues1.html)**  

每当传感器数据可用时，都会调用此回调。在 proto 消息中编码的实际传感器数据通过此回调传递。客户端需要解码 proto\_encoded\_message 以获取传感器数据。有关详细信息，可参见[编码和解码 protobuf 消息](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/encoding_and_decoding_protobuf_messages.html)。

**Parent Topic:** [传感器 API](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/qesdk_sensor_apis.html)

Last Published: Jun 22, 2023

[Previous Topic
delete\_session](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/delete_session.md) [Next Topic
发送请求](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/send_request.md)