This commit is contained in:
Milanka Ringwald 2015-11-18 17:27:50 +01:00
commit 03a10a49af
5 changed files with 35 additions and 15 deletions

View File

@ -312,6 +312,10 @@ static hfp_connection_t * provide_hfp_connection_context_for_bd_addr(bd_addr_t b
return context; return context;
} }
/* @param network.
* 0 == no ability to reject a call.
* 1 == ability to reject a call.
*/
/* @param suported_features /* @param suported_features
* HF bit 0: EC and/or NR function (yes/no, 1 = yes, 0 = no) * HF bit 0: EC and/or NR function (yes/no, 1 = yes, 0 = no)
@ -330,8 +334,7 @@ static hfp_connection_t * provide_hfp_connection_context_for_bd_addr(bd_addr_t b
* AG bit 5: Wide band speech (yes/no, 1 = yes, 0 = no) * AG bit 5: Wide band speech (yes/no, 1 = yes, 0 = no)
*/ */
void hfp_create_sdp_record(uint8_t * service, uint16_t service_uuid, int rfcomm_channel_nr, const char * name){
void hfp_create_sdp_record(uint8_t * service, uint16_t service_uuid, int rfcomm_channel_nr, const char * name, uint16_t supported_features){
uint8_t* attribute; uint8_t* attribute;
de_create_sequence(service); de_create_sequence(service);
@ -393,8 +396,6 @@ void hfp_create_sdp_record(uint8_t * service, uint16_t service_uuid, int rfcomm_
// 0x0100 "Service Name" // 0x0100 "Service Name"
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100); de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100);
de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name); de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name);
de_add_number(service, DE_UINT, DE_SIZE_16, supported_features);
} }
static hfp_connection_t * connection_doing_sdp_query = NULL; static hfp_connection_t * connection_doing_sdp_query = NULL;
@ -456,7 +457,7 @@ void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t
case RFCOMM_EVENT_INCOMING_CONNECTION: case RFCOMM_EVENT_INCOMING_CONNECTION:
// data: event (8), len(8), address(48), channel (8), rfcomm_cid (16) // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16)
bt_flip_addr(event_addr, &packet[2]); bt_flip_addr(event_addr, &packet[2]);
context = get_hfp_connection_context_for_bd_addr(event_addr); context = provide_hfp_connection_context_for_bd_addr(event_addr);
if (!context || context->state != HFP_IDLE) return; if (!context || context->state != HFP_IDLE) return;
@ -496,6 +497,8 @@ void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t
default: default:
break; break;
} }
// forward event to app, to learn about con_handle
(*callback)(packet, size);
} }
break; break;

View File

@ -409,7 +409,7 @@ int get_bit(uint16_t bitmap, int position);
int store_bit(uint32_t bitmap, int position, uint8_t value); int store_bit(uint32_t bitmap, int position, uint8_t value);
// UTILS_END // UTILS_END
void hfp_create_sdp_record(uint8_t * service, uint16_t service_uuid, int rfcomm_channel_nr, const char * name, uint16_t supported_features); void hfp_create_sdp_record(uint8_t * service, uint16_t service_uuid, int rfcomm_channel_nr, const char * name);
void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t *packet, uint16_t size); void hfp_handle_hci_event(hfp_callback_t callback, uint8_t packet_type, uint8_t *packet, uint16_t size);
void hfp_emit_event(hfp_callback_t callback, uint8_t event_subtype, uint8_t value); void hfp_emit_event(hfp_callback_t callback, uint8_t event_subtype, uint8_t value);

View File

