feat: 添加编译时模块开关配置
通过 sdkconfig.defaults 选择性启用/禁用模块,减少固件体积: 新增模块开关: - CONFIG_MIMI_CHAN_TELEGRAM (默认 n) - CONFIG_MIMI_CHAN_FEISHU (默认 y) - CONFIG_MIMI_TOOL_WEB_SEARCH (默认 y) - CONFIG_MIMI_TOOL_GPIO (默认 n) - CONFIG_MIMI_WS_SERVER (默认 y) - CONFIG_MIMI_WIFI_ONBOARD (默认 y) - CONFIG_MIMI_OTA (默认 n) 技术实现: - CMakeLists.txt 条件编译源文件 - 头文件使用 static inline stub - CLI 命令和工具注册也支持条件编译 消除 Telegram 未配置时的 5 秒轮询警告日志
This commit is contained in:
@@ -1012,6 +1012,7 @@ esp_err_t serial_cli_init(void)
|
||||
esp_console_cmd_register(&wifi_scan_cmd);
|
||||
|
||||
/* set_tg_token */
|
||||
#ifdef CONFIG_MIMI_CHAN_TELEGRAM
|
||||
tg_token_args.token = arg_str1(NULL, NULL, "<token>", "Telegram bot token");
|
||||
tg_token_args.end = arg_end(1);
|
||||
esp_console_cmd_t tg_token_cmd = {
|
||||
@@ -1021,8 +1022,13 @@ esp_err_t serial_cli_init(void)
|
||||
.argtable = &tg_token_args,
|
||||
};
|
||||
esp_console_cmd_register(&tg_token_cmd);
|
||||
#else
|
||||
(void)cmd_set_tg_token;
|
||||
(void)tg_token_args;
|
||||
#endif
|
||||
|
||||
/* set_feishu_creds */
|
||||
#ifdef CONFIG_MIMI_CHAN_FEISHU
|
||||
feishu_creds_args.app_id = arg_str1(NULL, NULL, "<app_id>", "Feishu App ID");
|
||||
feishu_creds_args.app_secret = arg_str1(NULL, NULL, "<app_secret>", "Feishu App Secret");
|
||||
feishu_creds_args.end = arg_end(2);
|
||||
@@ -1045,6 +1051,12 @@ esp_err_t serial_cli_init(void)
|
||||
.argtable = &feishu_send_args,
|
||||
};
|
||||
esp_console_cmd_register(&feishu_send_cmd);
|
||||
#else
|
||||
(void)cmd_set_feishu_creds;
|
||||
(void)cmd_feishu_send;
|
||||
(void)feishu_creds_args;
|
||||
(void)feishu_send_args;
|
||||
#endif
|
||||
|
||||
/* set_api_key */
|
||||
api_key_args.key = arg_str1(NULL, NULL, "<key>", "LLM API key");
|
||||
@@ -1200,6 +1212,7 @@ esp_err_t serial_cli_init(void)
|
||||
esp_console_cmd_register(&heap_cmd);
|
||||
|
||||
/* set_search_key */
|
||||
#ifdef CONFIG_MIMI_TOOL_WEB_SEARCH
|
||||
search_key_args.key = arg_str1(NULL, NULL, "<key>", "Brave Search API key");
|
||||
search_key_args.end = arg_end(1);
|
||||
esp_console_cmd_t search_key_cmd = {
|
||||
@@ -1220,6 +1233,12 @@ esp_err_t serial_cli_init(void)
|
||||
.argtable = &tavily_key_args,
|
||||
};
|
||||
esp_console_cmd_register(&tavily_key_cmd);
|
||||
#else
|
||||
(void)cmd_set_search_key;
|
||||
(void)cmd_set_tavily_key;
|
||||
(void)search_key_args;
|
||||
(void)tavily_key_args;
|
||||
#endif
|
||||
|
||||
/* set_proxy */
|
||||
proxy_args.host = arg_str1(NULL, NULL, "<host>", "Proxy host/IP");
|
||||
@@ -1302,6 +1321,7 @@ esp_err_t serial_cli_init(void)
|
||||
esp_console_cmd_register(&tool_exec_cmd);
|
||||
|
||||
/* web_search */
|
||||
#ifdef CONFIG_MIMI_TOOL_WEB_SEARCH
|
||||
web_search_args.query = arg_str1(NULL, NULL, "<query>", "Search query");
|
||||
web_search_args.end = arg_end(1);
|
||||
esp_console_cmd_t web_search_cmd = {
|
||||
@@ -1311,6 +1331,10 @@ esp_err_t serial_cli_init(void)
|
||||
.argtable = &web_search_args,
|
||||
};
|
||||
esp_console_cmd_register(&web_search_cmd);
|
||||
#else
|
||||
(void)cmd_web_search;
|
||||
(void)web_search_args;
|
||||
#endif
|
||||
|
||||
/* restart */
|
||||
esp_console_cmd_t restart_cmd = {
|
||||
|
||||
Reference in New Issue
Block a user