From 12cffa2e56b155f3a8394bd8756f387160e58c92 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 19 Nov 2015 16:27:56 +0100 Subject: [PATCH 1/5] disable SCO / avoid libusb warnings --- platforms/libusb/btstack-config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/libusb/btstack-config.h b/platforms/libusb/btstack-config.h index 8c5f79fa7..05498edb5 100644 --- a/platforms/libusb/btstack-config.h +++ b/platforms/libusb/btstack-config.h @@ -21,6 +21,6 @@ #define HAVE_HCI_DUMP #define SDP_DES_DUMP -#define HAVE_SCO +// #define HAVE_SCO #endif From 3d00ae4485fd23c2941b4ae4b703b6a4ba6e0fb9 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 19 Nov 2015 16:28:18 +0100 Subject: [PATCH 2/5] fix ringing --- src/hfp_ag.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hfp_ag.c b/src/hfp_ag.c index c93c1a6f0..e49ca13e5 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -76,6 +76,7 @@ static char *hfp_ag_call_hold_services[6]; static hfp_callback_t hfp_callback; static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); +static void hfp_run_for_context(hfp_connection_t *context); hfp_generic_status_indicator_t * get_hfp_generic_status_indicators(); int get_hfp_generic_status_indicators_nr(); @@ -621,10 +622,14 @@ static hfp_connection_t * hfp_ag_context_for_timer(timer_source_t * ts){ static void hfp_timeout_handler(timer_source_t * timer){ hfp_connection_t * context = hfp_ag_context_for_timer(timer); if (!context) return; + log_info("HFP start ring timeout, con handle 0x%02x", context->con_handle); context->ag_ring = 1; + run_loop_set_timer(&context->hfp_timeout, 2000); // 5 seconds timeout run_loop_add_timer(&context->hfp_timeout); + + hfp_run_for_context(context); } static void hfp_timeout_start(hfp_connection_t * context){ @@ -635,7 +640,7 @@ static void hfp_timeout_start(hfp_connection_t * context){ } static void hfp_timeout_stop(hfp_connection_t * context){ - log_info("HFP stor ring timeout, con handle 0x%02x", context->con_handle); + log_info("HFP stop ring timeout, con handle 0x%02x", context->con_handle); run_loop_remove_timer(&context->hfp_timeout); } @@ -674,11 +679,13 @@ static int incoming_call_state_machine(hfp_connection_t * context){ indicator->status = HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS; hfp_ag_transfer_ag_indicators_status_cmd(context->rfcomm_cid, indicator); + hfp_timeout_start(context); + context->ag_ring = 1; + if (use_in_band_tone()){ context->call_state = HFP_CALL_TRIGGER_AUDIO_CONNECTION; } else { context->call_state = HFP_CALL_W4_ANSWER; - hfp_timeout_start(context); hfp_emit_event(hfp_callback, HFP_SUBEVENT_START_RINGINIG, 0); } return 1; @@ -686,6 +693,7 @@ static int incoming_call_state_machine(hfp_connection_t * context){ case HFP_CALL_W4_ANSWER: if (context->command != HFP_CMD_CALL_ANSWERED) { if (context->ag_ring){ + context->ag_ring = 0; hfp_ag_ring(context->rfcomm_cid); return 1; } From 6471a72da018b82c70ca2182a855705e71739a0e Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 19 Nov 2015 16:28:29 +0100 Subject: [PATCH 3/5] fix usage --- test/pts/hfp_ag_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pts/hfp_ag_test.c b/test/pts/hfp_ag_test.c index 887190d9e..e75194df7 100644 --- a/test/pts/hfp_ag_test.c +++ b/test/pts/hfp_ag_test.c @@ -120,8 +120,8 @@ static void show_usage(void){ printf("c - simulate incoming call\n"); printf("C - simulate terminage call\n"); - printf("r - enable in-band ring tone\n"); - printf("R - disable in-band ring tone\n"); + printf("r - disable in-band ring tone\n"); + printf("R - enable in-band ring tone\n"); printf("t - terminate connection\n"); printf("---\n"); From b999e2ece68863470fe9ab3b987316b46f105f17 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 19 Nov 2015 16:54:48 +0100 Subject: [PATCH 4/5] re-enable SCO to maybe receive SCO data --- platforms/libusb/btstack-config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/libusb/btstack-config.h b/platforms/libusb/btstack-config.h index 05498edb5..8c5f79fa7 100644 --- a/platforms/libusb/btstack-config.h +++ b/platforms/libusb/btstack-config.h @@ -21,6 +21,6 @@ #define HAVE_HCI_DUMP #define SDP_DES_DUMP -// #define HAVE_SCO +#define HAVE_SCO #endif From bf128db5dc7e2fc29eeeafa41d850cfd8711fdfc Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 19 Nov 2015 16:55:24 +0100 Subject: [PATCH 5/5] fix update in-band ring tone feature, reset state for second call --- src/hfp_ag.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hfp_ag.c b/src/hfp_ag.c index e49ca13e5..4cffae2c4 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -664,6 +664,7 @@ static int incoming_call_state_machine(hfp_connection_t * context){ indicator->status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS; context->terminate_call = 0; context->run_call_state_machine = 0; + context->call_state = HFP_CALL_IDLE; hfp_emit_event(hfp_callback, HFP_SUBEVENT_CALL_TERMINATED, 0); hfp_ag_transfer_ag_indicators_status_cmd(context->rfcomm_cid, indicator); return 1; @@ -745,7 +746,7 @@ static int incoming_call_state_machine(hfp_connection_t * context){ } return 0; case HFP_CALL_ACTIVE: - printf(" HFP_CALL_ACTIVE \n"); + // printf(" HFP_CALL_ACTIVE \n"); break; default: break; @@ -943,7 +944,7 @@ void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone){ if (get_bit(hfp_supported_features, HFP_AGSF_IN_BAND_RING_TONE) == use_in_band_ring_tone){ return; } - store_bit(hfp_supported_features, HFP_AGSF_IN_BAND_RING_TONE, use_in_band_ring_tone); + hfp_supported_features = store_bit(hfp_supported_features, HFP_AGSF_IN_BAND_RING_TONE, use_in_band_ring_tone); linked_list_iterator_t it; linked_list_iterator_init(&it, hfp_get_connections());