hfp: rework parse third item

This commit is contained in:
Matthias Ringwald 2020-06-11 14:44:43 +02:00
parent ba0de05971
commit 74c7548a06

View File

@ -1265,25 +1265,23 @@ static bool hfp_parse_byte(hfp_connection_t * hfp_connection, uint8_t byte, int
hfp_parser_next_state(hfp_connection, byte);
return true;
default:
break;
}
if (!hfp_parser_is_separator(byte)){
hfp_parser_store_byte(hfp_connection, byte);
return true;
}
if (hfp_parser_is_end_of_line(byte)) {
if (hfp_parser_is_buffer_empty(hfp_connection)){
hfp_connection->parser_state = HFP_PARSER_CMD_HEADER;
}
}
if (hfp_parser_is_buffer_empty(hfp_connection)) return true;
switch (hfp_connection->parser_state){
case HFP_PARSER_THIRD_ITEM:
switch (hfp_connection->command){
switch (byte){
case ',':
case '\n':
case '\r':
case ';':
// separator
break;
case '(':
case ')':
// ignore brackets for now
return true;
default:
hfp_parser_store_byte(hfp_connection, byte);
return true;
}
switch (hfp_connection->command){
case HFP_CMD_QUERY_OPERATOR_SELECTION_NAME:
strncpy(hfp_connection->network_operator.name, (char *)hfp_connection->line_buffer, HFP_MAX_NETWORK_OPERATOR_NAME_SIZE);
hfp_connection->network_operator.name[HFP_MAX_NETWORK_OPERATOR_NAME_SIZE - 1] = 0;
@ -1298,14 +1296,13 @@ static bool hfp_parse_byte(hfp_connection_t * hfp_connection, uint8_t byte, int
default:
break;
}
break;
hfp_parser_next_state(hfp_connection, byte);
return true;
default:
break;
btstack_assert(false);
return true;
}
hfp_parser_next_state(hfp_connection, byte);
return true;
}
void hfp_parse(hfp_connection_t * hfp_connection, uint8_t byte, int isHandsFree){