mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 21:35:16 +00:00
Merge branch 'master' of https://github.com/bluekitchen/btstack
This commit is contained in:
commit
74b200de27
194
src/hfp.c
194
src/hfp.c
@ -263,17 +263,7 @@ void hfp_reset_context_flags(hfp_connection_t * context){
|
||||
|
||||
context->keep_separator = 0;
|
||||
|
||||
context->retrieve_ag_indicators = 0; // HFP_CMD_INDICATOR, check if needed
|
||||
context->retrieve_ag_indicators_status = 0;
|
||||
|
||||
context->list_generic_status_indicators = 0; // HFP_CMD_LIST_GENERIC_STATUS_INDICATOR
|
||||
context->retrieve_generic_status_indicators = 0; // HFP_CMD_GENERIC_STATUS_INDICATOR
|
||||
context->retrieve_generic_status_indicators_state = 0; // HFP_CMD_GENERIC_STATUS_INDICATOR_STATE
|
||||
|
||||
context->change_status_update_for_individual_ag_indicators = 0;
|
||||
|
||||
context->operator_name_format = 0;
|
||||
context->operator_name = 0;
|
||||
context->operator_name_changed = 0;
|
||||
|
||||
context->enable_extended_audio_gateway_error_report = 0;
|
||||
@ -618,7 +608,6 @@ void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t
|
||||
static void process_command(hfp_connection_t * context){
|
||||
if (context->line_size < 2) return;
|
||||
// printf("process_command %s\n", context->line_buffer);
|
||||
context->command = HFP_CMD_NONE;
|
||||
int offset = 0;
|
||||
int isHandsFree = 1;
|
||||
|
||||
@ -649,16 +638,12 @@ static void process_command(hfp_connection_t * context){
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_INDICATOR, strlen(HFP_INDICATOR)) == 0){
|
||||
//printf("parsed HFP_INDICATOR \n");
|
||||
context->command = HFP_CMD_INDICATOR;
|
||||
if (isHandsFree) return;
|
||||
|
||||
if (strncmp((char *)context->line_buffer+strlen(HFP_INDICATOR)+offset, "?", 1) == 0){
|
||||
context->retrieve_ag_indicators_status = 1;
|
||||
context->retrieve_ag_indicators = 0;
|
||||
} else {
|
||||
context->retrieve_ag_indicators = 1;
|
||||
context->retrieve_ag_indicators_status = 0;
|
||||
context->command = HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+strlen(HFP_INDICATOR)+offset, "=?", 2) == 0){
|
||||
context->command = HFP_CMD_RETRIEVE_AG_INDICATORS;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -679,21 +664,14 @@ static void process_command(hfp_connection_t * context){
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_GENERIC_STATUS_INDICATOR, strlen(HFP_GENERIC_STATUS_INDICATOR)) == 0){
|
||||
context->command = HFP_CMD_GENERIC_STATUS_INDICATOR;
|
||||
if (isHandsFree) return;
|
||||
|
||||
if (strncmp((char *)context->line_buffer+strlen(HFP_GENERIC_STATUS_INDICATOR)+offset, "=?", 2) == 0){
|
||||
context->list_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators = 1;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
context->command = HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS;
|
||||
} else if (strncmp((char *)context->line_buffer+strlen(HFP_GENERIC_STATUS_INDICATOR)+offset, "=", 1) == 0){
|
||||
context->list_generic_status_indicators = 1;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
context->command = HFP_CMD_LIST_GENERIC_STATUS_INDICATORS;
|
||||
} else {
|
||||
context->list_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators_state = 1;
|
||||
context->command = HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -705,14 +683,12 @@ static void process_command(hfp_connection_t * context){
|
||||
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_QUERY_OPERATOR_SELECTION, strlen(HFP_QUERY_OPERATOR_SELECTION)) == 0){
|
||||
context->command = HFP_CMD_QUERY_OPERATOR_SELECTION;
|
||||
context->operator_name = 1;
|
||||
context->operator_name_format = 0;
|
||||
context->command = HFP_CMD_QUERY_OPERATOR_SELECTION_NAME;
|
||||
|
||||
if (isHandsFree) return;
|
||||
|
||||
context->operator_name = 0;
|
||||
if (strncmp((char *)context->line_buffer+strlen(HFP_QUERY_OPERATOR_SELECTION)+offset, "=", 1) == 0){
|
||||
context->operator_name_format = 1;
|
||||
context->command = HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -761,7 +737,7 @@ static void process_command(hfp_connection_t * context){
|
||||
context->command = HFP_CMD_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
context->command = HFP_CMD_NONE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -814,20 +790,15 @@ static void hfp_parser_next_state(hfp_connection_t * context, uint8_t byte){
|
||||
case HFP_PARSER_CMD_SEQUENCE:
|
||||
switch (context->command){
|
||||
case HFP_CMD_TRANSFER_AG_INDICATOR_STATUS:
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION:
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME:
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT:
|
||||
context->parser_state = HFP_PARSER_SECOND_ITEM;
|
||||
break;
|
||||
case HFP_CMD_INDICATOR:
|
||||
if (context->retrieve_ag_indicators == 1){
|
||||
context->parser_state = HFP_PARSER_SECOND_ITEM;
|
||||
break;
|
||||
}
|
||||
case HFP_CMD_RETRIEVE_AG_INDICATORS:
|
||||
context->parser_state = HFP_PARSER_SECOND_ITEM;
|
||||
break;
|
||||
case HFP_CMD_GENERIC_STATUS_INDICATOR:
|
||||
if (context->retrieve_generic_status_indicators_state == 1){
|
||||
context->parser_state = HFP_PARSER_SECOND_ITEM;
|
||||
break;
|
||||
}
|
||||
case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE:
|
||||
context->parser_state = HFP_PARSER_SECOND_ITEM;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -837,7 +808,7 @@ static void hfp_parser_next_state(hfp_connection_t * context, uint8_t byte){
|
||||
context->parser_state = HFP_PARSER_THIRD_ITEM;
|
||||
break;
|
||||
case HFP_PARSER_THIRD_ITEM:
|
||||
if (context->command == HFP_CMD_INDICATOR && context->retrieve_ag_indicators){
|
||||
if (context->command == HFP_CMD_RETRIEVE_AG_INDICATORS){
|
||||
context->parser_state = HFP_PARSER_CMD_SEQUENCE;
|
||||
break;
|
||||
}
|
||||
@ -904,19 +875,15 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
context->parser_item_index++;
|
||||
context->remote_codecs_nr = context->parser_item_index;
|
||||
break;
|
||||
case HFP_CMD_INDICATOR:
|
||||
if (context->retrieve_ag_indicators == 1){
|
||||
strcpy((char *)context->ag_indicators[context->parser_item_index].name, (char *)context->line_buffer);
|
||||
context->ag_indicators[context->parser_item_index].index = context->parser_item_index+1;
|
||||
log_info("Indicator %d: %s (", context->ag_indicators_nr+1, context->line_buffer);
|
||||
}
|
||||
|
||||
if (context->retrieve_ag_indicators_status == 1){
|
||||
log_info("Parsed Indicator %d with status: %s\n", context->parser_item_index+1, context->line_buffer);
|
||||
context->ag_indicators[context->parser_item_index].status = atoi((char *) context->line_buffer);
|
||||
context->parser_item_index++;
|
||||
break;
|
||||
}
|
||||
case HFP_CMD_RETRIEVE_AG_INDICATORS:
|
||||
strcpy((char *)context->ag_indicators[context->parser_item_index].name, (char *)context->line_buffer);
|
||||
context->ag_indicators[context->parser_item_index].index = context->parser_item_index+1;
|
||||
log_info("Indicator %d: %s (", context->ag_indicators_nr+1, context->line_buffer);
|
||||
break;
|
||||
case HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS:
|
||||
log_info("Parsed Indicator %d with status: %s\n", context->parser_item_index+1, context->line_buffer);
|
||||
context->ag_indicators[context->parser_item_index].status = atoi((char *) context->line_buffer);
|
||||
context->parser_item_index++;
|
||||
break;
|
||||
case HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE:
|
||||
context->parser_item_index++;
|
||||
@ -931,27 +898,18 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
strcpy((char *)context->remote_call_services[context->remote_call_services_nr].name, (char *)context->line_buffer);
|
||||
context->remote_call_services_nr++;
|
||||
break;
|
||||
case HFP_CMD_GENERIC_STATUS_INDICATOR:
|
||||
log_info("parser HFP_CMD_GENERIC_STATUS_INDICATOR 1 (%d, %d, %d)\n",
|
||||
context->list_generic_status_indicators,
|
||||
context->retrieve_generic_status_indicators,
|
||||
context->retrieve_generic_status_indicators_state);
|
||||
if (context->retrieve_generic_status_indicators == 1 || context->list_generic_status_indicators == 1){
|
||||
log_info("Parsed Generic status indicator: %s\n", context->line_buffer);
|
||||
context->generic_status_indicators[context->parser_item_index].uuid = (uint16_t)atoi((char*)context->line_buffer);
|
||||
context->parser_item_index++;
|
||||
context->generic_status_indicators_nr = context->parser_item_index;
|
||||
break;
|
||||
}
|
||||
log_info("parser HFP_CMD_GENERIC_STATUS_INDICATOR 2\n");
|
||||
if (context->retrieve_generic_status_indicators_state == 1){
|
||||
// HF parses inital AG gen. ind. state
|
||||
log_info("Parsed List generic status indicator %s state: ", context->line_buffer);
|
||||
context->parser_item_index = (uint8_t)atoi((char*)context->line_buffer);
|
||||
break;
|
||||
}
|
||||
case HFP_CMD_LIST_GENERIC_STATUS_INDICATORS:
|
||||
case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS:
|
||||
log_info("Parsed Generic status indicator: %s\n", context->line_buffer);
|
||||
context->generic_status_indicators[context->parser_item_index].uuid = (uint16_t)atoi((char*)context->line_buffer);
|
||||
context->parser_item_index++;
|
||||
context->generic_status_indicators_nr = context->parser_item_index;
|
||||
break;
|
||||
case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE:
|
||||
// HF parses inital AG gen. ind. state
|
||||
log_info("Parsed List generic status indicator %s state: ", context->line_buffer);
|
||||
context->parser_item_index = (uint8_t)atoi((char*)context->line_buffer);
|
||||
break;
|
||||
|
||||
case HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE:
|
||||
// AG parses new gen. ind. state
|
||||
log_info("Parsed Enable ag indicator state: %s\n", context->line_buffer);
|
||||
@ -965,24 +923,18 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
// indicators are indexed starting with 1
|
||||
context->parser_item_index = atoi((char *)&context->line_buffer[0]) - 1;
|
||||
printf("Parsed status of the AG indicator %d, status ", context->parser_item_index);
|
||||
printf("\n");
|
||||
break;
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION:
|
||||
if (context->operator_name_format == 1){
|
||||
if (context->line_buffer[0] == '3'){
|
||||
log_info("Parsed Set network operator format : %s, ", context->line_buffer);
|
||||
break;
|
||||
}
|
||||
// TODO emit ERROR, wrong format
|
||||
log_info("ERROR Set network operator format: index %s not supported\n", context->line_buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
if (context->operator_name == 1) {
|
||||
context->network_operator.mode = atoi((char *)&context->line_buffer[0]);
|
||||
log_info("Parsed network operator mode: %d, ", context->network_operator.mode);
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME:
|
||||
context->network_operator.mode = atoi((char *)&context->line_buffer[0]);
|
||||
log_info("Parsed network operator mode: %d, ", context->network_operator.mode);
|
||||
break;
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT:
|
||||
if (context->line_buffer[0] == '3'){
|
||||
log_info("Parsed Set network operator format : %s, ", context->line_buffer);
|
||||
break;
|
||||
}
|
||||
// TODO emit ERROR, wrong format
|
||||
log_info("ERROR Set network operator format: index %s not supported\n", context->line_buffer);
|
||||
break;
|
||||
case HFP_CMD_ERROR:
|
||||
break;
|
||||
@ -1001,29 +953,27 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
|
||||
case HFP_PARSER_SECOND_ITEM:
|
||||
switch (context->command){
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION:
|
||||
if (context->operator_name_format == 1) {
|
||||
log_info("format %s \n", context->line_buffer);
|
||||
context->network_operator.format = atoi((char *)&context->line_buffer[0]);
|
||||
break;
|
||||
}
|
||||
if (context->operator_name == 1){
|
||||
log_info("format %s, ", context->line_buffer);
|
||||
context->network_operator.format = atoi((char *)&context->line_buffer[0]);
|
||||
}
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME:
|
||||
printf("format %s, ", context->line_buffer);
|
||||
context->network_operator.format = atoi((char *)&context->line_buffer[0]);
|
||||
break;
|
||||
case HFP_CMD_GENERIC_STATUS_INDICATOR:
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT:
|
||||
printf("format %s \n", context->line_buffer);
|
||||
context->network_operator.format = atoi((char *)&context->line_buffer[0]);
|
||||
break;
|
||||
case HFP_CMD_LIST_GENERIC_STATUS_INDICATORS:
|
||||
case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS:
|
||||
case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE:
|
||||
context->generic_status_indicators[context->parser_item_index].state = (uint8_t)atoi((char*)context->line_buffer);
|
||||
break;
|
||||
case HFP_CMD_TRANSFER_AG_INDICATOR_STATUS:
|
||||
context->ag_indicators[context->parser_item_index].status = (uint8_t)atoi((char*)context->line_buffer);
|
||||
printf("%d \n", context->ag_indicators[context->parser_item_index].status);
|
||||
context->ag_indicators[context->parser_item_index].status_changed = 1;
|
||||
break;
|
||||
case HFP_CMD_INDICATOR:
|
||||
if (context->retrieve_ag_indicators == 1){
|
||||
context->ag_indicators[context->parser_item_index].min_range = atoi((char *)context->line_buffer);
|
||||
log_info("%s, ", context->line_buffer);
|
||||
}
|
||||
case HFP_CMD_RETRIEVE_AG_INDICATORS:
|
||||
context->ag_indicators[context->parser_item_index].min_range = atoi((char *)context->line_buffer);
|
||||
log_info("%s, ", context->line_buffer);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1032,19 +982,15 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
|
||||
case HFP_PARSER_THIRD_ITEM:
|
||||
switch (context->command){
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION:
|
||||
if (context->operator_name == 1){
|
||||
strcpy(context->network_operator.name, (char *)context->line_buffer);
|
||||
log_info("name %s\n", context->line_buffer);
|
||||
}
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME:
|
||||
strcpy(context->network_operator.name, (char *)context->line_buffer);
|
||||
log_info("name %s\n", context->line_buffer);
|
||||
break;
|
||||
case HFP_CMD_INDICATOR:
|
||||
if (context->retrieve_ag_indicators == 1){
|
||||
context->ag_indicators[context->parser_item_index].max_range = atoi((char *)context->line_buffer);
|
||||
context->parser_item_index++;
|
||||
context->ag_indicators_nr = context->parser_item_index;
|
||||
log_info("%s)\n", context->line_buffer);
|
||||
}
|
||||
case HFP_CMD_RETRIEVE_AG_INDICATORS:
|
||||
context->ag_indicators[context->parser_item_index].max_range = atoi((char *)context->line_buffer);
|
||||
context->parser_item_index++;
|
||||
context->ag_indicators_nr = context->parser_item_index;
|
||||
log_info("%s)\n", context->line_buffer);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
26
src/hfp.h
26
src/hfp.h
@ -131,15 +131,23 @@ typedef enum {
|
||||
HFP_CMD_OK,
|
||||
HFP_CMD_SUPPORTED_FEATURES,
|
||||
HFP_CMD_AVAILABLE_CODECS,
|
||||
HFP_CMD_INDICATOR, // 5
|
||||
|
||||
HFP_CMD_RETRIEVE_AG_INDICATORS,
|
||||
HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS,
|
||||
|
||||
HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE,
|
||||
HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE,
|
||||
HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES,
|
||||
|
||||
HFP_CMD_GENERIC_STATUS_INDICATOR,
|
||||
|
||||
// HFP_CMD_GENERIC_STATUS_INDICATOR,
|
||||
HFP_CMD_LIST_GENERIC_STATUS_INDICATORS,
|
||||
HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS,
|
||||
HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE,
|
||||
|
||||
HFP_CMD_TRANSFER_AG_INDICATOR_STATUS,
|
||||
HFP_CMD_QUERY_OPERATOR_SELECTION,
|
||||
|
||||
HFP_CMD_QUERY_OPERATOR_SELECTION_NAME,
|
||||
HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT,
|
||||
|
||||
HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR,
|
||||
HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR,
|
||||
@ -374,18 +382,8 @@ typedef struct hfp_connection {
|
||||
uint8_t send_error;
|
||||
|
||||
uint8_t keep_separator;
|
||||
|
||||
uint8_t retrieve_ag_indicators; // HFP_CMD_INDICATOR, check if needed
|
||||
uint8_t retrieve_ag_indicators_status;
|
||||
|
||||
uint8_t list_generic_status_indicators; // HFP_CMD_LIST_GENERIC_STATUS_INDICATOR
|
||||
uint8_t retrieve_generic_status_indicators; // HFP_CMD_GENERIC_STATUS_INDICATOR
|
||||
uint8_t retrieve_generic_status_indicators_state; // HFP_CMD_GENERIC_STATUS_INDICATOR_STATE
|
||||
|
||||
uint8_t change_status_update_for_individual_ag_indicators;
|
||||
|
||||
uint8_t operator_name_format;
|
||||
uint8_t operator_name;
|
||||
uint8_t operator_name_changed;
|
||||
|
||||
uint8_t enable_extended_audio_gateway_error_report;
|
||||
|
106
src/hfp_ag.c
106
src/hfp_ag.c
@ -465,24 +465,19 @@ static int hfp_ag_run_for_context_service_level_connection(hfp_connection_t * co
|
||||
context->state = HFP_W4_RETRIEVE_INDICATORS;
|
||||
}
|
||||
break;
|
||||
case HFP_CMD_INDICATOR:
|
||||
switch(context->state){
|
||||
case HFP_W4_RETRIEVE_INDICATORS:
|
||||
if (context->retrieve_ag_indicators == 0) break;
|
||||
hfp_ag_retrieve_indicators_cmd(context->rfcomm_cid, context);
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_INDICATORS_STATUS;
|
||||
break;
|
||||
case HFP_W4_RETRIEVE_INDICATORS_STATUS:
|
||||
if (context->retrieve_ag_indicators_status == 0) break;
|
||||
hfp_ag_retrieve_indicators_status_cmd(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_ENABLE_INDICATORS_STATUS_UPDATE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case HFP_CMD_RETRIEVE_AG_INDICATORS:
|
||||
if (context->state != HFP_W4_RETRIEVE_INDICATORS) break;
|
||||
context->state = HFP_W4_RETRIEVE_INDICATORS_STATUS;
|
||||
done = 1;
|
||||
hfp_ag_retrieve_indicators_cmd(context->rfcomm_cid, context);
|
||||
break;
|
||||
case HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS:
|
||||
if (context->state != HFP_W4_RETRIEVE_INDICATORS_STATUS) break;
|
||||
context->state = HFP_W4_ENABLE_INDICATORS_STATUS_UPDATE;
|
||||
done = 1;
|
||||
hfp_ag_retrieve_indicators_status_cmd(context->rfcomm_cid);
|
||||
break;
|
||||
|
||||
case HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE:
|
||||
switch(context->state){
|
||||
case HFP_W4_ENABLE_INDICATORS_STATUS_UPDATE:
|
||||
@ -519,35 +514,26 @@ static int hfp_ag_run_for_context_service_level_connection(hfp_connection_t * co
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HFP_CMD_GENERIC_STATUS_INDICATOR:
|
||||
switch(context->state){
|
||||
case HFP_W4_LIST_GENERIC_STATUS_INDICATORS:
|
||||
if (context->list_generic_status_indicators == 0) break;
|
||||
hfp_ag_list_supported_generic_status_indicators_cmd(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS;
|
||||
context->list_generic_status_indicators = 0;
|
||||
break;
|
||||
case HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS:
|
||||
if (context->retrieve_generic_status_indicators == 0) break;
|
||||
hfp_ag_retrieve_supported_generic_status_indicators_cmd(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
break;
|
||||
case HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS:
|
||||
if (context->retrieve_generic_status_indicators_state == 0) break;
|
||||
hfp_ag_retrieve_initital_supported_generic_status_indicators_cmd(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
case HFP_CMD_LIST_GENERIC_STATUS_INDICATORS:
|
||||
if (context->state != HFP_W4_LIST_GENERIC_STATUS_INDICATORS) break;
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS;
|
||||
hfp_ag_list_supported_generic_status_indicators_cmd(context->rfcomm_cid);
|
||||
break;
|
||||
case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS:
|
||||
if (context->state != HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS) break;
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS;
|
||||
hfp_ag_retrieve_supported_generic_status_indicators_cmd(context->rfcomm_cid);
|
||||
break;
|
||||
case HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE:
|
||||
if (context->state != HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS) break;
|
||||
done = 1;
|
||||
context->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED;
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED, 0);
|
||||
hfp_ag_retrieve_initital_supported_generic_status_indicators_cmd(context->rfcomm_cid);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -564,35 +550,27 @@ static int hfp_ag_run_for_context_service_level_connection_queries(hfp_connectio
|
||||
printf(" -> State machine: SLC Queries\n");
|
||||
switch(context->command){
|
||||
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION:
|
||||
if (context->operator_name_format == 1){
|
||||
if (context->network_operator.format != 0){
|
||||
hfp_ag_error(context->rfcomm_cid);
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
hfp_ag_ok(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->operator_name_format = 0;
|
||||
break;
|
||||
}
|
||||
if (context->operator_name == 1){
|
||||
hfp_ag_report_network_operator_name_cmd(context->rfcomm_cid, context->network_operator);
|
||||
context->operator_name = 0;
|
||||
done = 1;
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME:
|
||||
done = 1;
|
||||
hfp_ag_report_network_operator_name_cmd(context->rfcomm_cid, context->network_operator);
|
||||
break;
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT:
|
||||
done = 1;
|
||||
if (context->network_operator.format != 0){
|
||||
hfp_ag_error(context->rfcomm_cid);
|
||||
break;
|
||||
}
|
||||
hfp_ag_ok(context->rfcomm_cid);
|
||||
break;
|
||||
case HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE:
|
||||
hfp_ag_ok(context->rfcomm_cid);
|
||||
done = 1;
|
||||
hfp_ag_ok(context->rfcomm_cid);
|
||||
break;
|
||||
|
||||
case HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR:
|
||||
if (context->extended_audio_gateway_error){
|
||||
hfp_ag_report_extended_audio_gateway_error(context->rfcomm_cid, context->extended_audio_gateway_error);
|
||||
context->extended_audio_gateway_error = 0;
|
||||
done = 1;
|
||||
hfp_ag_report_extended_audio_gateway_error(context->rfcomm_cid, context->extended_audio_gateway_error);
|
||||
break;
|
||||
}
|
||||
case HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE:
|
||||
|
37
src/hfp_hf.c
37
src/hfp_hf.c
@ -271,15 +271,13 @@ static int hfp_hf_run_for_context_service_level_connection(hfp_connection_t * co
|
||||
hfp_hf_cmd_retrieve_indicators(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_INDICATORS;
|
||||
context->retrieve_ag_indicators = 1;
|
||||
context->retrieve_ag_indicators_status = 0;
|
||||
context->command = HFP_CMD_RETRIEVE_AG_INDICATORS;
|
||||
break;
|
||||
case HFP_RETRIEVE_INDICATORS_STATUS:
|
||||
hfp_hf_cmd_retrieve_indicators_status(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_INDICATORS_STATUS;
|
||||
context->retrieve_ag_indicators_status = 1;
|
||||
context->retrieve_ag_indicators = 0;
|
||||
context->command = HFP_CMD_RETRIEVE_AG_INDICATORS;
|
||||
break;
|
||||
case HFP_ENABLE_INDICATORS_STATUS_UPDATE:
|
||||
hfp_hf_cmd_activate_status_update_for_all_ag_indicators(context->rfcomm_cid, 1);
|
||||
@ -295,25 +293,19 @@ static int hfp_hf_run_for_context_service_level_connection(hfp_connection_t * co
|
||||
hfp_hf_cmd_list_supported_generic_status_indicators(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_LIST_GENERIC_STATUS_INDICATORS;
|
||||
context->list_generic_status_indicators = 1;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
context->command = HFP_CMD_LIST_GENERIC_STATUS_INDICATORS;
|
||||
break;
|
||||
case HFP_RETRIEVE_GENERIC_STATUS_INDICATORS:
|
||||
hfp_hf_cmd_retrieve_supported_generic_status_indicators(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS;
|
||||
context->list_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators = 1;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
context->command = HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS;
|
||||
break;
|
||||
case HFP_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS:
|
||||
hfp_hf_cmd_list_initital_supported_generic_status_indicators(context->rfcomm_cid);
|
||||
done = 1;
|
||||
context->state = HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS;
|
||||
context->list_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators_state = 1;
|
||||
context->command = HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -338,12 +330,10 @@ static void hfp_hf_handle_ok_service_level_connection_establishment(hfp_connecti
|
||||
|
||||
case HFP_W4_RETRIEVE_INDICATORS:
|
||||
context->state = HFP_RETRIEVE_INDICATORS_STATUS;
|
||||
context->retrieve_ag_indicators = 0;
|
||||
break;
|
||||
|
||||
case HFP_W4_RETRIEVE_INDICATORS_STATUS:
|
||||
context->state = HFP_ENABLE_INDICATORS_STATUS_UPDATE;
|
||||
context->retrieve_ag_indicators_status = 0;
|
||||
break;
|
||||
|
||||
case HFP_W4_ENABLE_INDICATORS_STATUS_UPDATE:
|
||||
@ -370,17 +360,14 @@ static void hfp_hf_handle_ok_service_level_connection_establishment(hfp_connecti
|
||||
|
||||
case HFP_W4_LIST_GENERIC_STATUS_INDICATORS:
|
||||
context->state = HFP_RETRIEVE_GENERIC_STATUS_INDICATORS;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
break;
|
||||
|
||||
case HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS:
|
||||
context->state = HFP_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
break;
|
||||
|
||||
case HFP_W4_RETRIEVE_INITITAL_STATE_GENERIC_STATUS_INDICATORS:
|
||||
context->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED, 0);
|
||||
break;
|
||||
default:
|
||||
@ -408,13 +395,13 @@ static int hfp_hf_run_for_context_service_level_connection_queries(hfp_connectio
|
||||
return done;
|
||||
}
|
||||
|
||||
if (context->operator_name_format){
|
||||
if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT){
|
||||
hfp_hf_cmd_query_operator_name_format(context->rfcomm_cid);
|
||||
context->wait_ok = 1;
|
||||
done = 1;
|
||||
return done;
|
||||
}
|
||||
if (context->operator_name){
|
||||
if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME){
|
||||
hfp_hf_cmd_query_operator_name(context->rfcomm_cid);
|
||||
context->wait_ok = 1;
|
||||
done = 1;
|
||||
@ -446,14 +433,12 @@ static void hfp_hf_handle_ok_service_level_connection_queries(hfp_connection_t *
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->operator_name_format){
|
||||
context->operator_name_format = 0;
|
||||
context->operator_name = 1;
|
||||
if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT){
|
||||
context->command = HFP_CMD_QUERY_OPERATOR_SELECTION_NAME;
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->operator_name){
|
||||
context->operator_name = 0;
|
||||
if (context->command == HFP_CMD_QUERY_OPERATOR_SELECTION_NAME){
|
||||
hfp_emit_network_operator_event(hfp_callback, 0, context->network_operator);
|
||||
return;
|
||||
}
|
||||
@ -708,7 +693,7 @@ void hfp_hf_query_operator_selection(bd_addr_t bd_addr){
|
||||
log_error("HFP HF: connection doesn't exist.");
|
||||
return;
|
||||
}
|
||||
connection->operator_name_format = 1;
|
||||
connection->command = HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT;
|
||||
hfp_run_for_context(connection);
|
||||
}
|
||||
|
||||
|
@ -119,11 +119,7 @@ TEST(HFPParser, HFP_AG_GENERIC_STATUS_INDICATOR){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(context.command, HFP_CMD_GENERIC_STATUS_INDICATOR);
|
||||
CHECK_EQUAL(context.list_generic_status_indicators, 1);
|
||||
CHECK_EQUAL(context.retrieve_generic_status_indicators, 0);
|
||||
CHECK_EQUAL(context.retrieve_generic_status_indicators_state, 0);
|
||||
|
||||
CHECK_EQUAL(context.command, HFP_CMD_LIST_GENERIC_STATUS_INDICATORS);
|
||||
CHECK_EQUAL(5, context.generic_status_indicators_nr);
|
||||
|
||||
for (pos = 0; pos < context.generic_status_indicators_nr; pos++){
|
||||
@ -193,21 +189,15 @@ TEST(HFPParser, HFP_AG_HF_QUERY_OPERATOR_SELECTION){
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
}
|
||||
CHECK_EQUAL(context.operator_name_format, 1);
|
||||
CHECK_EQUAL(context.operator_name, 0);
|
||||
CHECK_EQUAL(context.operator_name_changed, 0);
|
||||
|
||||
CHECK_EQUAL(HFP_CMD_QUERY_OPERATOR_SELECTION, context.command);
|
||||
CHECK_EQUAL(context.network_operator.format, 0);
|
||||
CHECK_EQUAL(context.network_operator.mode, 0);
|
||||
CHECK_EQUAL(HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT, context.command);
|
||||
|
||||
sprintf(packet, "\r\nAT%s?\r\n", HFP_QUERY_OPERATOR_SELECTION);
|
||||
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
}
|
||||
CHECK_EQUAL(context.operator_name_format, 0);
|
||||
CHECK_EQUAL(context.operator_name, 0);
|
||||
CHECK_EQUAL(context.operator_name_changed, 0);
|
||||
}
|
||||
|
||||
|
@ -107,8 +107,7 @@ TEST(HFPParser, HFP_HF_INDICATORS){
|
||||
}
|
||||
offset += snprintf(packet+offset, sizeof(packet)-offset, "\"%s\", (%d, %d)\r\n\r\nOK\r\n", hfp_ag_indicators[pos].name, hfp_ag_indicators[pos].min_range, hfp_ag_indicators[pos].max_range);
|
||||
|
||||
context.retrieve_ag_indicators = 1;
|
||||
context.retrieve_ag_indicators_status = 0;
|
||||
context.command = HFP_CMD_RETRIEVE_AG_INDICATORS;
|
||||
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
@ -132,10 +131,8 @@ TEST(HFPParser, HFP_HF_INDICATOR_STATUS){
|
||||
}
|
||||
offset += snprintf(packet+offset, sizeof(packet)-offset, "%d\r\n\r\nOK\r\n", hfp_ag_indicators[pos].status);
|
||||
|
||||
context.command = HFP_CMD_INDICATOR;
|
||||
context.retrieve_ag_indicators_status = 1;
|
||||
context.retrieve_ag_indicators = 0;
|
||||
|
||||
context.command = HFP_CMD_RETRIEVE_AG_INDICATORS_STATUS;
|
||||
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
}
|
||||
@ -164,9 +161,7 @@ TEST(HFPParser, HFP_HF_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES){
|
||||
|
||||
TEST(HFPParser, HFP_HF_GENERIC_STATUS_INDICATOR){
|
||||
sprintf(packet, "\r\n%s:0,1,2,3,4\r\n\r\nOK\r\n", HFP_GENERIC_STATUS_INDICATOR);
|
||||
context.list_generic_status_indicators = 0;
|
||||
context.retrieve_generic_status_indicators = 1;
|
||||
context.retrieve_generic_status_indicators_state = 0;
|
||||
context.command = HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS;
|
||||
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
@ -182,9 +177,7 @@ TEST(HFPParser, HFP_HF_GENERIC_STATUS_INDICATOR){
|
||||
|
||||
TEST(HFPParser, HFP_HF_GENERIC_STATUS_INDICATOR_STATE){
|
||||
sprintf(packet, "\r\n%s:0,1\r\n\r\nOK\r\n", HFP_GENERIC_STATUS_INDICATOR);
|
||||
context.list_generic_status_indicators = 0;
|
||||
context.retrieve_generic_status_indicators = 0;
|
||||
context.retrieve_generic_status_indicators_state = 1;
|
||||
context.command = HFP_CMD_RETRIEVE_GENERIC_STATUS_INDICATORS_STATE;
|
||||
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
@ -213,13 +206,13 @@ TEST(HFPParser, HFP_HF_AG_INDICATOR_STATUS_UPDATE){
|
||||
TEST(HFPParser, HFP_HF_AG_QUERY_OPERATOR_SELECTION){
|
||||
sprintf(packet, "\r\n%s:1,0,\"sunrise\"\r\n\r\nOK\r\n", HFP_QUERY_OPERATOR_SELECTION);
|
||||
|
||||
context.command = HFP_CMD_QUERY_OPERATOR_SELECTION_NAME;
|
||||
|
||||
for (pos = 0; pos < strlen(packet); pos++){
|
||||
hfp_parse(&context, packet[pos]);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(context.command, HFP_CMD_OK);
|
||||
CHECK_EQUAL(context.operator_name_format, 0);
|
||||
CHECK_EQUAL(context.operator_name, 1);
|
||||
CHECK_EQUAL(context.operator_name_changed, 0);
|
||||
CHECK_EQUAL( strcmp("sunrise", context.network_operator.name), 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user