Files
RTC_BL_PHONE/components/cli/cli.c
T
clement 178931899a
Repo State / repo-state (push) Failing after 12m17s
feat(audio): AEC NLMS adaptatif (mode aec 2)
2026-06-19 22:53:12 +02:00

72 lines
2.2 KiB
C

/*
* cli.c — petit CLI serie (console UART0) pour regler les gains audio et le
* filtre micro a la volee, sans recompiler. Coexiste avec les logs ESP_LOG.
*/
#include "cli.h"
#include "audio_router.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAG "cli"
static void handle(char *l)
{
if (strncmp(l, "gmic", 4) == 0) {
audio_router_set_mic_gain(atoi(l + 4));
ESP_LOGI(TAG, "gain micro = %d", audio_router_get_mic_gain());
} else if (strncmp(l, "gspk", 4) == 0) {
audio_router_set_play_gain(atoi(l + 4));
ESP_LOGI(TAG, "gain ecouteur = %d", audio_router_get_play_gain());
} else if (strncmp(l, "filt", 4) == 0) {
int on = atoi(l + 4);
audio_router_set_mic_filter(on != 0);
ESP_LOGI(TAG, "filtre micro = %s", on ? "ON" : "OFF");
} else if (strncmp(l, "aecd", 4) == 0) {
audio_router_set_aec_delay(atoi(l + 4));
ESP_LOGI(TAG, "AEC retard = %d samples", atoi(l + 4));
} else if (strncmp(l, "aecmu", 5) == 0) {
audio_router_set_aec_mu(atoi(l + 5));
ESP_LOGI(TAG, "AEC mu = %d%%", atoi(l + 5));
} else if (strncmp(l, "aec", 3) == 0) {
audio_router_set_aec(atoi(l + 3));
ESP_LOGI(TAG, "anti-echo = %d (0=off 1=suppress 2=NLMS)", audio_router_get_aec());
} else if (strncmp(l, "status", 6) == 0) {
ESP_LOGI(TAG, "gspk=%d gmic=%d aec=%d",
audio_router_get_play_gain(), audio_router_get_mic_gain(),
audio_router_get_aec());
} else {
ESP_LOGI(TAG, "cmds: gmic N|gspk N|filt 0/1|aec 0/1/2|aecd N|aecmu N|status");
}
}
static void cli_task(void *a)
{
(void)a;
char line[48];
int pos = 0;
ESP_LOGI(TAG, "CLI prete — gmic N / gspk N / filt 0/1 / status");
for (;;) {
int c = getchar();
if (c == EOF) {
vTaskDelay(pdMS_TO_TICKS(30));
continue;
}
if (c == '\n' || c == '\r') {
if (pos > 0) { line[pos] = '\0'; handle(line); pos = 0; }
} else if (pos < (int)sizeof(line) - 1) {
line[pos++] = (char)c;
}
}
}
void cli_start(void)
{
xTaskCreate(cli_task, "cli", 3072, NULL, 3, NULL);
}