From def24a7fe392dd954a4093be304df7e9a27e4acd Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Fri, 31 Jul 2015 14:28:46 +0200 Subject: [PATCH] hfp: fix compile --- src/hfp.h | 2 ++ src/hfp_ag.c | 32 +++++++++++++++++++++++++++++--- src/hfp_hf.c | 10 ++++------ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/hfp.h b/src/hfp.h index c53c52b7b..669668231 100644 --- a/src/hfp.h +++ b/src/hfp.h @@ -212,6 +212,8 @@ typedef struct hfp_connection { uint32_t remote_supported_features; uint8_t remote_indicators_update_enabled; + + uint32_t remote_indicators_status; hfp_callback_t callback; } hfp_connection_t; diff --git a/src/hfp_ag.c b/src/hfp_ag.c index d27563545..19e371fec 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -77,6 +77,26 @@ static char *hfp_ag_call_hold_services[6]; static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); + +static int has_codec_negotiation_feature(hfp_connection_t * connection){ + int hf = get_bit(connection->remote_supported_features, HFP_HFSF_CODEC_NEGOTIATION); + int ag = get_bit(hfp_supported_features, HFP_AGSF_CODEC_NEGOTIATION); + return hf && ag; +} + +static int has_call_waiting_and_3way_calling_feature(hfp_connection_t * connection){ + int hf = get_bit(connection->remote_supported_features, HFP_HFSF_THREE_WAY_CALLING); + int ag = get_bit(hfp_supported_features, HFP_AGSF_THREE_WAY_CALLING); + return hf && ag; +} + + +static int has_hf_indicators_feature(hfp_connection_t * connection){ + int hf = get_bit(connection->remote_supported_features, HFP_HFSF_HF_INDICATORS); + int ag = get_bit(hfp_supported_features, HFP_AGSF_HF_INDICATORS); + return hf && ag; +} + void hfp_ag_create_service(uint8_t * service, int rfcomm_channel_nr, const char * name, uint8_t ability_to_reject_call, uint16_t supported_features){ if (!name){ name = default_hfp_ag_service_name; @@ -160,12 +180,12 @@ int hfp_ag_indicators_status_join(char * buffer, int buffer_size){ int hfp_ag_call_services_join(char * buffer, int buffer_size){ if (buffer_size < hfp_ag_call_hold_services_nr * 3) return 0; int i; - int offset = 0; + int offset = snprintf(buffer, buffer_size, "("); for (i = 0; i < hfp_ag_call_hold_services_nr-1; i++) { offset += snprintf(buffer+offset, buffer_size-offset, "%s,", hfp_ag_call_hold_services[i]); } if (istate){ - + case HFP_W4_EXCHANGE_SUPPORTED_FEATURES: + if (has_codec_negotiation_feature(context)){ + context->state = HFP_NOTIFY_ON_CODECS; + break; + } + context->state = HFP_RETRIEVE_INDICATORS; + break; default: break; } diff --git a/src/hfp_hf.c b/src/hfp_hf.c index f363a020f..7f0764ac3 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -68,24 +68,24 @@ static uint8_t hfp_codecs_nr = 0; static uint8_t hfp_codecs[HFP_MAX_NUM_CODECS]; static uint8_t hfp_indicators_nr = 0; -static uint8_t hfp_indicators[HFP_MAX_NUM_INDICATORS]; +static uint8_t hfp_indicators[HFP_MAX_NUM_HF_INDICATORS]; static uint8_t hfp_indicators_status; -int has_codec_negotiation_feature(hfp_connection_t * connection){ +static int has_codec_negotiation_feature(hfp_connection_t * connection){ int hf = get_bit(hfp_supported_features, HFP_HFSF_CODEC_NEGOTIATION); int ag = get_bit(connection->remote_supported_features, HFP_AGSF_CODEC_NEGOTIATION); return hf && ag; } -int has_call_waiting_and_3way_calling_feature(hfp_connection_t * connection){ +static int has_call_waiting_and_3way_calling_feature(hfp_connection_t * connection){ int hf = get_bit(hfp_supported_features, HFP_HFSF_THREE_WAY_CALLING); int ag = get_bit(connection->remote_supported_features, HFP_AGSF_THREE_WAY_CALLING); return hf && ag; } -int has_hf_indicators_feature(hfp_connection_t * connection){ +static int has_hf_indicators_feature(hfp_connection_t * connection){ int hf = get_bit(hfp_supported_features, HFP_HFSF_HF_INDICATORS); int ag = get_bit(connection->remote_supported_features, HFP_AGSF_HF_INDICATORS); return hf && ag; @@ -270,7 +270,6 @@ void handle_switch_on_ok(hfp_connection_t *context){ printf("handle switch on OK\n"); switch (context->state){ case HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS: - context->remote_hf_indicators_status = 0; context->state = HFP_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS; break; @@ -291,7 +290,6 @@ void handle_switch_on_ok(hfp_connection_t *context){ context->state = HFP_RETRIEVE_INDICATORS; break; case HFP_W4_RETRIEVE_INDICATORS: - context->remote_indicators_status = 0; context->state = HFP_RETRIEVE_INDICATORS_STATUS; break;