fix: fix telegram sent error in cron task.
Signed-off-by: Bo <boironic@gmail.com>
This commit is contained in:
36
main/mimi.c
36
main/mimi.c
@@ -21,6 +21,8 @@
|
||||
#include "cli/serial_cli.h"
|
||||
#include "proxy/http_proxy.h"
|
||||
#include "tools/tool_registry.h"
|
||||
#include "cron/cron_service.h"
|
||||
#include "heartbeat/heartbeat.h"
|
||||
#include "display/display.h"
|
||||
#include "buttons/button_driver.h"
|
||||
#include "ui/config_screen.h"
|
||||
@@ -75,9 +77,23 @@ static void outbound_dispatch_task(void *arg)
|
||||
ESP_LOGI(TAG, "Dispatching response to %s:%s", msg.channel, msg.chat_id);
|
||||
|
||||
if (strcmp(msg.channel, MIMI_CHAN_TELEGRAM) == 0) {
|
||||
telegram_send_message(msg.chat_id, msg.content);
|
||||
esp_err_t send_err = telegram_send_message(msg.chat_id, msg.content);
|
||||
if (send_err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Telegram send failed for %s: %s", msg.chat_id, esp_err_to_name(send_err));
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Telegram send success for %s (%d bytes)", msg.chat_id, (int)strlen(msg.content));
|
||||
}
|
||||
if (config_screen_is_active()) {
|
||||
config_screen_toggle();
|
||||
}
|
||||
char title[48];
|
||||
snprintf(title, sizeof(title), "TG OUT %s", msg.chat_id);
|
||||
display_show_message_card(title, msg.content);
|
||||
} else if (strcmp(msg.channel, MIMI_CHAN_WEBSOCKET) == 0) {
|
||||
ws_server_send(msg.chat_id, msg.content);
|
||||
esp_err_t ws_err = ws_server_send(msg.chat_id, msg.content);
|
||||
if (ws_err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "WS send failed for %s: %s", msg.chat_id, esp_err_to_name(ws_err));
|
||||
}
|
||||
} else if (strcmp(msg.channel, MIMI_CHAN_SYSTEM) == 0) {
|
||||
ESP_LOGI(TAG, "System message [%s]: %.128s", msg.chat_id, msg.content);
|
||||
} else {
|
||||
@@ -92,6 +108,7 @@ void app_main(void)
|
||||
{
|
||||
/* Silence noisy components */
|
||||
esp_log_level_set("esp-x509-crt-bundle", ESP_LOG_WARN);
|
||||
esp_log_level_set("QRCODE", ESP_LOG_WARN);
|
||||
|
||||
ESP_LOGI(TAG, "========================================");
|
||||
ESP_LOGI(TAG, " MimiClaw - ESP32-S3 AI Agent");
|
||||
@@ -144,19 +161,20 @@ void app_main(void)
|
||||
if (wifi_manager_wait_connected(30000) == ESP_OK) {
|
||||
ESP_LOGI(TAG, "WiFi connected: %s", wifi_manager_get_ip());
|
||||
|
||||
/* Outbound dispatch task should start first to avoid dropping early replies. */
|
||||
ESP_ERROR_CHECK((xTaskCreatePinnedToCore(
|
||||
outbound_dispatch_task, "outbound",
|
||||
MIMI_OUTBOUND_STACK, NULL,
|
||||
MIMI_OUTBOUND_PRIO, NULL, MIMI_OUTBOUND_CORE) == pdPASS)
|
||||
? ESP_OK : ESP_FAIL);
|
||||
|
||||
/* Start network-dependent services */
|
||||
ESP_ERROR_CHECK(telegram_bot_start());
|
||||
ESP_ERROR_CHECK(agent_loop_start());
|
||||
ESP_ERROR_CHECK(telegram_bot_start());
|
||||
cron_service_start();
|
||||
heartbeat_start();
|
||||
ESP_ERROR_CHECK(ws_server_start());
|
||||
|
||||
/* Outbound dispatch task */
|
||||
xTaskCreatePinnedToCore(
|
||||
outbound_dispatch_task, "outbound",
|
||||
MIMI_OUTBOUND_STACK, NULL,
|
||||
MIMI_OUTBOUND_PRIO, NULL, MIMI_OUTBOUND_CORE);
|
||||
|
||||
ESP_LOGI(TAG, "All services started!");
|
||||
} else {
|
||||
ESP_LOGW(TAG, "WiFi connection timeout. Check MIMI_SECRET_WIFI_SSID in mimi_secrets.h");
|
||||
|
||||
Reference in New Issue
Block a user