diff --git a/main/cli/serial_cli.c b/main/cli/serial_cli.c index f8b8aae..49fed0a 100644 --- a/main/cli/serial_cli.c +++ b/main/cli/serial_cli.c @@ -80,6 +80,13 @@ static struct { struct arg_end *end; } feishu_creds_args; +/* --- feishu_send command --- */ +static struct { + struct arg_str *receive_id; + struct arg_str *text; + struct arg_end *end; +} feishu_send_args; + static int cmd_set_feishu_creds(int argc, char **argv) { int nerrors = arg_parse(argc, argv, (void **)&feishu_creds_args); @@ -93,6 +100,20 @@ static int cmd_set_feishu_creds(int argc, char **argv) return 0; } +static int cmd_feishu_send(int argc, char **argv) +{ + int nerrors = arg_parse(argc, argv, (void **)&feishu_send_args); + if (nerrors != 0) { + arg_print_errors(stderr, feishu_send_args.end, argv[0]); + return 1; + } + + esp_err_t err = feishu_send_message(feishu_send_args.receive_id->sval[0], + feishu_send_args.text->sval[0]); + printf("feishu_send status: %s\n", esp_err_to_name(err)); + return (err == ESP_OK) ? 0 : 1; +} + /* --- set_api_key command --- */ static struct { struct arg_str *key; @@ -652,6 +673,18 @@ esp_err_t serial_cli_init(void) }; esp_console_cmd_register(&feishu_creds_cmd); + /* feishu_send */ + feishu_send_args.receive_id = arg_str1(NULL, NULL, "", "Feishu open_id/chat_id"); + feishu_send_args.text = arg_str1(NULL, NULL, "", "Text message (quote if contains spaces)"); + feishu_send_args.end = arg_end(2); + esp_console_cmd_t feishu_send_cmd = { + .command = "feishu_send", + .help = "Send Feishu text: feishu_send \"hello\"", + .func = &cmd_feishu_send, + .argtable = &feishu_send_args, + }; + esp_console_cmd_register(&feishu_send_cmd); + /* set_api_key */ api_key_args.key = arg_str1(NULL, NULL, "", "LLM API key"); api_key_args.end = arg_end(1);