# 编码和解码 protobuf 消息

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

本节介绍如何编码消息数据以获取传感器的 SUID 和向传感器子系统发送请求，以及如何解码由传感器子系统通过回调函数发送的数据。

- **[请求消息](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/requesting_message.html)**  

传感器子系统只能理解协议缓冲区编码的请求。必须准备 `sns_client_request_msg` 才能通过协议缓冲区 Java API（由 .proto 文件生成）启用 `activity_recognition` 传感器。
- **[解码消息](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/decoding_message.html)**

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

Last Published: Jun 22, 2023

[Previous Topic
活动识别枚举](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/activity_recognition_enums.md) [Next Topic
请求消息](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/requesting_message.md)