feat(bt): pont data SCO HCI vers audio_router
Ajoute sco_incoming_cb et sco_outgoing_cb dans bt_hfp.c. Enregistre les callbacks sur AUDIO_STATE connecte (CVSD/mSBC). REQUIRES audio_router dans CMakeLists.txt. Build vert, boot non regressé (flash + monitor 2026-06-19).
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "bt_hfp.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES bt
|
||||
REQUIRES bt audio_router
|
||||
)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "esp_bt_device.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "esp_hf_client_api.h"
|
||||
#include "audio_router.h"
|
||||
|
||||
#define TAG "bt_hfp"
|
||||
|
||||
@@ -35,6 +36,18 @@ static void emit(bt_hfp_event_t ev, const char *number, bool msbc)
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- Callbacks data SCO : pont PCM BT <-> audio_router ---- */
|
||||
static void sco_incoming_cb(const uint8_t *buf, uint32_t len)
|
||||
{
|
||||
audio_router_sco_feed_playback(buf, len);
|
||||
esp_hf_client_outgoing_data_ready();
|
||||
}
|
||||
|
||||
static uint32_t sco_outgoing_cb(uint8_t *buf, uint32_t len)
|
||||
{
|
||||
return audio_router_sco_take_capture(buf, len);
|
||||
}
|
||||
|
||||
/* ---- GAP callback : appairage / authentification / SSP ---- */
|
||||
static void gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
|
||||
{
|
||||
@@ -133,6 +146,7 @@ static void hf_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *para
|
||||
ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC);
|
||||
ESP_LOGI(TAG, "audio SCO connecte (%s)", msbc ? "mSBC 16k" : "CVSD 8k");
|
||||
emit(BT_HFP_EV_AUDIO_CONNECTED, NULL, msbc);
|
||||
esp_hf_client_register_data_callback(sco_incoming_cb, sco_outgoing_cb);
|
||||
} else if (param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_DISCONNECTED) {
|
||||
ESP_LOGI(TAG, "audio SCO deconnecte");
|
||||
emit(BT_HFP_EV_AUDIO_DISCONNECTED, NULL, false);
|
||||
|
||||
Reference in New Issue
Block a user