mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-26 02:37:41 +00:00
hfp: fix outgoing connections
This commit is contained in:
parent
674515e8a0
commit
d68dcce183
@ -97,6 +97,7 @@ static const char * hfp_ag_features[] = {
|
||||
static btstack_linked_list_t hfp_connections = NULL;
|
||||
static void parse_sequence(hfp_connection_t * context);
|
||||
static hfp_callback_t hfp_callback;
|
||||
static btstack_packet_handler_t rfcomm_packet_handler;
|
||||
|
||||
void hfp_set_callback(hfp_callback_t callback){
|
||||
hfp_callback = callback;
|
||||
@ -427,7 +428,7 @@ static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uin
|
||||
if (hfp_connection->rfcomm_channel_nr > 0){
|
||||
hfp_connection->state = HFP_W4_RFCOMM_CONNECTED;
|
||||
log_info("HFP: SDP_EVENT_QUERY_COMPLETE context %p, addr %s, state %d", hfp_connection, bd_addr_to_str( hfp_connection->remote_addr), hfp_connection->state);
|
||||
rfcomm_create_channel(&hfp_handle_hci_event, hfp_connection->remote_addr, hfp_connection->rfcomm_channel_nr, NULL);
|
||||
rfcomm_create_channel(rfcomm_packet_handler, hfp_connection->remote_addr, hfp_connection->rfcomm_channel_nr, NULL);
|
||||
break;
|
||||
}
|
||||
log_info("rfcomm service not found, status %u.", sdp_event_query_complete_get_status(packet));
|
||||
@ -1336,3 +1337,8 @@ void hfp_setup_synchronous_connection(hci_con_handle_t handle, hfp_link_settting
|
||||
hci_send_cmd(&hci_setup_synchronous_connection, handle, 8000, 8000, hfp_link_settings[setting].max_latency,
|
||||
hci_get_sco_voice_setting(), hfp_link_settings[setting].retransmission_effort, hfp_link_settings[setting].packet_types); // all types 0x003f, only 2-ev3 0x380
|
||||
}
|
||||
|
||||
void hfp_set_packet_handler_for_rfcomm_connections(btstack_packet_handler_t handler){
|
||||
rfcomm_packet_handler = handler;
|
||||
}
|
||||
|
||||
|
@ -623,6 +623,8 @@ int store_bit(uint32_t bitmap, int position, uint8_t value);
|
||||
|
||||
void hfp_set_callback(hfp_callback_t callback);
|
||||
|
||||
void hfp_set_packet_handler_for_rfcomm_connections(btstack_packet_handler_t handler);
|
||||
|
||||
void hfp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint16_t service_uuid, int rfcomm_channel_nr, const char * name);
|
||||
void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
void hfp_emit_event(hfp_callback_t callback, uint8_t event_subtype, uint8_t value);
|
||||
|
@ -1763,6 +1763,7 @@ static void hfp_run_for_context(hfp_connection_t *hfp_connection){
|
||||
hfp_connection->command = HFP_CMD_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static hfp_generic_status_indicator_t *get_hf_indicator_by_number(int number){
|
||||
int i;
|
||||
for (i=0;i< hfp_generic_status_indicators_nr;i++){
|
||||
@ -2037,12 +2038,14 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr){
|
||||
|
||||
l2cap_init();
|
||||
|
||||
rfcomm_register_service(packet_handler, rfcomm_channel_nr, 0xffff);
|
||||
rfcomm_register_service(&packet_handler, rfcomm_channel_nr, 0xffff);
|
||||
|
||||
hfp_ag_response_and_hold_active = 0;
|
||||
subscriber_numbers = NULL;
|
||||
subscriber_numbers_count = 0;
|
||||
|
||||
hfp_set_packet_handler_for_rfcomm_connections(&packet_handler);
|
||||
|
||||
hfp_gsm_init();
|
||||
}
|
||||
|
||||
|
@ -1086,6 +1086,8 @@ void hfp_hf_init(uint16_t rfcomm_channel_nr){
|
||||
|
||||
rfcomm_register_service(packet_handler, rfcomm_channel_nr, 0xffff);
|
||||
|
||||
hfp_set_packet_handler_for_rfcomm_connections(&packet_handler);
|
||||
|
||||
hfp_supported_features = HFP_DEFAULT_HF_SUPPORTED_FEATURES;
|
||||
hfp_codecs_nr = 0;
|
||||
hfp_indicators_nr = 0;
|
||||
|
@ -132,6 +132,10 @@ extern "C" void hci_add_event_handler(btstack_packet_callback_registration_t * c
|
||||
}
|
||||
|
||||
int rfcomm_send(uint16_t rfcomm_cid, uint8_t *data, uint16_t len){
|
||||
|
||||
// printf("mock: rfcomm send: ");
|
||||
print_without_newlines(data, len);
|
||||
|
||||
int start_command_offset = 2;
|
||||
int end_command_offset = 2;
|
||||
|
||||
@ -150,17 +154,21 @@ int rfcomm_send(uint16_t rfcomm_cid, uint8_t *data, uint16_t len){
|
||||
rfcomm_payload_len = len;
|
||||
}
|
||||
|
||||
//print_without_newlines(rfcomm_payload,rfcomm_payload_len);
|
||||
// print_without_newlines(rfcomm_payload,rfcomm_payload_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rfcomm_request_can_send_now_event(uint16_t rfcomm_cid){
|
||||
|
||||
// printf("mock: rfcomm_request_can_send_now_event\n");
|
||||
|
||||
uint8_t event[] = { RFCOMM_EVENT_CAN_SEND_NOW, 2, 0, 0};
|
||||
little_endian_store_16(event, 2, rfcomm_cid);
|
||||
registered_rfcomm_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
int rfcomm_reserve_packet_buffer(void){
|
||||
// printf("mock: rfcomm_reserve_packet_buffer\n");
|
||||
return 1;
|
||||
};
|
||||
void rfcomm_release_packet_buffer(void){};
|
||||
@ -171,7 +179,7 @@ uint16_t rfcomm_get_max_frame_size(uint16_t rfcomm_cid){
|
||||
return sizeof(rfcomm_reserved_buffer);
|
||||
}
|
||||
int rfcomm_send_prepared(uint16_t rfcomm_cid, uint16_t len){
|
||||
printf("--- rfcomm_send_prepared with len %u ---\n", len);
|
||||
// printf("--- rfcomm_send_prepared with len %u ---\n", len);
|
||||
return rfcomm_send(rfcomm_cid, rfcomm_reserved_buffer, len);
|
||||
}
|
||||
|
||||
@ -233,6 +241,11 @@ uint8_t sdp_client_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler
|
||||
|
||||
|
||||
uint8_t rfcomm_create_channel(btstack_packet_handler_t handler, bd_addr_t addr, uint8_t channel, uint16_t * out_cid){
|
||||
|
||||
// printf("mock: rfcomm_create_channel addr %s\n", bd_addr_to_str(addr));
|
||||
|
||||
registered_rfcomm_packet_handler = handler;
|
||||
|
||||
// RFCOMM_EVENT_CHANNEL_OPENED
|
||||
uint8_t event[16];
|
||||
uint8_t pos = 0;
|
||||
@ -258,6 +271,7 @@ uint8_t rfcomm_create_channel(btstack_packet_handler_t handler, bd_addr_t addr,
|
||||
}
|
||||
|
||||
int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){
|
||||
// printf("mock: rfcomm_can_send_packet_now\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -270,19 +284,19 @@ void rfcomm_disconnect(uint16_t rfcomm_cid){
|
||||
}
|
||||
|
||||
uint8_t rfcomm_register_service(btstack_packet_handler_t handler, uint8_t channel, uint16_t max_frame_size){
|
||||
printf("rfcomm_register_service\n");
|
||||
// printf("rfcomm_register_service\n");
|
||||
registered_rfcomm_packet_handler = handler;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void sdp_client_query_rfcomm_channel_and_name_for_search_pattern(bd_addr_t remote, uint8_t * des_serviceSearchPattern){
|
||||
printf("sdp_client_query_rfcomm_channel_and_name_for_search_pattern\n");
|
||||
// printf("sdp_client_query_rfcomm_channel_and_name_for_search_pattern\n");
|
||||
}
|
||||
|
||||
|
||||
void rfcomm_accept_connection(uint16_t rfcomm_cid){
|
||||
printf("rfcomm_accept_connection \n");
|
||||
// printf("rfcomm_accept_connection \n");
|
||||
}
|
||||
|
||||
void btstack_run_loop_add_timer(btstack_timer_source_t *timer){
|
||||
@ -354,6 +368,10 @@ void inject_hfp_command_to_ag(uint8_t * data, int len){
|
||||
if (data[0] == '+') return;
|
||||
|
||||
add_new_lines_to_hfp_command(data, len);
|
||||
|
||||
// printf("mock: inject command to ag: ");
|
||||
// print_without_newlines(data, len);
|
||||
|
||||
(*registered_rfcomm_packet_handler)(RFCOMM_DATA_PACKET, rfcomm_cid, (uint8_t *) &outgoing_rfcomm_payload[0], outgoing_rfcomm_payload_len);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user