feat: 添加 console_user_cmds 组件,提供用户命令支持

This commit is contained in:
Wang Beihong
2026-03-06 13:21:11 +08:00
parent ae294c0b6a
commit 6782af2d4a
6 changed files with 531 additions and 169 deletions

View File

@@ -1,4 +1,4 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS "."
REQUIRES wifi-connect esp_lvgl_port lvgl_st7735s_use i2c_master_messager io_device_control console_simple_init console
REQUIRES wifi-connect esp_lvgl_port lvgl_st7735s_use i2c_master_messager io_device_control console_simple_init console console_user_cmds
)

View File

@@ -10,6 +10,7 @@
#include "i2c_master_messager.h"
#include "io_device_control.h"
#include "console_simple_init.h" // 提供 console_cmd_user_register 和 console_cmd_all_register
#include "console_user_cmds.h"
#ifndef CONFIG_I2C_MASTER_MESSAGER_BH1750_ENABLE
#define CONFIG_I2C_MASTER_MESSAGER_BH1750_ENABLE 0
@@ -42,12 +43,6 @@
static const char *TAG = "main";
static int cmd_hello(int argc, char **argv)
{
printf("hello from BotanicalBuddy\n");
return 0;
}
void app_main(void)
{
// 初始化 Wi-Fi 配网组件,支持长按按键进入配网
@@ -55,7 +50,7 @@ void app_main(void)
printf("设备启动完成:长按按键进入配网模式,手机连接 ESP32-* 后访问 http://192.168.4.1\n");
ESP_ERROR_CHECK(console_cmd_init());
ESP_ERROR_CHECK(console_cmd_user_register("hello", cmd_hello));
ESP_ERROR_CHECK(console_user_cmds_register());
ESP_ERROR_CHECK(console_cmd_all_register()); // 可选:自动注册插件命令
ESP_ERROR_CHECK(console_cmd_start());