shared/hfp: Add Operator name support
PATCH 1/4 shared/hfp: Add Operator name support
Send AT+COPS=3,0 at the end of the SLC creation to set the format of the operator selection to long alphanumeric, then query the currently selected operator name from the AG.
Register +COPS handler to call the update_operator callback on event.
--- src/shared/hfp.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++-- src/shared/hfp.h | 1 + 2 files changed, 83 insertions(+), 2 deletions(-)
src/shared/hfp.c +82 -2
@@ -1710,7 +1710,30 @@ static void ciev_cb(struct hfp_context *context, void *user_data)set_indicator_value (index, val, hfp->ag_ind, hfp); } -static void slc_cmer_resp (enum hfp_result result,enum hfp_error cme_err, +static void cops_cb (struct hfp_context *context,void *user_data) +{ +struct hfp_hf *hfp = user_data; +unsigned int mode, val; +char name[255 ]; + +DBG (hfp,"" ); + +if (!hfp_context_get_number (context, &mode)) +return ; + +if (!hfp_context_get_number (context, &val)) +return ; + +if (!hfp_context_get_string (context, name,sizeof (name))) { +DBG (hfp,"hf: Could not get string" ); +return ; + } + +if (hfp->callbacks && hfp->callbacks->update_operator) + hfp->callbacks->update_operator (name, hfp->callbacks_data); +} + +static void cops_resp (enum hfp_result result,enum hfp_error cme_err,void *user_data) {struct hfp_hf *hfp = user_data;
@@ -1718,7 +1741,7 @@ static void slc_cmer_resp(enum hfp_result result, enum hfp_error cme_err,DBG (hfp,"" );if (result !=HFP_RESULT_OK ) { -DBG (hfp,"hf: CMER error: %d" , result); +DBG (hfp,"hf: COPS? error: %d" , result); goto failed; }
@@ -1726,8 +1749,65 @@ static void slc_cmer_resp(enum hfp_result result, enum hfp_error cme_err, hfp->callbacks->session_ready (HFP_RESULT_OK ,0 , hfp->callbacks_data); +return ; + +failed: +if (hfp->callbacks->session_ready) + hfp->callbacks->session_ready (result, cme_err, + hfp->callbacks_data); +} + +static void cops_conf_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: COPS= error: %d" , result); + goto failed; + } + +/* SLC creation done, continue with default setup */ +if (!hfp_hf_send_command (hfp, cops_resp, hfp, +"AT+COPS?" )) { +DBG (hfp,"hf: Could not send AT+COPS?" ); + 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 slc_cmer_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: CMER error: %d" , result); + goto failed; + } + +/* SLC creation done, continue with default setup */ +if (!hfp_hf_send_command (hfp, cops_conf_resp, hfp, +"AT+COPS=3,0" )) { +DBG (hfp,"hf: Could not send AT+COPS=3,0" ); + result =HFP_RESULT_ERROR ; + goto failed; + } +/* Register unsolicited results handlers */ hfp_hf_register (hfp, ciev_cb,"+CIEV" , hfp,NULL ); +hfp_hf_register (hfp, cops_cb,"+COPS" , hfp,NULL );return ;
src/shared/hfp.h +1 -0
@@ -190,6 +190,7 @@ struct hfp_hf_callbacks { void *user_data);void (*update_indicator)(enum hfp_indicator indicator,uint32_t val,void *user_data); +void (*update_operator)(const char *operator_name,void *user_data); };struct hfp_hf *hfp_hf_new (int fd);
Signature · 1 line
2.43.0
PATCH 2/4 unit/test-hfp: Add Operator name test for HF
This add the following test:
- HFP/HF/PSI/BV-04-C
Verify that the HF can query the currently selected operator name.
Improve MINIMAL_SLC_SESSION macro to be able to set the service, call, callsetup and callheld indicators at connection time.
--- unit/test-hfp.c | 50 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-)
unit/test-hfp.c +40 -10
@@ -699,7 +699,7 @@ static void test_hf_robustness(gconstpointer data)context_quit (context); } -#define MINIMAL_SLC_SESSION \ +#define MINIMAL_SLC_SESSION (service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \
@@ -722,10 +722,15 @@ static void test_hf_robustness(gconstpointer data)frg_pdu ('\r' ,'\n' ), \frg_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'N' ,'D' ,':' ,' ' ), \ -frg_pdu ('0' ,',' ,'0' ,',' ,'0' ,',' ,'0' ,',' ,'5' ), \ -frg_pdu (',' ,'0' ,',' ,'5' ,'\r' ,'\n' ), \ +frg_pdu (service,',' , call,',' , callsetup,',' , callheld,',' ), \ +frg_pdu ('5' ,',' ,'0' ,',' ,'5' ,'\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' ), \ +raw_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \ +raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'O' ,'P' ,'S' ,':' ,' ' ), \ +frg_pdu ('0' ,',' ,'0' ,',' ,'\"' ,'T' ,'E' ,'S' ,'T' ), \ +frg_pdu ('\"' ,'\r' ,'\n' ), \ + frg_pdu('\r', '\n', 'O', 'K', '\r', '\n') static void hf_session_ready_cb(enum hfp_result res, enum hfp_error cme_err, void *user_data)
@@ -745,7 +750,13 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,if (!context->session.completed) {switch (indicator) {case HFP_INDICATOR_SERVICE : - g_assert_cmpint(val, ==, 0); +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-03-C" ) || +g_str_equal (test_name,"/HFP/HF/TRS/BV-01-C" ) || +g_str_equal (test_name, +"/hfp_hf/test_session_minimal" )) + g_assert_cmpint(val, ==, 0); +else + g_assert_cmpint(val, ==, 1);break ;case HFP_INDICATOR_CALL : g_assert_cmpint(val, ==, 0);
@@ -789,9 +800,22 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val, } } +static void hf_update_operator (const char *operator_name,void *user_data) +{ +struct context *context = user_data; +const char *test_name = context->data->test_name; + +if (tester_use_debug ()) +tester_debug ("operator updated: %s" , operator_name); + +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-04-C" )) + g_assert_cmpstr(operator_name, ==, "TEST"); +} +static struct hfp_hf_callbacks hf_session_callbacks = { .session_ready = hf_session_ready_cb, .update_indicator = hf_update_indicator, + .update_operator = hf_update_operator, }; static void test_hf_session_done(enum hfp_result res, enum hfp_error cme_err,
@@ -996,13 +1020,13 @@ int main(int argc, char *argv[])define_hf_test ("/hfp_hf/test_session_minimal" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),data_end ());/* Transfer Signal Strength Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-01-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'5' ,',' ,'3' ,'\r' ,'\n' ),data_end ());
@@ -1010,7 +1034,7 @@ int main(int argc, char *argv[])/* Transfer Roaming Status Indication - HF */ define_hf_test("/HFP/HF/PSI/BV-02-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION, + MINIMAL_SLC_SESSION('1', '0', '0', '0'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), frg_pdu(' ', '6', ',', '1', '\r', '\n'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
@@ -1020,15 +1044,21 @@ int main(int argc, char *argv[])/* Transfer Battery Level Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-03-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'7' ,',' ,'3' ,'\r' ,'\n' ),data_end ()); +/* Transfer Operator name - HF */ +define_hf_test ("/HFP/HF/PSI/BV-04-C" , test_hf_session, +NULL , test_hf_session_done, +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ), +data_end ()); +/* Transfer Registration Status - HF */ define_hf_test("/HFP/HF/TRS/BV-01-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION, + MINIMAL_SLC_SESSION('0', '0', '0', '0'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), frg_pdu(' ', '1', ',', '1', '\r', '\n'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
Signature · 1 line
2.43.0
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ 2/4] unit/test-hfp: Add Operator name test for HF
Hi Frédéric,
Quoted 16 lines · Frédéric Danis
This add the following test:
- HFP/HF/PSI/BV-04-C
Verify that the HF can query the currently selected operator name.Improve
MINIMAL_SLC_SESSIONmacro to be able to set the service, call, callsetup and callheld indicators at connection time.--- unit/test-hfp.c | 50 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-)unit/test-hfp.c +0
-0
unit/test-hfp.c static void test_hf_robustness(gconstpointer data) · line 702
Quoted 5 lines
unit/test-hfp.c +1
-1@@ -699,7 +699,7 @@ static void test_hf_robustness(gconstpointer data)context_quit (context); } -#define MINIMAL_SLC_SESSION \ +#define MINIMAL_SLC_SESSION (service, call, callsetup, callheld) \
WARNING:MACRO_ARG_UNUSED: Argument 'service' is not used in function-like macro #10: FILE: unit/test-hfp.c:702:
+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \
raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \
' ', '0', '\r', '\n'), \
frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'call' is not used in function-like macro #10: FILE: unit/test-hfp.c:702:
+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \
raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \
' ', '0', '\r', '\n'), \
frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'callsetup' is not used in function-like macro
#10: FILE: unit/test-hfp.c:702:
+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \
raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \
' ', '0', '\r', '\n'), \
frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'callheld' is not used in function-like macro #10: FILE: unit/test-hfp.c:702:
+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \
raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \
' ', '0', '\r', '\n'), \
frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \- total: 0 errors, 4 warnings, 108 lines checked
Quoted 113 lines
unit/test-hfp.c +39
-10raw_pdu ('\r' ,'\n' ,'+' ,'B' ,'R' ,'S' ,'F' ,':' , \' ' ,'0' ,'\r' ,'\n' ), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \@@ -722,10 +722,15 @@ static void test_hf_robustness(gconstpointer data)frg_pdu ('\r' ,'\n' ), \frg_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'N' ,'D' ,':' ,' ' ), \ -frg_pdu ('0' ,',' ,'0' ,',' ,'0' ,',' ,'0' ,',' ,'5' ), \ -frg_pdu (',' ,'0' ,',' ,'5' ,'\r' ,'\n' ), \ +frg_pdu (service,',' , call,',' , callsetup,',' , callheld,',' ), \ +frg_pdu ('5' ,',' ,'0' ,',' ,'5' ,'\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' ), \ +raw_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \ +raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'O' ,'P' ,'S' ,':' ,' ' ), \ +frg_pdu ('0' ,',' ,'0' ,',' ,'\"' ,'T' ,'E' ,'S' ,'T' ), \ +frg_pdu ('\"' ,'\r' ,'\n' ), \ + frg_pdu('\r', '\n', 'O', 'K', '\r', '\n') static void hf_session_ready_cb(enum hfp_result res, enum hfp_error cme_err, void *user_data)@@ -745,7 +750,13 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,if (!context->session.completed) {switch (indicator) {case HFP_INDICATOR_SERVICE : - g_assert_cmpint(val, ==, 0); +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-03-C" ) || +g_str_equal (test_name,"/HFP/HF/TRS/BV-01-C" ) || +g_str_equal (test_name, +"/hfp_hf/test_session_minimal" )) + g_assert_cmpint(val, ==, 0); +else + g_assert_cmpint(val, ==, 1);break ;case HFP_INDICATOR_CALL : g_assert_cmpint(val, ==, 0);@@ -789,9 +800,22 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val, } } +static void hf_update_operator (const char *operator_name,void *user_data) +{ +struct context *context = user_data; +const char *test_name = context->data->test_name; + +if (tester_use_debug ()) +tester_debug ("operator updated: %s" , operator_name); + +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-04-C" )) + g_assert_cmpstr(operator_name, ==, "TEST"); +} +static struct hfp_hf_callbacks hf_session_callbacks = { .session_ready = hf_session_ready_cb, .update_indicator = hf_update_indicator, + .update_operator = hf_update_operator, }; static void test_hf_session_done(enum hfp_result res, enum hfp_error cme_err,@@ -996,13 +1020,13 @@ int main(int argc, char *argv[])define_hf_test ("/hfp_hf/test_session_minimal" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),data_end ());/* Transfer Signal Strength Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-01-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'5' ,',' ,'3' ,'\r' ,'\n' ),data_end ());@@ -1010,7 +1034,7 @@ int main(int argc, char *argv[])/* Transfer Roaming Status Indication - HF */ define_hf_test("/HFP/HF/PSI/BV-02-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION, + MINIMAL_SLC_SESSION('1', '0', '0', '0'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), frg_pdu(' ', '6', ',', '1', '\r', '\n'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),@@ -1020,15 +1044,21 @@ int main(int argc, char *argv[])/* Transfer Battery Level Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-03-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'7' ,',' ,'3' ,'\r' ,'\n' ),data_end ()); +/* Transfer Operator name - HF */ +define_hf_test ("/HFP/HF/PSI/BV-04-C" , test_hf_session, +NULL , test_hf_session_done, +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ), +data_end ()); +/* Transfer Registration Status - HF */ define_hf_test("/HFP/HF/TRS/BV-01-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION, + MINIMAL_SLC_SESSION('0', '0', '0', '0'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), frg_pdu(' ', '1', ',', '1', '\r', '\n'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), --2.43.0
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH BlueZ 2/4] unit/test-hfp: Add Operator name test for HF
Hi Luiz,
Quoted 46 lines · Luiz Augusto von Dentz
Hi Frédéric,
Quoted 15 lines · Frédéric Danis
This add the following test:
- HFP/HF/PSI/BV-04-C
Verify that the HF can query the currently selected operator name.Improve
MINIMAL_SLC_SESSIONmacro to be able to set the service, call, callsetup and callheld indicators at connection time.--- unit/test-hfp.c | 50 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-)unit/test-hfp.c +0
-0unit/test-hfp.c static void test_hf_robustness(gconstpointer data) · line 702
Quoted 5 lines
unit/test-hfp.c +1
-1@@ -699,7 +699,7 @@ static void test_hf_robustness(gconstpointer data)context_quit (context); } -#define MINIMAL_SLC_SESSION \ +#define MINIMAL_SLC_SESSION (service, call, callsetup, callheld) \WARNING:MACRO_ARG_UNUSED: Argument 'service' is not used in function-like macro #10: FILE:
unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'call' is not used in function-like macro #10: FILE:
unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'callsetup' is not used in function-like macro
#10: FILE:unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \
Quoted 8 lines
WARNING:MACRO_ARG_UNUSED: Argument 'callheld' is not used in function-like macro #10: FILE:
unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \- total: 0 errors, 4 warnings, 108 lines checked
Yes, I saw this, it is due to argument usage is done in the next hunk, and checkpatch failsto parse it.
Quoted 105 lines
Quoted 105 lines
unit/test-hfp.c +38
-9raw_pdu ('\r' ,'\n' ,'+' ,'B' ,'R' ,'S' ,'F' ,':' , \' ' ,'0' ,'\r' ,'\n' ), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \@@ -722,10 +722,15 @@ static void test_hf_robustness(gconstpointer data)frg_pdu ('\r' ,'\n' ), \frg_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'N' ,'D' ,':' ,' ' ), \ -frg_pdu ('0' ,',' ,'0' ,',' ,'0' ,',' ,'0' ,',' ,'5' ), \ -frg_pdu (',' ,'0' ,',' ,'5' ,'\r' ,'\n' ), \ +frg_pdu (service,',' , call,',' , callsetup,',' , callheld,',' ), \ +frg_pdu ('5' ,',' ,'0' ,',' ,'5' ,'\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' ), \ +raw_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \ +raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'O' ,'P' ,'S' ,':' ,' ' ), \ +frg_pdu ('0' ,',' ,'0' ,',' ,'\"' ,'T' ,'E' ,'S' ,'T' ), \ +frg_pdu ('\"' ,'\r' ,'\n' ), \ + frg_pdu('\r', '\n', 'O', 'K', '\r', '\n') static void hf_session_ready_cb(enum hfp_result res, enum hfp_error cme_err, void *user_data)@@ -745,7 +750,13 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,if (!context->session.completed) {switch (indicator) {case HFP_INDICATOR_SERVICE : - g_assert_cmpint(val, ==, 0); +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-03-C" ) || +g_str_equal (test_name,"/HFP/HF/TRS/BV-01-C" ) || +g_str_equal (test_name, +"/hfp_hf/test_session_minimal" )) + g_assert_cmpint(val, ==, 0); +else + g_assert_cmpint(val, ==, 1);break ;case HFP_INDICATOR_CALL : g_assert_cmpint(val, ==, 0);@@ -789,9 +800,22 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val, } } +static void hf_update_operator (const char *operator_name,void *user_data) +{ +struct context *context = user_data; +const char *test_name = context->data->test_name; + +if (tester_use_debug ()) +tester_debug ("operator updated: %s" , operator_name); + +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-04-C" )) + g_assert_cmpstr(operator_name, ==, "TEST"); +} +static struct hfp_hf_callbacks hf_session_callbacks = { .session_ready = hf_session_ready_cb, .update_indicator = hf_update_indicator, + .update_operator = hf_update_operator, }; static void test_hf_session_done(enum hfp_result res, enum hfp_error cme_err,@@ -996,13 +1020,13 @@ int main(int argc, char *argv[])define_hf_test ("/hfp_hf/test_session_minimal" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),data_end ());/* Transfer Signal Strength Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-01-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'5' ,',' ,'3' ,'\r' ,'\n' ),data_end ());@@ -1010,7 +1034,7 @@ int main(int argc, char *argv[])/* Transfer Roaming Status Indication - HF */ define_hf_test("/HFP/HF/PSI/BV-02-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION, + MINIMAL_SLC_SESSION('1', '0', '0', '0'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), frg_pdu(' ', '6', ',', '1', '\r', '\n'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),@@ -1020,15 +1044,21 @@ int main(int argc, char *argv[])/* Transfer Battery Level Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-03-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'7' ,',' ,'3' ,'\r' ,'\n' ),data_end ()); +/* Transfer Operator name - HF */ +define_hf_test ("/HFP/HF/PSI/BV-04-C" , test_hf_session, +NULL , test_hf_session_done, +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ), +data_end ()); +/* Transfer Registration Status - HF */ define_hf_test("/HFP/HF/TRS/BV-01-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION,
Quoted 9 lines
Quoted 8 lines
unit/test-hfp.c +1
-1+MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'1' ,',' ,'1' ,'\r' ,'\n' ), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), --2.43.0
Regards,
Fred
Signature · 6 lines
Frédéric Danis Senior Software Engineer Collabora Ltd. Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, United Kingdom Registered in England & Wales, no. 5513718
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ 2/4] unit/test-hfp: Add Operator name test for HF
Hi Frédéric,
Quoted 57 lines · Frédéric Danis
Hi Luiz,
Quoted 53 lines · Luiz Augusto von Dentz
Hi Frédéric,
Quoted 15 lines · Frédéric Danis
This add the following test:
- HFP/HF/PSI/BV-04-C
Verify that the HF can query the currently selected operator name.Improve
MINIMAL_SLC_SESSIONmacro to be able to set the service, call, callsetup and callheld indicators at connection time.--- unit/test-hfp.c | 50 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-)unit/test-hfp.c +0
-0unit/test-hfp.c static void test_hf_robustness(gconstpointer data) · line 702
Quoted 5 lines
unit/test-hfp.c +1
-1@@ -699,7 +699,7 @@ static void test_hf_robustness(gconstpointer data)context_quit (context); } -#define MINIMAL_SLC_SESSION \ +#define MINIMAL_SLC_SESSION (service, call, callsetup, callheld) \WARNING:MACRO_ARG_UNUSED: Argument 'service' is not used in function-like macro #10: FILE:
unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'call' is not used in function-like macro #10: FILE:
unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'callsetup' is not used in function-like macro
#10: FILE:unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \WARNING:MACRO_ARG_UNUSED: Argument 'callheld' is not used in function-like macro #10: FILE:
unit/test-hfp.c:702:+#define MINIMAL_SLC_SESSION(service, call, callsetup, callheld) \ raw_pdu('\r', '\n', '+', 'B', 'R', 'S', 'F', ':', \ ' ', '0', '\r', '\n'), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \
Quoted 4 lines
Quoted 1 line
- total: 0 errors, 4 warnings, 108 lines checked
Yes, I saw this, it is due to argument usage is done in the next hunk, and checkpatch failsto parse it.
I'd recommend introducing them in the next change then, otherwise this may break things like bisect.
Quoted 126 lines
Quoted 105 lines
Quoted 105 lines
unit/test-hfp.c +38
-9raw_pdu ('\r' ,'\n' ,'+' ,'B' ,'R' ,'S' ,'F' ,':' , \' ' ,'0' ,'\r' ,'\n' ), \ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \@@ -722,10 +722,15 @@ static void test_hf_robustness(gconstpointer data)frg_pdu ('\r' ,'\n' ), \frg_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'N' ,'D' ,':' ,' ' ), \ -frg_pdu ('0' ,',' ,'0' ,',' ,'0' ,',' ,'0' ,',' ,'5' ), \ -frg_pdu (',' ,'0' ,',' ,'5' ,'\r' ,'\n' ), \ +frg_pdu (service,',' , call,',' , callsetup,',' , callheld,',' ), \ +frg_pdu ('5' ,',' ,'0' ,',' ,'5' ,'\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' ), \ +raw_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \ +raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'O' ,'P' ,'S' ,':' ,' ' ), \ +frg_pdu ('0' ,',' ,'0' ,',' ,'\"' ,'T' ,'E' ,'S' ,'T' ), \ +frg_pdu ('\"' ,'\r' ,'\n' ), \ + frg_pdu('\r', '\n', 'O', 'K', '\r', '\n') static void hf_session_ready_cb(enum hfp_result res, enum hfp_error cme_err, void *user_data)@@ -745,7 +750,13 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,if (!context->session.completed) {switch (indicator) {case HFP_INDICATOR_SERVICE : - g_assert_cmpint(val, ==, 0); +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-03-C" ) || +g_str_equal (test_name,"/HFP/HF/TRS/BV-01-C" ) || +g_str_equal (test_name, +"/hfp_hf/test_session_minimal" )) + g_assert_cmpint(val, ==, 0); +else + g_assert_cmpint(val, ==, 1);break ;case HFP_INDICATOR_CALL : g_assert_cmpint(val, ==, 0);@@ -789,9 +800,22 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val, } } +static void hf_update_operator (const char *operator_name,void *user_data) +{ +struct context *context = user_data; +const char *test_name = context->data->test_name; + +if (tester_use_debug ()) +tester_debug ("operator updated: %s" , operator_name); + +if (g_str_equal (test_name,"/HFP/HF/PSI/BV-04-C" )) + g_assert_cmpstr(operator_name, ==, "TEST"); +} +static struct hfp_hf_callbacks hf_session_callbacks = { .session_ready = hf_session_ready_cb, .update_indicator = hf_update_indicator, + .update_operator = hf_update_operator, }; static void test_hf_session_done(enum hfp_result res, enum hfp_error cme_err,@@ -996,13 +1020,13 @@ int main(int argc, char *argv[])define_hf_test ("/hfp_hf/test_session_minimal" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),data_end ());/* Transfer Signal Strength Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-01-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'5' ,',' ,'3' ,'\r' ,'\n' ),data_end ());@@ -1010,7 +1034,7 @@ int main(int argc, char *argv[])/* Transfer Roaming Status Indication - HF */ define_hf_test("/HFP/HF/PSI/BV-02-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION, + MINIMAL_SLC_SESSION('1', '0', '0', '0'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), frg_pdu(' ', '6', ',', '1', '\r', '\n'), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),@@ -1020,15 +1044,21 @@ int main(int argc, char *argv[])/* Transfer Battery Level Indication - HF */ define_hf_test ("/HFP/HF/PSI/BV-03-C" , test_hf_session,NULL , test_hf_session_done, -MINIMAL_SLC_SESSION , +MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'7' ,',' ,'3' ,'\r' ,'\n' ),data_end ()); +/* Transfer Operator name - HF */ +define_hf_test ("/HFP/HF/PSI/BV-04-C" , test_hf_session, +NULL , test_hf_session_done, +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ), +data_end ()); +/* Transfer Registration Status - HF */ define_hf_test("/HFP/HF/TRS/BV-01-C", test_hf_session, NULL, test_hf_session_done, - MINIMAL_SLC_SESSION,Quoted 9 lines
Quoted 8 lines
unit/test-hfp.c +1
-1+MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ),frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ),frg_pdu (' ' ,'1' ,',' ,'1' ,'\r' ,'\n' ), frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'), --2.43.0
Regards,
Fred
--
Frédéric Danis
Senior Software EngineerCollabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, United Kingdom Registered in England & Wales, no. 5513718
Signature · 1 line
Luiz Augusto von Dentz
PATCH 3/4 shared/hfp: Add Call Line Identification support
In reply to Frédéric DanisSend AT+CLIP=1 at the end of the SLC creation to enable CLIP event. Register +CLIP handler to call the update_call_line_id callback on event.
During incoming call notifications, i.e. after +CIEV:<callsetup>,1 event which creates a new call object, the reception of +CLIP event will update the line_id and type of the call object.
--- src/shared/hfp.c | 238 ++++++++++++++++++++++++++++++++++++++++++++++- src/shared/hfp.h | 20 ++++ 2 files changed, 255 insertions(+), 3 deletions(-)
src/shared/hfp.c +235 -3
@@ -18,6 +18,7 @@#include <string.h> #include <stdarg.h> #include <ctype.h> +#include <limits.h> #include "src/shared/util.h" #include "src/shared/ringbuf.h"
@@ -29,7 +30,7 @@ hfp_debug(_hfp->debug_callback, _hfp->debug_data, "%s:%s() " fmt, \ __FILE__, __func__, ## arg) -#define HFP_HF_FEATURES (HFP_HF_FEAT_ESCO_S4_T2) +#define HFP_HF_FEATURES (HFP_HF_FEAT_CLIP | HFP_HF_FEAT_ESCO_S4_T2) struct hfp_gw { int ref_count;
@@ -100,6 +101,7 @@ struct hfp_hf {bool roaming;uint8_t battchg; +struct queue *calls; };struct cmd_handler {
@@ -128,6 +130,15 @@ struct event_handler {hfp_hf_result_func_t callback; }; +struct hf_call { +uint id; +enum hfp_call_status status; +char *line_id; +uint type; + +struct hfp_hf *hfp; +}; +static void hfp_debug (hfp_debug_func_t debug_func,void *debug_data,const char *format, ...) {
@@ -1303,6 +1314,7 @@ struct hfp_hf *hfp_hf_new(int fd) hfp->event_handlers =queue_new (); hfp->cmd_queue =queue_new (); + hfp->calls =queue_new (); hfp->writer_active = false; if (!io_set_read_handler(hfp->io, hf_can_read_data, hfp,
@@ -1329,6 +1341,18 @@ struct hfp_hf *hfp_hf_ref(struct hfp_hf *hfp)return hfp; } +static void remove_call_cb (void *user_data) +{ +struct hf_call *call = user_data; +struct hfp_hf *hfp = call->hfp; + +if (hfp->callbacks && hfp->callbacks->call_removed) + hfp->callbacks->call_removed (call->id, hfp->callbacks_data); + +free (call->line_id); +free (call); +} +void hfp_hf_unref (struct hfp_hf *hfp) {if (!hfp)
@@ -1361,6 +1385,9 @@ void hfp_hf_unref(struct hfp_hf *hfp)queue_destroy (hfp->cmd_queue, free); hfp->cmd_queue =NULL ; +queue_destroy (hfp->calls, remove_call_cb); + hfp->calls =NULL ; +if (!hfp->in_disconnect) {free (hfp);return ;
@@ -1568,6 +1595,44 @@ bool hfp_hf_disconnect(struct hfp_hf *hfp)return io_shutdown (hfp->io); } +static bool call_id_match (const void *data,const void *match_data) +{ +const struct hf_call *call = data; +uint id =PTR_TO_UINT (match_data); + +return (call->id == id); +} + +static uint next_call_index (struct hfp_hf *hfp) +{ +for (uint i =1 ; i <UINT_MAX ; i++) { +if (!queue_find (hfp->calls, call_id_match,UINT_TO_PTR (i))) +return i; + } + +return 0 ; +} + +static struct hf_call *call_new (struct hfp_hf *hfp,unsigned int id, +enum hfp_call_status status, +char *number) +{ +struct hf_call *call; + + call = new0(struct hf_call, 1); + call->id = id; + call->status = status; + call->line_id = number; + call->hfp = hfp; +queue_push_tail (hfp->calls, call); + +if (hfp->callbacks && hfp->callbacks->call_added) + hfp->callbacks->call_added (call->id, call->status, + hfp->callbacks_data); + +return call; +} +static void ciev_service_cb (uint8_t val,void *user_data) {struct hfp_hf *hfp = user_data;
@@ -1599,9 +1664,40 @@ static void ciev_call_cb(uint8_t val, void *user_data) } } +static bool call_outgoing_match (const void *data,const void *match_data) +{ +const struct hf_call *call = data; + +return (call->status ==CALL_STATUS_DIALING || + call->status ==CALL_STATUS_ALERTING ); +} + +static bool call_incoming_match (const void *data,const void *match_data) +{ +const struct hf_call *call = data; + +return (call->status ==CALL_STATUS_INCOMING ); +} + +static bool call_setup_match (const void *data,const void *match_data) +{ +return (call_outgoing_match (data, match_data) || +call_incoming_match (data, match_data)); +} + +static bool call_active_match (const void *data,const void *match_data) +{ +const struct hf_call *call = data; + +return (call->status ==CALL_STATUS_ACTIVE ); +} +static void ciev_callsetup_cb (uint8_t val,void *user_data) {struct hfp_hf *hfp = user_data; +struct hf_call *call; +uint id; +enum hfp_call_status status;DBG (hfp,"%u" , val);
@@ -1610,6 +1706,57 @@ static void ciev_callsetup_cb(uint8_t val, void *user_data)DBG (hfp,"hf: Incorrect call setup state: %u" , val);return ; } + +switch (val) { +case CIND_CALLSETUP_NONE : +/* remove call in setup phase */ +queue_remove_all (hfp->calls, call_setup_match, hfp, + remove_call_cb); +break ; +case CIND_CALLSETUP_INCOMING : +if (queue_length (hfp->calls) !=0 ) { +DBG (hfp,"hf: Call already exists" ); +return ; + } + + id =next_call_index (hfp); +if (id ==0 ) { +DBG (hfp,"hf: No new call index available" ); +return ; + } +call_new (hfp, id,CALL_STATUS_INCOMING ,NULL ); +break ; +case CIND_CALLSETUP_DIALING : +case CIND_CALLSETUP_ALERTING : +if (val ==CIND_CALLSETUP_DIALING ) + status =CALL_STATUS_DIALING ; +else + status =CALL_STATUS_ALERTING ; + +if (queue_find (hfp->calls, call_active_match,NULL )) { +DBG (hfp,"hf: Error: active call" ); +return ; + } + + call =queue_find (hfp->calls, call_outgoing_match,NULL ); +if (call && call->status != status) { + call->status = status; +if (hfp->callbacks && + hfp->callbacks->call_status_updated) + hfp->callbacks->call_status_updated (call->id, + call->status, + hfp->callbacks_data); +return ; + } + + id =next_call_index (hfp); +if (id ==0 ) { +DBG (hfp,"hf: No new call index available" ); +return ; + } +call_new (hfp, id, status,NULL ); +break ; + } }static void ciev_callheld_cb (uint8_t val,void *user_data)
@@ -1733,7 +1880,45 @@ static void cops_cb(struct hfp_context *context, void *user_data) hfp->callbacks->update_operator (name, hfp->callbacks_data); } -static void cops_resp (enum hfp_result result,enum hfp_error cme_err, +static void clip_cb (struct hfp_context *context,void *user_data) +{ +struct hfp_hf *hfp = user_data; +char number[255 ]; +unsigned int type; +struct hf_call *call; + +DBG (hfp,"" ); + +if (!hfp_context_get_string (context, number,sizeof (number))) { +DBG (hfp,"hf: Could not get string" ); +return ; + } + +if (!hfp_context_get_number (context, &type)) +return ; + + call =queue_find (hfp->calls, call_incoming_match,NULL ); +if (!call) { +DBG (hfp,"hf: no incoming call" ); +return ; + } + +if (call->line_id &&strcmp (call->line_id, number) ==0 && + call->type == type) +return ; + +if (call->line_id) +free (call->line_id); + call->line_id =strdup (number); + call->type = type; + +if (hfp->callbacks && hfp->callbacks->call_line_id_updated) + hfp->callbacks->call_line_id_updated (call->id, call->line_id, + call->type, + 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;
@@ -1741,7 +1926,7 @@ static void cops_resp(enum hfp_result result, enum hfp_error cme_err,DBG (hfp,"" );if (result !=HFP_RESULT_OK ) { -DBG (hfp,"hf: COPS? error: %d" , result); +DBG (hfp,"hf: CLIP error: %d" , result); goto failed; }
@@ -1757,6 +1942,34 @@ failed: hfp->callbacks_data); } +static void cops_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: COPS? error: %d" , result); + goto failed; + } + +/* SLC creation done, continue with default setup */ +if (!hfp_hf_send_command (hfp, clip_resp, hfp, +"AT+CLIP=1" )) { +DBG (hfp,"hf: Could not send AT+CLIP=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_conf_resp (enum hfp_result result,enum hfp_error cme_err,void *user_data) {
@@ -1807,6 +2020,7 @@ static void slc_cmer_resp(enum hfp_result result, enum hfp_error cme_err,/* Register unsolicited results handlers */ hfp_hf_register (hfp, ciev_cb,"+CIEV" , hfp,NULL ); +hfp_hf_register (hfp, clip_cb,"+CLIP" , hfp,NULL );hfp_hf_register (hfp, cops_cb,"+COPS" , hfp,NULL );return ;
@@ -2135,3 +2349,21 @@ bool hfp_hf_session(struct hfp_hf *hfp)return hfp_hf_send_command (hfp, slc_brsf_resp, hfp,"AT+BRSF=%u" ,HFP_HF_FEATURES ); } + +const char *hfp_hf_call_get_number (struct hfp_hf *hfp,uint id) +{ +struct hf_call *call; + +DBG (hfp,"" ); + +if (!hfp) +return false; + + call =queue_find (hfp->calls, call_id_match,UINT_TO_PTR (id)); +if (!call) { +DBG (hfp,"hf: no call with id: %u" , id); +return false; + } + +return call->line_id; +}
src/shared/hfp.h +20 -0
@@ -114,6 +114,16 @@ enum hfp_call_held {CIND_CALLHELD_HOLD }; +enum hfp_call_status { +CALL_STATUS_ACTIVE =0 , +CALL_STATUS_HELD , +CALL_STATUS_DIALING , +CALL_STATUS_ALERTING , +CALL_STATUS_INCOMING , +CALL_STATUS_WAITING , +CALL_STATUS_RESPONSE_AND_HOLD +}; +struct hfp_context ; typedef void (*hfp_result_func_t)(struct hfp_context *context,
@@ -191,6 +201,14 @@ struct hfp_hf_callbacks {void (*update_indicator)(enum hfp_indicator indicator,uint32_t val,void *user_data);void (*update_operator)(const char *operator_name,void *user_data); + +void (*call_added)(uint id,enum hfp_call_status status, +void *user_data); +void (*call_removed)(uint id,void *user_data); +void (*call_status_updated)(uint id,enum hfp_call_status status, +void *user_data); +void (*call_line_id_updated)(uint id,const char *number,uint type, +void *user_data); };struct hfp_hf *hfp_hf_new (int fd);
@@ -216,3 +234,5 @@ bool hfp_hf_session_register(struct hfp_hf *hfp,struct hfp_hf_callbacks *callbacks, void *callbacks_data);bool hfp_hf_session (struct hfp_hf *hfp); + +const char *hfp_hf_call_get_number (struct hfp_hf *hfp,uint id);
Signature · 1 line
2.43.0
PATCH 4/4 unit/test-hfp: Add Call Line Identification test for HF
In reply to Frédéric DanisThis add the following test:
- HFP/HF/CLI/BV-01-C
Verify that the HF receives the caller ID.
--- unit/test-hfp.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)
unit/test-hfp.c +48 -1
@@ -730,7 +730,8 @@ static void test_hf_robustness(gconstpointer data)raw_pdu ('\r' ,'\n' ,'+' ,'C' ,'O' ,'P' ,'S' ,':' ,' ' ), \frg_pdu ('0' ,',' ,'0' ,',' ,'\"' ,'T' ,'E' ,'S' ,'T' ), \frg_pdu ('\"' ,'\r' ,'\n' ), \ - frg_pdu('\r', '\n', 'O', 'K', '\r', '\n') +frg_pdu ('\r' ,'\n' ,'O' ,'K' ,'\r' ,'\n' ), \ + raw_pdu('\r', '\n', 'O', 'K', '\r', '\n')static void hf_session_ready_cb (enum hfp_result res,enum hfp_error cme_err,void *user_data)
@@ -812,10 +813,44 @@ static void hf_update_operator(const char *operator_name, void *user_data) g_assert_cmpstr(operator_name, ==, "TEST"); } +static void hf_call_added (uint id,enum hfp_call_status status, +void *user_data) +{ +struct context *context = user_data; +const char *test_name = context->data->test_name; + +if (tester_use_debug ()) +tester_debug ("call %d added: status %u" , id, status); + +if (g_str_equal (test_name,"/HFP/HF/CLI/BV-01-C" )) { + g_assert_cmpint(id, ==, 1); + g_assert_cmpint(status, ==, CALL_STATUS_INCOMING); + } +} + +static void hf_call_line_id_updated (uint id,const char *number, +unsigned int type, +void *user_data) +{ +struct context *context = user_data; +const char *str; + +if (tester_use_debug ()) +tester_debug ("call %d line id updated: %s, %u" , id, number, + type); + g_assert_cmpint(id, ==, 1); + g_assert_cmpstr(number, ==, "1234567"); + g_assert_cmpint(type, ==, 129); + str =hfp_hf_call_get_number (context->hfp_hf, id); + g_assert_cmpstr(number, ==, str); +} +static struct hfp_hf_callbacks hf_session_callbacks = { .session_ready = hf_session_ready_cb, .update_indicator = hf_update_indicator, .update_operator = hf_update_operator, + .call_added = hf_call_added, + .call_line_id_updated = hf_call_line_id_updated, }; static void test_hf_session_done(enum hfp_result res, enum hfp_error cme_err,
@@ -1023,6 +1058,18 @@ int main(int argc, char *argv[])MINIMAL_SLC_SESSION ('0' ,'0' ,'0' ,'0' ), data_end()); +/* Calling Line Identification - HF */ +define_hf_test ("/HFP/HF/CLI/BV-01-C" , test_hf_session, +NULL , test_hf_session_done, +MINIMAL_SLC_SESSION ('1' ,'0' ,'0' ,'0' ), +frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'I' ,'E' ,'V' ,':' ,' ' , +'3' ,',' ,'1' ,'\r' ,'\n' ), +frg_pdu ('\r' ,'\n' ,'R' ,'I' ,'N' ,'G' ,'\r' ,'\n' ), +frg_pdu ('\r' ,'\n' ,'+' ,'C' ,'L' ,'I' ,'P' ,':' , +'\"' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'\"' , +',' ,'1' ,'2' ,'9' ,',' ,',' ,'\r' ,'\n' ), +data_end ()); +/* Transfer Signal Strength Indication - HF */ define_hf_test("/HFP/HF/PSI/BV-01-C", test_hf_session, NULL, test_hf_session_done,
Signature · 1 line
2.43.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1001291
---Test result---
Test Summary:
CheckPatch PENDING 0.45 seconds GitLint PENDING 0.42 seconds BuildEll PASS 20.19 seconds BluezMake PASS 2758.58 seconds MakeCheck PASS 19.71 seconds MakeDistcheck PASS 183.38 seconds CheckValgrind PASS 236.93 seconds CheckSmatch PASS 306.51 seconds bluezmakeextell PASS 126.69 seconds IncrementalBuild PENDING 0.37 seconds ScanBuild PASS 914.55 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth