From b0db5e1c330ade4cfa188105468aa6fd60293ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Tue, 4 Nov 2025 10:28:06 +0100 Subject: [PATCH] shared/hfp: Add extended response code enabling command --- src/shared/hfp.c | 36 ++++++++++++++++++++++++++++++++++-- unit/test-hfp.c | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/shared/hfp.c b/src/shared/hfp.c index bc81a07ee..2342c24df 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -1996,7 +1996,7 @@ static void clip_cb(struct hfp_context *context, void *user_data) hfp->callbacks_data); } -static void clip_resp(enum hfp_result result, enum hfp_error cme_err, +static void cmee_resp(enum hfp_result result, enum hfp_error cme_err, void *user_data) { struct hfp_hf *hfp = user_data; @@ -2004,7 +2004,7 @@ static void clip_resp(enum hfp_result result, enum hfp_error cme_err, DBG(hfp, ""); if (result != HFP_RESULT_OK) { - DBG(hfp, "hf: CLIP error: %d", result); + DBG(hfp, "hf: CMEE error: %d", result); goto failed; } @@ -2020,6 +2020,38 @@ failed: hfp->callbacks_data); } +static void clip_resp(enum hfp_result result, enum hfp_error cme_err, + void *user_data) +{ + struct hfp_hf *hfp = user_data; + + DBG(hfp, ""); + + if (result != HFP_RESULT_OK) { + DBG(hfp, "hf: CLIP error: %d", result); + goto failed; + } + + if (!(hfp->features & HFP_AG_FEAT_EXTENDED_RES_CODE)) { + /* Jump to next setup state */ + cmee_resp(HFP_RESULT_OK, cme_err, user_data); + return; + } + + if (!hfp_hf_send_command(hfp, cmee_resp, hfp, "AT+CMEE=1")) { + DBG(hfp, "hf: Could not send AT+CMEE=1"); + result = HFP_RESULT_ERROR; + goto failed; + } + + return; + +failed: + if (hfp->callbacks->session_ready) + hfp->callbacks->session_ready(result, cme_err, + hfp->callbacks_data); +} + static void cops_resp(enum hfp_result result, enum hfp_error cme_err, void *user_data) { diff --git a/unit/test-hfp.c b/unit/test-hfp.c index 3973df5cf..fc9fb1865 100644 --- a/unit/test-hfp.c +++ b/unit/test-hfp.c @@ -762,6 +762,7 @@ static void test_hf_robustness(gconstpointer data) raw_pdu('\r', '\n', '+', 'C', 'O', 'P', 'S', ':', ' ', '0', ',', \ '0', ',', '\"', 'T', 'E', 'S', 'T', '\"', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \ + raw_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \ raw_pdu('\r', '\n', 'O', 'K', '\r', '\n') static void hf_cmd_complete(enum hfp_result res, enum hfp_error cme_err, -- 2.47.3