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:
2026-04-03 20:15:26 +08:00
parent 540bfe825f
commit 6983a1f1ba
15 changed files with 455 additions and 154 deletions

View File

@@ -2,35 +2,25 @@
#include "esp_err.h"
/**
* Initialize the Feishu bot (load credentials from NVS / build-time).
*/
#ifdef CONFIG_MIMI_CHAN_FEISHU
esp_err_t feishu_bot_init(void);
/**
* Start the Feishu webhook HTTP server for receiving events.
* Listens on MIMI_FEISHU_WEBHOOK_PORT.
*/
esp_err_t feishu_bot_start(void);
/**
* Send a text message to a Feishu chat.
* Automatically splits messages longer than MIMI_FEISHU_MAX_MSG_LEN chars.
* @param chat_id Feishu chat ID (open_id or chat_id)
* @param text Message text
*/
esp_err_t feishu_send_message(const char *chat_id, const char *text);
/**
* Reply to a specific message in a Feishu chat.
* @param message_id The message_id to reply to
* @param text Reply text
*/
esp_err_t feishu_reply_message(const char *message_id, const char *text);
/**
* Save Feishu app credentials to NVS.
* @param app_id Feishu App ID
* @param app_secret Feishu App Secret
*/
esp_err_t feishu_set_credentials(const char *app_id, const char *app_secret);
#else
static inline esp_err_t feishu_bot_init(void) { return ESP_OK; }
static inline esp_err_t feishu_bot_start(void) { return ESP_OK; }
static inline esp_err_t feishu_send_message(const char *chat_id, const char *text) {
(void)chat_id; (void)text;
return ESP_OK;
}
static inline esp_err_t feishu_reply_message(const char *message_id, const char *text) {
(void)message_id; (void)text;
return ESP_OK;
}
static inline esp_err_t feishu_set_credentials(const char *app_id, const char *app_secret) {
(void)app_id; (void)app_secret;
return ESP_OK;
}
#endif

View File

@@ -2,26 +2,20 @@
#include "esp_err.h"
/**
* Initialize the Telegram bot.
*/
#ifdef CONFIG_MIMI_CHAN_TELEGRAM
esp_err_t telegram_bot_init(void);
/**
* Start the Telegram polling task (long polling on Core 0).
*/
esp_err_t telegram_bot_start(void);
/**
* Send a text message to a Telegram chat.
* Automatically splits messages longer than 4096 chars.
* @param chat_id Telegram chat ID (numeric string)
* @param text Message text (supports Markdown)
*/
esp_err_t telegram_send_message(const char *chat_id, const char *text);
/**
* Save the Telegram bot token to NVS.
*/
esp_err_t telegram_set_token(const char *token);
#else
static inline esp_err_t telegram_bot_init(void) { return ESP_OK; }
static inline esp_err_t telegram_bot_start(void) { return ESP_OK; }
static inline esp_err_t telegram_send_message(const char *chat_id, const char *text) {
(void)chat_id; (void)text;
return ESP_OK;
}
static inline esp_err_t telegram_set_token(const char *token) {
(void)token;
return ESP_OK;
}
#endif