mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
hfp: update_cmd moved to hfp.c as process_cmd
This commit is contained in:
parent
e11a0e7d0f
commit
2bb9ee548e
102
src/hfp.c
102
src/hfp.c
@ -491,7 +491,105 @@ void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
void update_command(hfp_connection_t * context);
|
||||
// translates command string into hfp_command_t CMD and flags to distinguish between CMD=, CMD?, CMD=?
|
||||
void process_command(hfp_connection_t * context){
|
||||
context->command = HFP_CMD_NONE;
|
||||
int offset = 0;
|
||||
int isHandsFree = 1;
|
||||
|
||||
if (strncmp((char *)context->line_buffer, "AT", 2) == 0){
|
||||
offset = 2;
|
||||
isHandsFree = 0;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_ERROR, strlen(HFP_ERROR)) == 0){
|
||||
context->command = HFP_CMD_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_OK, strlen(HFP_OK)) == 0){
|
||||
context->command = HFP_CMD_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_SUPPORTED_FEATURES, strlen(HFP_SUPPORTED_FEATURES)) == 0){
|
||||
context->command = HFP_CMD_SUPPORTED_FEATURES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_INDICATOR, strlen(HFP_INDICATOR)) == 0){
|
||||
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;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_AVAILABLE_CODECS, strlen(HFP_AVAILABLE_CODECS)) == 0){
|
||||
context->command = HFP_CMD_AVAILABLE_CODECS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS, strlen(HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS)) == 0){
|
||||
context->command = HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES, strlen(HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES)) == 0){
|
||||
context->command = HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
} 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;
|
||||
} else {
|
||||
context->list_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators_state = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS, strlen(HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS)) == 0){
|
||||
context->command = HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+offset, HFP_TRANSFER_AG_INDICATOR_STATUS, strlen(HFP_TRANSFER_AG_INDICATOR_STATUS)) == 0){
|
||||
context->command = HFP_CMD_TRANSFER_AG_INDICATOR_STATUS;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t fromBinary(char *s) {
|
||||
return (uint32_t) strtol(s, NULL, 2);
|
||||
@ -600,7 +698,7 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
}
|
||||
|
||||
if (hfp_parser_is_end_of_header(byte) || context->keep_separator == 1){
|
||||
update_command(context);
|
||||
process_command(context);
|
||||
}
|
||||
break;
|
||||
|
||||
|
72
src/hfp_ag.c
72
src/hfp_ag.c
@ -326,78 +326,6 @@ int hfp_ag_report_network_operator_name_cmd(uint16_t cid, hfp_network_opearator_
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
void update_command(hfp_connection_t * context){
|
||||
context->command = HFP_CMD_NONE;
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_SUPPORTED_FEATURES, strlen(HFP_SUPPORTED_FEATURES)) == 0){
|
||||
context->command = HFP_CMD_SUPPORTED_FEATURES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_INDICATOR, strlen(HFP_INDICATOR)) == 0){
|
||||
context->command = HFP_CMD_INDICATOR;
|
||||
|
||||
if (strncmp((char *)context->line_buffer+strlen(HFP_INDICATOR)+2, "?", 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;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_AVAILABLE_CODECS, strlen(HFP_AVAILABLE_CODECS)) == 0){
|
||||
context->command = HFP_CMD_AVAILABLE_CODECS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS, strlen(HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS)) == 0){
|
||||
context->command = HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES, strlen(HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES)) == 0){
|
||||
context->command = HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_GENERIC_STATUS_INDICATOR, strlen(HFP_GENERIC_STATUS_INDICATOR)) == 0){
|
||||
context->command = HFP_CMD_GENERIC_STATUS_INDICATOR;
|
||||
if (strncmp((char *)context->line_buffer+strlen(HFP_GENERIC_STATUS_INDICATOR)+2, "=?", 2) == 0){
|
||||
context->list_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators = 1;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
} else if (strncmp((char *)context->line_buffer+strlen(HFP_GENERIC_STATUS_INDICATOR)+2, "=", 1) == 0){
|
||||
context->list_generic_status_indicators = 1;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators_state = 0;
|
||||
} else {
|
||||
context->list_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators = 0;
|
||||
context->retrieve_generic_status_indicators_state = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS, strlen(HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS)) == 0){
|
||||
context->command = HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_QUERY_OPERATOR_SELECTION, strlen(HFP_QUERY_OPERATOR_SELECTION)) == 0){
|
||||
context->command = HFP_CMD_QUERY_OPERATOR_SELECTION;
|
||||
context->operator_name_format = 0;
|
||||
if (strncmp((char *)context->line_buffer+strlen(HFP_QUERY_OPERATOR_SELECTION)+2, "=", 1) == 0){
|
||||
context->operator_name_format = 1;
|
||||
context->operator_name = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void hfp_run_for_context(hfp_connection_t *context){
|
||||
// printf(" hfp_run_for_context \n");
|
||||
if (!context) return;
|
||||
|
56
src/hfp_hf.c
56
src/hfp_hf.c
@ -318,62 +318,6 @@ static void hfp_run_for_context(hfp_connection_t * context){
|
||||
}
|
||||
}
|
||||
|
||||
void update_command(hfp_connection_t * context){
|
||||
context->command = HFP_CMD_NONE;
|
||||
if (strncmp((char *)context->line_buffer, HFP_ERROR, strlen(HFP_ERROR)) == 0){
|
||||
context->command = HFP_CMD_ERROR;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_OK, strlen(HFP_OK)) == 0){
|
||||
context->command = HFP_CMD_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_SUPPORTED_FEATURES, strlen(HFP_SUPPORTED_FEATURES)) == 0){
|
||||
context->command = HFP_CMD_SUPPORTED_FEATURES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_INDICATOR, strlen(HFP_INDICATOR)) == 0){
|
||||
context->command = HFP_CMD_INDICATOR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_AVAILABLE_CODECS, strlen(HFP_AVAILABLE_CODECS)) == 0){
|
||||
context->command = HFP_CMD_AVAILABLE_CODECS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS, strlen(HFP_ENABLE_STATUS_UPDATE_FOR_AG_INDICATORS)) == 0){
|
||||
context->command = HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES, strlen(HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES)) == 0){
|
||||
context->command = HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_GENERIC_STATUS_INDICATOR, strlen(HFP_GENERIC_STATUS_INDICATOR)) == 0){
|
||||
context->command = HFP_CMD_GENERIC_STATUS_INDICATOR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, HFP_TRANSFER_AG_INDICATOR_STATUS, strlen(HFP_TRANSFER_AG_INDICATOR_STATUS)) == 0){
|
||||
context->command = HFP_CMD_TRANSFER_AG_INDICATOR_STATUS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer, 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;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void handle_switch_on_ok(hfp_connection_t *context){
|
||||
// printf("switch on ok\n");
|
||||
switch (context->state){
|
||||
|
Loading…
x
Reference in New Issue
Block a user