add hack to parse ATD command

This commit is contained in:
Matthias Ringwald 2015-11-20 23:25:54 +01:00
parent 2b949bb1ec
commit cb13fa8131
4 changed files with 23 additions and 12 deletions

View File

@ -210,8 +210,9 @@ void hfp_emit_string_event(hfp_callback_t callback, uint8_t event_subtype, const
event[0] = HCI_EVENT_HFP_META;
event[1] = sizeof(event) - 2;
event[2] = event_subtype;
int size = sizeof(value) < sizeof(event) - 4? sizeof(value) : sizeof(event) - 4;
int size = (strlen(value) < sizeof(event) - 4) ? strlen(value) : sizeof(event) - 4;
strncpy((char*)&event[3], value, size);
event[sizeof(event)-1] = 0;
(*callback)(event, sizeof(event));
}
@ -624,7 +625,7 @@ static hfp_command_t parse_command(const char * line_buffer, int isHandsFree){
return HFP_CMD_CALL_ANSWERED;
}
if (strncmp(line_buffer+offset, HFP_CALL_PHONE_NUMBER, strlen(HFP_CALL_PHONE_NUMBER)) == 0){
if (strncmp(line_buffer, HFP_CALL_PHONE_NUMBER, strlen(HFP_CALL_PHONE_NUMBER)) == 0){
return HFP_CMD_CALL_PHONE_NUMBER;
}
@ -815,6 +816,19 @@ static void hfp_parser_next_state(hfp_connection_t * context, uint8_t byte){
void hfp_parse(hfp_connection_t * context, uint8_t byte, int isHandsFree){
int value;
// handle ATD<dial_string>;
if (strncmp((const char*)context->line_buffer, HFP_CALL_PHONE_NUMBER, strlen(HFP_CALL_PHONE_NUMBER)) == 0){
// check for end-of-line or ';'
if (byte == ';' || hfp_parser_is_end_of_line(byte)){
context->line_buffer[context->line_size] = 0;
context->line_size = 0;
context->command = HFP_CMD_CALL_PHONE_NUMBER;
} else {
context->line_buffer[context->line_size++] = byte;
}
return;
}
// TODO: handle space inside word
if (byte == ' ' && context->parser_state > HFP_PARSER_CMD_HEADER) return;
@ -876,10 +890,6 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte, int isHandsFree){
case HFP_PARSER_CMD_SEQUENCE: // parse comma separated sequence, ignore breacktes
switch (context->command){
case HFP_CMD_CALL_PHONE_NUMBER:
context->place_call_with_number = (char *)context->line_buffer;
log_info("hfp parse HFP_CMD_CALL_PHONE_NUMBER %s", context->place_call_with_number);
break;
case HFP_CMD_CHANGE_IN_BAND_RING_TONE_SETTING:
value = atoi((char *)&context->line_buffer[0]);
context->remote_supported_features = store_bit(context->remote_supported_features, HFP_AGSF_IN_BAND_RING_TONE, value);

View File

@ -414,10 +414,7 @@ typedef struct hfp_connection {
uint8_t change_in_band_ring_tone_setting;
uint8_t ag_ring;
char * place_call_with_number;
timer_source_t hfp_timeout;
} hfp_connection_t;
// UTILS_START : TODO move to utils

View File

@ -1047,8 +1047,9 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_
context->ok_pending = 1;
hfp_ag_call_sm(HFP_AG_TERMINATE_CALL_BY_HF, context);
case HFP_CMD_CALL_PHONE_NUMBER:
context->command = HFP_CMD_NONE;
context->ok_pending = 1;
hfp_emit_string_event(hfp_callback, HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER, context->place_call_with_number);
hfp_emit_string_event(hfp_callback, HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER, (const char *) &context->line_buffer[3]);
break;
default:
break;

View File

@ -256,7 +256,7 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
}
if (event[0] != HCI_EVENT_HFP_META) return;
if (event[3]){
if (event[3] && event[2] != HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER){
printf("ERROR, status: %u\n", event[3]);
return;
}
@ -279,7 +279,10 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
break;
case HFP_SUBEVENT_STOP_RINGINIG:
printf("\n** Stop Ringing **\n\n");
break;
break;
case HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER:
printf("\n** Outgoing call '%s' **\n\n", &event[3]);
break;
default:
// printf("event not handled %u\n", event[2]);
break;