Files
fusion/mw/has_task_msg_manager/has_task_msg.h

69 lines
2.4 KiB
C
Raw Normal View History

2025-12-24 16:45:17 +08:00
#ifndef HAS_TASK_MSG_H
#define HAS_TASK_MSG_H
/* 静态订阅表 */
// TODO后续可支持动态增加模块订阅感觉目前没必要
typedef enum {
INVALID_ID = 0,
GUI,
SENSOR,
ACM,
WIFI,
VOICE,
MODULE_MAX
} has_module_ID_e;
/* 格式:模块 订阅数量 订阅模块 */
2025-12-24 16:45:17 +08:00
#define SUBSCIBE_INFO \
{ \
2025-12-29 14:32:03 +08:00
{GUI, 4, {ACM, SENSOR, WIFI, VOICE}}, \
{SENSOR, 1, {GUI}}, \
2025-12-24 16:45:17 +08:00
}
2025-12-30 15:39:29 +08:00
// #define SUBSCIBE_INFO \
// { \
// {GUI, 4, {ACM, WIFI, VOICE, SENSOR}}, \
// {SENSOR, 5, {ACM, GUI, WIFI, VOICE, SENSOR}}, \
// {ACM, 4, {GUI, WIFI, VOICE, SENSOR}}, \
// {WIFI, 4, {ACM, GUI, VOICE, SENSOR}}, \
// {VOICE, 4, {ACM, WIFI, GUI, SENSOR}}, \
// }
/**
* @brief
* @param module_id:id号
* @param buf:
* @param len:
* @return 0: -1
*/
2025-12-24 16:45:17 +08:00
typedef int (*has_msg_handle_cb)(unsigned char module_id, const unsigned char *buf, unsigned int len);
/* -------------------- 注意 Attention -------------------- */
/* 对于同一个id,不能同时在不同线程中调用 *_handle*, *_receive* 和 *delete_all* 的接口 */
/* For the same id, the *_handle*, *_receive* and *delete_all* API cannot be called in different threads at the same time */
2025-12-24 16:45:17 +08:00
/* 基础功能 */
int has_msg_init(void);
int has_msg_os_init(void);
2025-12-30 15:39:29 +08:00
int has_msg_init_module(has_module_ID_e module_id); // HAS OS调用
2025-12-24 16:45:17 +08:00
int has_msg_publish(has_module_ID_e module_id, void *buffer, unsigned int length);
int has_msg_handle(has_module_ID_e module_id, has_msg_handle_cb cb, int ms_timeout);
2025-12-30 15:39:29 +08:00
2025-12-24 16:45:17 +08:00
unsigned int has_msg_is_message_empty(has_module_ID_e module_id);
unsigned int has_msg_get_message_number(has_module_ID_e module_id);
int has_msg_delete_all_message(has_module_ID_e module_id);
/* 扩展功能 */
int has_msg_handle_by_module(has_module_ID_e module_id, has_msg_handle_cb cb, has_module_ID_e pub_module_id);
int has_msg_handle_latest(has_module_ID_e module_id, has_msg_handle_cb cb, int ms_timeout);
unsigned int has_msg_receive(has_module_ID_e module_id, unsigned char *pub_module_id, unsigned char *buf_out, int ms_timeout);
unsigned int has_msg_receive_latest(has_module_ID_e module_id, unsigned char *pub_module_id, unsigned char *buf_out, int ms_timeout);
2025-12-24 16:45:17 +08:00
int has_msg_printf_subscribe(has_module_ID_e module_id);
// int has_msg_subscribe(has_module_ID_e module_id, has_module_ID_e sub_id);
// int has_msg_unsubscribe(has_module_ID_e module_id, has_module_ID_e sub_id);
#endif