mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
hfp: remove operator flags
This commit is contained in:
parent
b2bcc92ed3
commit
652c5eb0a4
62
src/hfp.c
62
src/hfp.c
@ -268,9 +268,6 @@ void hfp_reset_context_flags(hfp_connection_t * context){
|
||||
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;
|
||||
@ -696,14 +693,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;
|
||||
}
|
||||
@ -805,7 +800,8 @@ 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_RETRIEVE_AG_INDICATORS:
|
||||
@ -951,22 +947,17 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
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;
|
||||
@ -985,16 +976,13 @@ 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:
|
||||
log_info("format %s, ", context->line_buffer);
|
||||
context->network_operator.format = atoi((char *)&context->line_buffer[0]);
|
||||
break;
|
||||
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME_FORMAT:
|
||||
log_info("format %s \n", context->line_buffer);
|
||||
context->network_operator.format = atoi((char *)&context->line_buffer[0]);
|
||||
break;
|
||||
case HFP_CMD_GENERIC_STATUS_INDICATOR:
|
||||
context->generic_status_indicators[context->parser_item_index].state = (uint8_t)atoi((char*)context->line_buffer);
|
||||
@ -1014,11 +1002,9 @@ 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_RETRIEVE_AG_INDICATORS:
|
||||
context->ag_indicators[context->parser_item_index].max_range = atoi((char *)context->line_buffer);
|
||||
|
@ -142,7 +142,9 @@ typedef enum {
|
||||
HFP_CMD_GENERIC_STATUS_INDICATOR,
|
||||
|
||||
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,
|
||||
@ -383,9 +385,6 @@ typedef struct hfp_connection {
|
||||
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;
|
||||
|
30
src/hfp_ag.c
30
src/hfp_ag.c
@ -556,35 +556,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:
|
||||
|
14
src/hfp_hf.c
14
src/hfp_hf.c
@ -402,13 +402,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;
|
||||
@ -440,14 +440,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;
|
||||
}
|
||||
@ -702,7 +700,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);
|
||||
}
|
||||
|
||||
|
@ -193,21 +193,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);
|
||||
}
|
||||
|
||||
|
@ -210,13 +210,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