diff --git a/src/hfp.c b/src/hfp.c index aadef4fea..34164129a 100644 --- a/src/hfp.c +++ b/src/hfp.c @@ -1066,6 +1066,22 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte, int isHandsFree){ static void parse_sequence(hfp_connection_t * context){ int value; switch (context->command){ + case HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION: + // printf("HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION (%u), '%s'\n", context->parser_item_index, (char*)context->line_buffer); + switch(context->parser_item_index){ + case 0: + strncpy(context->bnip_number, (char *)context->line_buffer, sizeof(context->bnip_number)); + context->bnip_number[sizeof(context->bnip_number)-1] = 0; + break; + case 1: + value = atoi((char *)&context->line_buffer[0]); + context->bnip_type = value; + break; + default: + break; + } + context->parser_item_index++; + break; case HFP_CMD_LIST_CURRENT_CALLS: switch(context->parser_item_index){ case 0: diff --git a/src/hfp.h b/src/hfp.h index d59184160..946e63252 100644 --- a/src/hfp.h +++ b/src/hfp.h @@ -571,6 +571,8 @@ typedef struct hfp_connection { uint8_t hf_send_clcc; uint8_t hf_send_rrh; char hf_send_rrh_command; + uint8_t hf_send_cnum; + uint8_t hf_activate_call_waiting_notification; uint8_t hf_deactivate_call_waiting_notification; diff --git a/src/hfp_hf.c b/src/hfp_hf.c index 28d52e877..2b7c7da7e 100644 --- a/src/hfp_hf.c +++ b/src/hfp_hf.c @@ -734,6 +734,14 @@ static void hfp_run_for_context(hfp_connection_t * context){ return; } + if (context->hf_send_cnum){ + context->hf_send_cnum = 0; + char buffer[20]; + sprintf(buffer, "AT%s\r\n", HFP_SUBSCRIBER_NUMBER_INFORMATION); + send_str_over_rfcomm(context->rfcomm_cid, buffer); + return; + } + if (done) return; // deal with disconnect switch (context->state){ @@ -893,6 +901,10 @@ static void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8 } switch (context->command){ + case HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION: + context->command = HFP_CMD_NONE; + printf("Subscriber Number: number %s, type %u\n", context->bnip_number, context->bnip_type); + break; case HFP_CMD_RESPONSE_AND_HOLD_STATUS: context->command = HFP_CMD_NONE; printf("Response and Hold status: %s\n", context->line_buffer); @@ -1459,3 +1471,15 @@ void hfp_hf_rrh_reject_held_call(bd_addr_t addr) connection->hf_send_rrh_command = '2'; hfp_run_for_context(connection); } + +/* + * @brief + */ +void hfp_hf_query_subscriber_number(bd_addr_t addr) +{ + hfp_hf_establish_service_level_connection(addr); + hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(addr); + connection->hf_send_cnum = 1; + hfp_run_for_context(connection); +} + diff --git a/src/hfp_hf.h b/src/hfp_hf.h index 6dcc349c8..907ccdb8b 100644 --- a/src/hfp_hf.h +++ b/src/hfp_hf.h @@ -300,6 +300,11 @@ void hfp_hf_rrh_accept_held_call(bd_addr_t addr); */ void hfp_hf_rrh_reject_held_call(bd_addr_t addr); +/* + * @brief + */ +void hfp_hf_query_subscriber_number(bd_addr_t addr); + /* API_END */ #if defined __cplusplus diff --git a/test/pts/hfp_hf_test.c b/test/pts/hfp_hf_test.c index bf547ace9..91f72cf34 100644 --- a/test/pts/hfp_hf_test.c +++ b/test/pts/hfp_hf_test.c @@ -163,6 +163,8 @@ static void show_usage(void){ printf("{ - Accept held call(RHH 1)\n"); printf("} - Reject held call(RHH 2)\n"); + printf("? - Query Subscriber Number\n"); + printf("---\n"); printf("Ctrl-c - exit\n"); printf("---\n"); @@ -384,6 +386,10 @@ static int stdin_process(struct data_source *ds){ printf("Reject held call (RHH 2)\n"); hfp_hf_rrh_reject_held_call(device_addr); break; + case '?': + printf("Query Subscriber Number\n"); + hfp_hf_query_subscriber_number(device_addr); + break; default: show_usage(); break;