@ -150,14 +150,17 @@ void hfp_ag_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const ch
if (!name){ if (!name){
name = default_hfp_ag_service_name; name = default_hfp_ag_service_name;
} }
hfp_create_sdp_record(service, SDP_HandsfreeAudioGateway, rfcomm_channel_nr, name, supported_features); hfp_create_sdp_record(service, SDP_HandsfreeAudioGateway, rfcomm_channel_nr, name);
// Network
de_add_number(service, DE_UINT, DE_SIZE_8, ability_to_reject_call);
/* /*
* 0x01 Ability to reject a call * 0x01 Ability to reject a call
* 0x00 No ability to reject a call * 0x00 No ability to reject a call
*/ */
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0301); // Hands-Free Profile - Network
de_add_number(service, DE_UINT, DE_SIZE_8, ability_to_reject_call);
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0311); // Hands-Free Profile - SupportedFeatures
de_add_number(service, DE_UINT, DE_SIZE_16, supported_features);
} }
static int hfp_ag_exchange_supported_features_cmd(uint16_t cid){ static int hfp_ag_exchange_supported_features_cmd(uint16_t cid){

View File

@ -114,9 +114,11 @@ void hfp_hf_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const ch
if (!name){ if (!name){
name = default_hfp_hf_service_name; name = default_hfp_hf_service_name;
} }
hfp_create_sdp_record(service, SDP_Handsfree, rfcomm_channel_nr, name, supported_features); hfp_create_sdp_record(service, SDP_Handsfree, rfcomm_channel_nr, name);
}
de_add_number(service, DE_UINT, DE_SIZE_16, 0x0311); // Hands-Free Profile - SupportedFeatures
de_add_number(service, DE_UINT, DE_SIZE_16, supported_features);
}
static int hfp_hf_cmd_exchange_supported_features(uint16_t cid){ static int hfp_hf_cmd_exchange_supported_features(uint16_t cid){
char buffer[20]; char buffer[20];

View File

@ -75,6 +75,7 @@ static bd_addr_t device_addr;
static bd_addr_t pts_addr = {0x00,0x1b,0xDC,0x07,0x32,0xEF}; static bd_addr_t pts_addr = {0x00,0x1b,0xDC,0x07,0x32,0xEF};
static bd_addr_t speaker_addr = {0x00, 0x21, 0x3C, 0xAC, 0xF7, 0x38}; static bd_addr_t speaker_addr = {0x00, 0x21, 0x3C, 0xAC, 0xF7, 0x38};
static uint8_t codecs[1] = {HFP_CODEC_CVSD}; static uint8_t codecs[1] = {HFP_CODEC_CVSD};
static uint16_t handle = -1;
static int ag_indicators_nr = 7; static int ag_indicators_nr = 7;
static hfp_ag_indicator_t ag_indicators[] = { static hfp_ag_indicator_t ag_indicators[] = {
@ -108,16 +109,18 @@ static void show_usage(void){
printf("---\n"); printf("---\n");
printf("a - establish HFP connection to PTS module\n"); printf("a - establish HFP connection to PTS module\n");
printf("A - release HFP connection to PTS module\n"); // printf("A - release HFP connection to PTS module\n");
printf("z - establish HFP connection to speaker\n"); printf("z - establish HFP connection to speaker\n");
printf("Z - release HFP connection to speaker\n"); // printf("Z - release HFP connection to speaker\n");
printf("b - establish AUDIO connection\n"); printf("b - establish AUDIO connection\n");
printf("B - release AUDIO connection\n"); printf("B - release AUDIO connection\n");
printf("d - report AG failure\n"); printf("d - report AG failure\n");
printf("t - terminate connection\n");
printf("---\n"); printf("---\n");
printf("Ctrl-c - exit\n"); printf("Ctrl-c - exit\n");
printf("---\n"); printf("---\n");
@ -155,7 +158,9 @@ static int stdin_process(struct data_source *ds){
case 'd': case 'd':
printf("Report AG failure\n"); printf("Report AG failure\n");
hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE); hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE);
break;
case 't':
gap_disconnect(handle);
default: default:
show_usage(); show_usage();
break; break;
@ -166,6 +171,13 @@ static int stdin_process(struct data_source *ds){
static void packet_handler(uint8_t * event, uint16_t event_size){ static void packet_handler(uint8_t * event, uint16_t event_size){
if (event[0] == RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE){
handle = READ_BT_16(event, 9);
printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE received for handle 0x%04x\n", handle);
return;
}
if (event[0] != HCI_EVENT_HFP_META) return; if (event[0] != HCI_EVENT_HFP_META) return;
if (event[3]){ if (event[3]){
printf("ERROR, status: %u\n", event[3]); printf("ERROR, status: %u\n", event[3]);
@ -197,7 +209,7 @@ int btstack_main(int argc, const char * argv[]){
l2cap_init(); l2cap_init();
rfcomm_init(); rfcomm_init();
hfp_ag_init(rfcomm_channel_nr, 1007, codecs, sizeof(codecs), hfp_ag_init(rfcomm_channel_nr, 1007 | (1<<HFP_AGSF_HF_INDICATORS), codecs, sizeof(codecs),
ag_indicators, ag_indicators_nr, ag_indicators, ag_indicators_nr,
hf_indicators, hf_indicators_nr, hf_indicators, hf_indicators_nr,
call_hold_services, call_hold_services_nr); call_hold_services, call_hold_services_nr);