Files
Smart-granary-code/components/su-03t/include/su-03t_voice.h

56 lines
1.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 文件: components/su-03t/include/su-03t_voice.h
* 角色: SU-03T 语音命令解析与分发
* 说明:
* - 这里维护语音消息号到业务命令的映射。
* - 主接收回调只负责拿到帧,这里负责做语义判断和后续分发。
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "su-03t.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
SU03T_VOICE_CMD_ASK_TEMP = 0x00,
SU03T_VOICE_CMD_ASK_HUMI = 0x01,
SU03T_VOICE_CMD_ASK_LUX = 0x02,
SU03T_VOICE_CMD_ASK_MQ2 = 0x03,
SU03T_VOICE_CMD_ASK_CO2 = 0x04,
SU03T_VOICE_CMD_ASK_WEIGHT = 0x05,
SU03T_VOICE_CMD_ASK_HUM = 0x06,
SU03T_VOICE_CMD_ASK_DOOR = 0x07,
SU03T_VOICE_CMD_ASK_FAN = 0x08,
SU03T_VOICE_CMD_ASK_LIGHT = 0x09,
SU03T_VOICE_CMD_ASK_COOL = 0x0A,
SU03T_VOICE_CMD_ASK_HOT = 0x0B,
SU03T_VOICE_CMD_ASK_CONTROL = 0x0C,
SU03T_VOICE_CMD_ASK_RICE = 0x0D,
SU03T_VOICE_CMD_UNKNOWN = 0xFF,
} su03t_voice_cmd_id_t;
typedef struct {
su03t_voice_cmd_id_t id;
uint8_t msgno;
const char *key;
const char *label;
} su03t_voice_command_t;
const su03t_voice_command_t *su03t_voice_command_from_msgno(uint8_t msgno);
const char *su03t_voice_command_key(uint8_t msgno);
void su03t_voice_handle_frame(const su03t_frame_t *frame);
/* 以 8 字节 little-endian double 作为参数区发送一帧。 */
esp_err_t su03t_voice_send_double_reply(uint8_t msgno, double value);
/* 从接收帧参数区解析 little-endian double要求 params_len == 8。 */
bool su03t_voice_parse_double_payload(const su03t_frame_t *frame, double *out_value);
#ifdef __cplusplus
}
#endif