mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 03:35:20 +00:00
remove printf from library code
This commit is contained in:
parent
49dda2734b
commit
8587e32cbd
@ -210,13 +210,13 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
switch (hci_event_packet_get_type(packet)) {
|
||||
case HCI_EVENT_PIN_CODE_REQUEST:
|
||||
// inform about pin code request
|
||||
printf("Pin code request - using '0000'\n");
|
||||
log_info("Pin code request - using '0000'");
|
||||
hci_event_pin_code_request_get_bd_addr(packet, event_addr);
|
||||
hci_send_cmd(&hci_pin_code_request_reply, &event_addr, 4, "0000");
|
||||
break;
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
// connection closed -> quit test app
|
||||
printf("\n --- a2dp source --- HCI_EVENT_DISCONNECTION_COMPLETE ---\n");
|
||||
log_info("\n --- a2dp source --- HCI_EVENT_DISCONNECTION_COMPLETE ---");
|
||||
|
||||
break;
|
||||
case HCI_EVENT_AVDTP_META:
|
||||
@ -225,13 +225,13 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
avdtp_cid = avdtp_subevent_signaling_connection_established_get_avdtp_cid(packet);
|
||||
status = avdtp_subevent_signaling_connection_established_get_status(packet);
|
||||
if (status != 0){
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION could not be established, status %d ---\n", status);
|
||||
log_info(" --- a2dp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION could not be established, status %d ---", status);
|
||||
break;
|
||||
}
|
||||
sc.active_remote_sep = NULL;
|
||||
next_remote_sep_index_to_query = 0;
|
||||
app_state = A2DP_W2_DISCOVER_SEPS;
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED, avdtp cid 0x%02x ---\n", avdtp_cid);
|
||||
log_info(" --- a2dp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED, avdtp cid 0x%02x ---", avdtp_cid);
|
||||
avdtp_source_discover_stream_endpoints(avdtp_cid);
|
||||
break;
|
||||
|
||||
@ -242,12 +242,12 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
acp_seid = avdtp_subevent_streaming_connection_established_get_acp_seid(packet);
|
||||
|
||||
if (status != 0){
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION could not be established, status %d ---\n", status);
|
||||
log_info(" --- a2dp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION could not be established, status %d ---", status);
|
||||
break;
|
||||
}
|
||||
app_state = A2DP_STREAMING_OPENED;
|
||||
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, avdtp_cid, int_seid, acp_seid, 0);
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED --- avdtp_cid 0x%02x, local seid %d, remote seid %d\n", avdtp_cid, int_seid, acp_seid);
|
||||
log_info(" --- a2dp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED --- avdtp_cid 0x%02x, local seid %d, remote seid %d", avdtp_cid, int_seid, acp_seid);
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_SEP_FOUND:
|
||||
@ -256,13 +256,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
sep.in_use = avdtp_subevent_signaling_sep_found_get_in_use(packet);
|
||||
sep.media_type = avdtp_subevent_signaling_sep_found_get_media_type(packet);
|
||||
sep.type = avdtp_subevent_signaling_sep_found_get_sep_type(packet);
|
||||
printf(" --- a2dp source --- Found sep: seid %u, in_use %d, media type %d, sep type %d (1-SNK)\n", sep.seid, sep.in_use, sep.media_type, sep.type);
|
||||
log_info(" --- a2dp source --- Found sep: seid %u, in_use %d, media type %d, sep type %d (1-SNK)", sep.seid, sep.in_use, sep.media_type, sep.type);
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY:{
|
||||
printf(" AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY 0\n");
|
||||
if (!sc.local_stream_endpoint) return;
|
||||
printf(" AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY 1\n");
|
||||
uint8_t sampling_frequency = avdtp_choose_sbc_sampling_frequency(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_sampling_frequency_bitmap(packet));
|
||||
uint8_t channel_mode = avdtp_choose_sbc_channel_mode(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_channel_mode_bitmap(packet));
|
||||
uint8_t block_length = avdtp_choose_sbc_block_length(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_block_length_bitmap(packet));
|
||||
@ -285,21 +283,13 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
break;
|
||||
}
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY:
|
||||
printf(" --- a2dp source --- received non SBC codec. not implemented\n");
|
||||
log_info(" --- a2dp source --- received non SBC codec. not implemented");
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION:{
|
||||
sc.sampling_frequency = avdtp_subevent_signaling_media_codec_sbc_configuration_get_sampling_frequency(packet);
|
||||
sc.block_length = avdtp_subevent_signaling_media_codec_sbc_configuration_get_block_length(packet);
|
||||
sc.subbands = avdtp_subevent_signaling_media_codec_sbc_configuration_get_subbands(packet);
|
||||
// switch (avdtp_subevent_signaling_media_codec_sbc_configuration_get_allocation_method(packet)){
|
||||
// case AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS:
|
||||
// sc.allocation_method = SBC_LOUDNESS;
|
||||
// break;
|
||||
// case AVDTP_SBC_ALLOCATION_METHOD_SNR:
|
||||
// sc.allocation_method = SBC_SNR;
|
||||
// break;
|
||||
// }
|
||||
sc.allocation_method = avdtp_subevent_signaling_media_codec_sbc_configuration_get_allocation_method(packet) - 1;
|
||||
sc.max_bitpool_value = avdtp_subevent_signaling_media_codec_sbc_configuration_get_max_bitpool_value(packet);
|
||||
// TODO: deal with reconfigure: avdtp_subevent_signaling_media_codec_sbc_configuration_get_reconfigure(packet);
|
||||
@ -312,23 +302,23 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
case AVDTP_SUBEVENT_SIGNALING_ACCEPT:
|
||||
signal_identifier = avdtp_subevent_signaling_accept_get_signal_identifier(packet);
|
||||
status = avdtp_subevent_signaling_accept_get_status(packet);
|
||||
printf(" --- a2dp source --- Accepted %d\n", signal_identifier);
|
||||
log_info(" --- a2dp source --- Accepted %d", signal_identifier);
|
||||
|
||||
switch (app_state){
|
||||
case A2DP_W2_DISCOVER_SEPS:
|
||||
app_state = A2DP_W2_GET_ALL_CAPABILITIES;
|
||||
sc.active_remote_sep = avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query++);
|
||||
printf(" --- a2dp source --- Query get caps for seid %d\n", sc.active_remote_sep->seid);
|
||||
log_info(" --- a2dp source --- Query get caps for seid %d", sc.active_remote_sep->seid);
|
||||
avdtp_source_get_capabilities(avdtp_cid, sc.active_remote_sep->seid);
|
||||
break;
|
||||
case A2DP_W2_GET_CAPABILITIES:
|
||||
case A2DP_W2_GET_ALL_CAPABILITIES:
|
||||
if (next_remote_sep_index_to_query < avdtp_source_remote_seps_num(avdtp_cid)){
|
||||
sc.active_remote_sep = avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query++);
|
||||
printf(" --- a2dp source --- Query get caps for seid %d\n", sc.active_remote_sep->seid);
|
||||
log_info(" --- a2dp source --- Query get caps for seid %d", sc.active_remote_sep->seid);
|
||||
avdtp_source_get_capabilities(avdtp_cid, sc.active_remote_sep->seid);
|
||||
} else {
|
||||
printf(" --- a2dp source --- No more remote seps found\n");
|
||||
log_info(" --- a2dp source --- No more remote seps found");
|
||||
app_state = A2DP_IDLE;
|
||||
}
|
||||
break;
|
||||
@ -374,7 +364,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
event[pos++] = A2DP_SUBEVENT_STREAM_RELEASED;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
printf("send A2DP_SUBEVENT_STREAM_RELEASED to app\n");
|
||||
log_info("send A2DP_SUBEVENT_STREAM_RELEASED to app");
|
||||
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
|
||||
(*a2dp_source_context.a2dp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
break;
|
||||
@ -404,16 +394,16 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
case AVDTP_SUBEVENT_SIGNALING_REJECT:
|
||||
app_state = A2DP_IDLE;
|
||||
signal_identifier = avdtp_subevent_signaling_reject_get_signal_identifier(packet);
|
||||
printf(" --- a2dp source --- Rejected %d\n", signal_identifier);
|
||||
log_info(" --- a2dp source --- Rejected %d", signal_identifier);
|
||||
break;
|
||||
case AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT:
|
||||
app_state = A2DP_IDLE;
|
||||
signal_identifier = avdtp_subevent_signaling_general_reject_get_signal_identifier(packet);
|
||||
printf(" --- a2dp source --- Rejected %d\n", signal_identifier);
|
||||
log_info(" --- a2dp source --- Rejected %d", signal_identifier);
|
||||
break;
|
||||
default:
|
||||
app_state = A2DP_IDLE;
|
||||
printf(" --- a2dp source --- not implemented\n");
|
||||
log_info(" --- a2dp source --- not implemented");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -456,10 +446,10 @@ uint8_t a2dp_source_create_stream_endpoint(avdtp_media_type_t media_type, avdtp_
|
||||
void a2dp_source_establish_stream(bd_addr_t bd_addr, uint8_t local_seid){
|
||||
sc.local_stream_endpoint = avdtp_stream_endpoint_for_seid(local_seid, &a2dp_source_context);
|
||||
if (!sc.local_stream_endpoint){
|
||||
printf(" no local_stream_endpoint for seid %d\n", local_seid);
|
||||
log_error(" no local_stream_endpoint for seid %d", local_seid);
|
||||
return;
|
||||
}
|
||||
avdtp_source_connect(bd_addr);
|
||||
|
||||
}
|
||||
|
||||
void a2dp_source_disconnect(uint16_t con_handle){
|
||||
@ -481,7 +471,7 @@ void a2dp_source_pause_stream(uint8_t int_seid){
|
||||
uint8_t a2dp_source_stream_endpoint_ready(uint8_t local_seid){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(local_seid, &a2dp_source_context);
|
||||
if (!stream_endpoint) {
|
||||
printf("no stream_endpoint");
|
||||
log_error("No stream_endpoint with seid %d", local_seid);
|
||||
return 0;
|
||||
}
|
||||
return (stream_endpoint->state == AVDTP_STREAM_ENDPOINT_STREAMING);
|
||||
@ -490,7 +480,7 @@ uint8_t a2dp_source_stream_endpoint_ready(uint8_t local_seid){
|
||||
|
||||
static void a2dp_source_setup_media_header(uint8_t * media_packet, int size, int *offset, uint8_t marker, uint16_t sequence_number){
|
||||
if (size < AVDTP_MEDIA_PAYLOAD_HEADER_SIZE){
|
||||
printf("small outgoing buffer\n");
|
||||
log_error("small outgoing buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -521,7 +511,7 @@ static void a2dp_source_setup_media_header(uint8_t * media_packet, int size, int
|
||||
void a2dp_source_stream_endpoint_request_can_send_now(uint8_t local_seid){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(local_seid, &a2dp_source_context);
|
||||
if (!stream_endpoint) {
|
||||
printf("no stream_endpoint");
|
||||
log_error("no stream_endpoint for seid %d", local_seid);
|
||||
return;
|
||||
}
|
||||
stream_endpoint->send_stream = 1;
|
||||
@ -531,11 +521,11 @@ void a2dp_source_stream_endpoint_request_can_send_now(uint8_t local_seid){
|
||||
int a2dp_max_media_payload_size(uint8_t int_seid){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(int_seid, &a2dp_source_context);
|
||||
if (!stream_endpoint) {
|
||||
printf("no stream_endpoint found for seid %d", int_seid);
|
||||
log_error("no stream_endpoint found for seid %d", int_seid);
|
||||
return 0;
|
||||
}
|
||||
if (stream_endpoint->l2cap_media_cid == 0){
|
||||
printf("no media cid found for seid %d", int_seid);
|
||||
log_error("no media cid found for seid %d", int_seid);
|
||||
return 0;
|
||||
}
|
||||
return l2cap_get_remote_mtu_for_local_cid(stream_endpoint->l2cap_media_cid) - AVDTP_MEDIA_PAYLOAD_HEADER_SIZE;
|
||||
@ -543,7 +533,7 @@ int a2dp_max_media_payload_size(uint8_t int_seid){
|
||||
|
||||
static void a2dp_source_copy_media_payload(uint8_t * media_packet, int size, int * offset, uint8_t * storage, int num_bytes_to_copy, uint8_t num_frames){
|
||||
if (size < num_bytes_to_copy + 1){
|
||||
printf("small outgoing buffer\n");
|
||||
log_error("small outgoing buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -557,12 +547,12 @@ static void a2dp_source_copy_media_payload(uint8_t * media_packet, int size, int
|
||||
int a2dp_source_stream_send_media_payload(uint8_t int_seid, uint8_t * storage, int num_bytes_to_copy, uint8_t num_frames, uint8_t marker){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(int_seid, &a2dp_source_context);
|
||||
if (!stream_endpoint) {
|
||||
printf("no stream_endpoint found for seid %d", int_seid);
|
||||
log_error("no stream_endpoint found for seid %d", int_seid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (stream_endpoint->l2cap_media_cid == 0){
|
||||
printf("no media cid found for seid %d", int_seid);
|
||||
log_error("no media cid found for seid %d", int_seid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,6 @@ void avdtp_connect(bd_addr_t remote, avdtp_sep_type_t query_role, avdtp_context_
|
||||
sdp_query_context.avdtp_callback = avdtp_context->avdtp_callback;
|
||||
sdp_query_context.packet_handler = avdtp_context->packet_handler;
|
||||
|
||||
printf("packet handler %p, avdtp_callback %p\n", sdp_query_context.packet_handler, sdp_query_context.avdtp_callback);
|
||||
sdp_client_query_uuid16(&avdtp_handle_sdp_client_query_result, remote, BLUETOOTH_PROTOCOL_AVDTP);
|
||||
}
|
||||
|
||||
@ -90,7 +89,6 @@ void avdtp_register_media_transport_category(avdtp_stream_endpoint_t * stream_en
|
||||
}
|
||||
uint16_t bitmap = store_bit16(stream_endpoint->sep.registered_service_categories, AVDTP_MEDIA_TRANSPORT, 1);
|
||||
stream_endpoint->sep.registered_service_categories = bitmap;
|
||||
printf("registered services AVDTP_MEDIA_TRANSPORT(%d) %02x\n", AVDTP_MEDIA_TRANSPORT, stream_endpoint->sep.registered_service_categories);
|
||||
}
|
||||
|
||||
void avdtp_register_reporting_category(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
@ -154,7 +152,6 @@ void avdtp_register_media_codec_category(avdtp_stream_endpoint_t * stream_endpoi
|
||||
}
|
||||
uint16_t bitmap = store_bit16(stream_endpoint->sep.registered_service_categories, AVDTP_MEDIA_CODEC, 1);
|
||||
stream_endpoint->sep.registered_service_categories = bitmap;
|
||||
printf("registered services AVDTP_MEDIA_CODEC(%d) %02x\n", AVDTP_MEDIA_CODEC, stream_endpoint->sep.registered_service_categories);
|
||||
stream_endpoint->sep.capabilities.media_codec.media_type = media_type;
|
||||
stream_endpoint->sep.capabilities.media_codec.media_codec_type = media_codec_type;
|
||||
stream_endpoint->sep.capabilities.media_codec.media_codec_information = media_codec_info;
|
||||
@ -235,7 +232,6 @@ avdtp_stream_endpoint_t * avdtp_create_stream_endpoint(avdtp_sep_type_t sep_type
|
||||
|
||||
static void handle_l2cap_data_packet_for_signaling_connection(avdtp_connection_t * connection, uint8_t *packet, uint16_t size, avdtp_context_t * context){
|
||||
int offset = avdtp_read_signaling_header(&connection->signaling_packet, packet, size);
|
||||
// printf("handle_l2cap_data_packet_for_signaling_connection \n");
|
||||
switch (connection->signaling_packet.message_type){
|
||||
case AVDTP_CMD_MSG:
|
||||
avdtp_acceptor_stream_config_subsm(connection, packet, size, offset, context);
|
||||
@ -267,7 +263,7 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp
|
||||
stream_endpoint->connection = connection;
|
||||
stream_endpoint->l2cap_media_cid = l2cap_event_channel_opened_get_local_cid(packet);
|
||||
stream_endpoint->media_con_handle = l2cap_event_channel_opened_get_handle(packet);
|
||||
printf(" -> AVDTP_STREAM_ENDPOINT_OPENED, media con handle 0x%02x, l2cap_media_cid 0x%02x\n", stream_endpoint->media_con_handle, stream_endpoint->l2cap_media_cid);
|
||||
log_info(" -> AVDTP_STREAM_ENDPOINT_OPENED, media con handle 0x%02x, l2cap_media_cid 0x%02x", stream_endpoint->media_con_handle, stream_endpoint->l2cap_media_cid);
|
||||
avdtp_streaming_emit_connection_established(context->avdtp_callback, connection->l2cap_signaling_cid, stream_endpoint->sep.seid, connection->remote_seps[stream_endpoint->remote_sep_index].seid, 0);
|
||||
break;
|
||||
}
|
||||
@ -276,7 +272,7 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp
|
||||
local_cid = l2cap_event_channel_closed_get_local_cid(packet);
|
||||
if (stream_endpoint->l2cap_media_cid == local_cid){
|
||||
stream_endpoint->l2cap_media_cid = 0;
|
||||
printf(" -> L2CAP_EVENT_CHANNEL_CLOSED: AVDTP_STREAM_ENDPOINT_IDLE\n");
|
||||
log_info(" -> L2CAP_EVENT_CHANNEL_CLOSED: AVDTP_STREAM_ENDPOINT_IDLE");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_IDLE;
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE;
|
||||
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
|
||||
@ -322,7 +318,7 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
// Handle new SDP record
|
||||
if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id) {
|
||||
record_id = sdp_event_query_attribute_byte_get_record_id(packet);
|
||||
printf("SDP Record: Nr: %d\n", record_id);
|
||||
// log_info("SDP Record: Nr: %d", record_id);
|
||||
}
|
||||
|
||||
if (sdp_event_query_attribute_byte_get_attribute_length(packet) <= attribute_value_buffer_size) {
|
||||
@ -344,7 +340,7 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
avdtp_signaling_emit_connection_established(sdp_query_context.avdtp_callback, sdp_query_context.connection->l2cap_signaling_cid, sdp_query_context.connection->remote_addr, 0);
|
||||
break;
|
||||
}
|
||||
printf("SDP Attribute 0x%04x: AVDTP SOURCE protocol UUID: 0x%04x\n", sdp_event_query_attribute_byte_get_attribute_id(packet), uuid);
|
||||
// log_info("SDP Attribute 0x%04x: AVDTP SOURCE protocol UUID: 0x%04x", sdp_event_query_attribute_byte_get_attribute_id(packet), uuid);
|
||||
avdtp_remote_uuid = uuid;
|
||||
break;
|
||||
case BLUETOOTH_SERVICE_CLASS_AUDIO_SINK:
|
||||
@ -353,7 +349,7 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
avdtp_signaling_emit_connection_established(sdp_query_context.avdtp_callback, sdp_query_context.connection->l2cap_signaling_cid, sdp_query_context.connection->remote_addr, 0);
|
||||
break;
|
||||
}
|
||||
printf("SDP Attribute 0x%04x: AVDTP SINK protocol UUID: 0x%04x\n", sdp_event_query_attribute_byte_get_attribute_id(packet), uuid);
|
||||
// log_info("SDP Attribute 0x%04x: AVDTP SINK protocol UUID: 0x%04x", sdp_event_query_attribute_byte_get_attribute_id(packet), uuid);
|
||||
avdtp_remote_uuid = uuid;
|
||||
break;
|
||||
default:
|
||||
@ -363,7 +359,7 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
break;
|
||||
|
||||
case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST: {
|
||||
printf("SDP Attribute: 0x%04x\n", sdp_event_query_attribute_byte_get_attribute_id(packet));
|
||||
// log_info("SDP Attribute: 0x%04x", sdp_event_query_attribute_byte_get_attribute_id(packet));
|
||||
|
||||
for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)) {
|
||||
uint8_t *des_element;
|
||||
@ -389,17 +385,18 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
if (!des_iterator_has_more(&prot_it)) continue;
|
||||
des_iterator_next(&prot_it);
|
||||
de_element_get_uint16(des_iterator_get_element(&prot_it), &avdtp_version);
|
||||
sdp_query_context.connection->state = AVDTP_SIGNALING_CONNECTION_W2_L2CAP_CONNECT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("l2cap_psm 0x%04x, avdtp_version 0x%04x\n", avdtp_l2cap_psm, avdtp_version);
|
||||
printf("Create AVDTP connection, handler %p, addr %s\n", sdp_query_context.packet_handler, bd_addr_to_str(sdp_query_context.connection->remote_addr));
|
||||
if (!avdtp_l2cap_psm) {
|
||||
sdp_query_context.connection->state = AVDTP_SIGNALING_CONNECTION_IDLE;
|
||||
avdtp_signaling_emit_connection_established(sdp_query_context.avdtp_callback, sdp_query_context.connection->l2cap_signaling_cid, sdp_query_context.connection->remote_addr, L2CAP_SERVICE_DOES_NOT_EXIST);
|
||||
break;
|
||||
}
|
||||
sdp_query_context.connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED;
|
||||
l2cap_create_channel(sdp_query_context.packet_handler, sdp_query_context.connection->remote_addr, avdtp_l2cap_psm, l2cap_max_mtu(), NULL);
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -407,12 +404,12 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "SDP attribute value buffer size exceeded: available %d, required %d\n", attribute_value_buffer_size, sdp_event_query_attribute_byte_get_attribute_length(packet));
|
||||
log_error("SDP attribute value buffer size exceeded: available %d, required %d", attribute_value_buffer_size, sdp_event_query_attribute_byte_get_attribute_length(packet));
|
||||
}
|
||||
break;
|
||||
|
||||
case SDP_EVENT_QUERY_COMPLETE:
|
||||
printf("General query done with status %d.\n", sdp_event_query_complete_get_status(packet));
|
||||
log_info("General query done with status %d.", sdp_event_query_complete_get_status(packet));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -428,7 +425,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
btstack_linked_list_t * avdtp_connections = &context->connections;
|
||||
btstack_linked_list_t * stream_endpoints = &context->stream_endpoints;
|
||||
handle_media_data = context->handle_media_data;
|
||||
// printf("avdtp_packet_handler packet type %02x, event %02x \n", packet_type, hci_event_packet_get_type(packet));
|
||||
// log_info("avdtp_packet_handler packet type %02x, event %02x ", packet_type, hci_event_packet_get_type(packet));
|
||||
switch (packet_type) {
|
||||
case L2CAP_DATA_PACKET:
|
||||
connection = avdtp_connection_for_l2cap_signaling_cid(channel, context);
|
||||
@ -456,10 +453,10 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
|
||||
if (channel == stream_endpoint->l2cap_reporting_cid){
|
||||
// TODO
|
||||
printf("L2CAP_DATA_PACKET for reporting: NOT IMPLEMENTED\n");
|
||||
log_info("L2CAP_DATA_PACKET for reporting: NOT IMPLEMENTED");
|
||||
} else if (channel == stream_endpoint->l2cap_recovery_cid){
|
||||
// TODO
|
||||
printf("L2CAP_DATA_PACKET for recovery: NOT IMPLEMENTED\n");
|
||||
log_info("L2CAP_DATA_PACKET for recovery: NOT IMPLEMENTED");
|
||||
} else {
|
||||
log_error("avdtp packet handler L2CAP_DATA_PACKET: local cid 0x%02x not found", channel);
|
||||
}
|
||||
@ -476,14 +473,14 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
if (!connection || connection->state == AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED){
|
||||
connection = avdtp_create_connection(event_addr, context);
|
||||
connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED;
|
||||
printf("L2CAP_EVENT_INCOMING_CONNECTION, connection %p, state connection %d\n", connection, connection->state);
|
||||
log_info("L2CAP_EVENT_INCOMING_CONNECTION, connection %p, state connection %d", connection, connection->state);
|
||||
l2cap_accept_connection(local_cid);
|
||||
break;
|
||||
}
|
||||
|
||||
stream_endpoint = avdtp_stream_endpoint_for_seid(connection->query_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
printf("L2CAP_EVENT_INCOMING_CONNECTION no streamendpoint found for seid %d\n", connection->query_seid);
|
||||
log_info("L2CAP_EVENT_INCOMING_CONNECTION no streamendpoint found for seid %d", connection->query_seid);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -511,7 +508,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
con_handle = l2cap_event_channel_opened_get_handle(packet);
|
||||
local_cid = l2cap_event_channel_opened_get_local_cid(packet);
|
||||
|
||||
printf("L2CAP_EVENT_CHANNEL_OPENED: Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||
log_info("L2CAP_EVENT_CHANNEL_OPENED: Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x",
|
||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||
|
||||
if (psm != BLUETOOTH_PROTOCOL_AVDTP) break;
|
||||
@ -525,14 +522,14 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
connection->con_handle = con_handle;
|
||||
connection->query_seid = 0;
|
||||
connection->state = AVDTP_SIGNALING_CONNECTION_OPENED;
|
||||
printf(" -> AVDTP_SIGNALING_CONNECTION_OPENED, connection %p\n", connection);
|
||||
log_info(" -> AVDTP_SIGNALING_CONNECTION_OPENED, connection %p", connection);
|
||||
avdtp_signaling_emit_connection_established(context->avdtp_callback, connection->l2cap_signaling_cid, event_addr, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
stream_endpoint = avdtp_stream_endpoint_for_seid(connection->query_seid, context);
|
||||
if (!stream_endpoint){
|
||||
printf("L2CAP_EVENT_CHANNEL_OPENED: stream_endpoint not found");
|
||||
log_info("L2CAP_EVENT_CHANNEL_OPENED: stream_endpoint not found");
|
||||
return;
|
||||
}
|
||||
stream_endpoint_state_machine(connection, stream_endpoint, HCI_EVENT_PACKET, L2CAP_EVENT_CHANNEL_OPENED, packet, size, context);
|
||||
@ -542,10 +539,10 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
// data: event (8), len(8), channel (16)
|
||||
local_cid = l2cap_event_channel_closed_get_local_cid(packet);
|
||||
connection = avdtp_connection_for_l2cap_signaling_cid(local_cid, context);
|
||||
printf(" -> L2CAP_EVENT_CHANNEL_CLOSED signaling cid 0x%0x\n", local_cid);
|
||||
log_info(" -> L2CAP_EVENT_CHANNEL_CLOSED signaling cid 0x%0x", local_cid);
|
||||
|
||||
if (connection){
|
||||
printf(" -> AVDTP_STREAM_ENDPOINT_IDLE, connection closed\n");
|
||||
log_info(" -> AVDTP_STREAM_ENDPOINT_IDLE, connection closed");
|
||||
btstack_linked_list_remove(avdtp_connections, (btstack_linked_item_t*) connection);
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, stream_endpoints);
|
||||
@ -575,7 +572,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
avdtp_handle_can_send_now(connection, channel, context);
|
||||
break;
|
||||
default:
|
||||
printf("unknown HCI event type %02x\n", hci_event_packet_get_type(packet));
|
||||
log_info("unknown HCI event type %02x", hci_event_packet_get_type(packet));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -599,22 +596,22 @@ void avdtp_disconnect(uint16_t avdtp_cid, avdtp_context_t * context){
|
||||
void avdtp_open_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_media_connect: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_media_connect: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return;
|
||||
}
|
||||
if (avdtp_find_remote_sep(connection, acp_seid) == 0xFF){
|
||||
printf("avdtp_media_connect: no remote sep for seid %d found\n", acp_seid);
|
||||
log_error("avdtp_media_connect: no remote sep for seid %d found", acp_seid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) {
|
||||
printf("avdtp_media_connect: wrong connection state %d\n", connection->state);
|
||||
log_error("avdtp_media_connect: wrong connection state %d", connection->state);
|
||||
return;
|
||||
}
|
||||
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_with_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
printf("avdtp_media_connect: no stream_endpoint with seid %d found\n", int_seid);
|
||||
log_error("avdtp_media_connect: no stream_endpoint with seid %d found", int_seid);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -632,12 +629,12 @@ void avdtp_open_stream(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, a
|
||||
void avdtp_start_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_with_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
printf("avdtp_start_stream: no stream_endpoint with seid %d found\n", int_seid);
|
||||
log_error("avdtp_start_stream: no stream_endpoint with seid %d found", int_seid);
|
||||
return;
|
||||
}
|
||||
avdtp_connection_t * connection = stream_endpoint->connection;
|
||||
if (!connection){
|
||||
printf("avdtp_start_stream: no connection for seid %d found\n",stream_endpoint->sep.seid);
|
||||
log_error("avdtp_start_stream: no connection for seid %d found",stream_endpoint->sep.seid);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -650,12 +647,12 @@ void avdtp_start_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
void avdtp_stop_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_with_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
printf("avdtp_stop_stream: no stream_endpoint with seid %d found\n", int_seid);
|
||||
log_error("avdtp_stop_stream: no stream_endpoint with seid %d found", int_seid);
|
||||
return;
|
||||
}
|
||||
avdtp_connection_t * connection = stream_endpoint->connection;
|
||||
if (!connection){
|
||||
printf("avdtp_stop_stream: no connection for seid %d found\n",stream_endpoint->sep.seid);
|
||||
log_error("avdtp_stop_stream: no connection for seid %d found",stream_endpoint->sep.seid);
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->remote_sep_index == 0xFF || stream_endpoint->stop_stream) return;
|
||||
@ -667,12 +664,12 @@ void avdtp_stop_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
void avdtp_abort_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_with_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
printf("avdtp_abort_stream: no stream_endpoint with seid %d found\n", int_seid);
|
||||
log_error("avdtp_abort_stream: no stream_endpoint with seid %d found", int_seid);
|
||||
return;
|
||||
}
|
||||
avdtp_connection_t * connection = stream_endpoint->connection;
|
||||
if (!connection){
|
||||
printf("avdtp_abort_stream: no connection for seid %d found\n",stream_endpoint->sep.seid);
|
||||
log_error("avdtp_abort_stream: no connection for seid %d found",stream_endpoint->sep.seid);
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->remote_sep_index == 0xFF || stream_endpoint->abort_stream) return;
|
||||
@ -683,12 +680,12 @@ void avdtp_abort_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
void avdtp_suspend_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_with_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
printf("avdtp_abort_stream: no stream_endpoint with seid %d found\n", int_seid);
|
||||
log_error("avdtp_abort_stream: no stream_endpoint with seid %d found", int_seid);
|
||||
return;
|
||||
}
|
||||
avdtp_connection_t * connection = stream_endpoint->connection;
|
||||
if (!connection){
|
||||
printf("avdtp_abort_stream: no connection for seid %d found\n",stream_endpoint->sep.seid);
|
||||
log_error("avdtp_abort_stream: no connection for seid %d found",stream_endpoint->sep.seid);
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->remote_sep_index == 0xFF || stream_endpoint->suspend_stream) return;
|
||||
@ -700,7 +697,7 @@ void avdtp_suspend_stream(uint8_t int_seid, avdtp_context_t * context){
|
||||
void avdtp_discover_stream_endpoints(uint16_t avdtp_cid, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_discover_stream_endpoints: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_discover_stream_endpoints: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return;
|
||||
}
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
@ -712,17 +709,16 @@ void avdtp_discover_stream_endpoints(uint16_t avdtp_cid, avdtp_context_t * conte
|
||||
avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid);
|
||||
break;
|
||||
default:
|
||||
printf("avdtp_discover_stream_endpoints: wrong state\n");
|
||||
log_error("avdtp_discover_stream_endpoints: wrong state");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void avdtp_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
printf("avdtp_get_capabilities: acp_seid %d\n", acp_seid);
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_get_capabilities: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_get_capabilities: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return;
|
||||
}
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
@ -735,10 +731,9 @@ void avdtp_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_
|
||||
|
||||
|
||||
void avdtp_get_all_capabilities(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
printf("avdtp_get_all_capabilities: acp_seid %d\n", acp_seid);
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_get_all_capabilities: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_get_all_capabilities: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return;
|
||||
}
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
@ -752,7 +747,7 @@ void avdtp_get_all_capabilities(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_cont
|
||||
void avdtp_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_get_configuration: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_get_configuration: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return;
|
||||
}
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
@ -766,7 +761,7 @@ void avdtp_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context
|
||||
void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
log_error("avdtp_set_configuration: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_set_configuration: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return;
|
||||
}
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
@ -774,10 +769,9 @@ void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_s
|
||||
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
log_error("avdtp_set_configuration: no initiator stream endpoint for seid %d\n", int_seid);
|
||||
log_error("avdtp_set_configuration: no initiator stream endpoint for seid %d", int_seid);
|
||||
return;
|
||||
}
|
||||
// printf("avdtp_set_configuration int seid %d, acp seid %d\n", int_seid, acp_seid);
|
||||
|
||||
connection->initiator_transaction_label++;
|
||||
connection->acp_seid = acp_seid;
|
||||
@ -791,7 +785,7 @@ void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_s
|
||||
void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_reconfigure: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_reconfigure: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return;
|
||||
}
|
||||
//TODO: if opened only app capabilities, enable reconfigure for not opened
|
||||
@ -800,12 +794,12 @@ void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, u
|
||||
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
log_error("avdtp_reconfigure: no initiator stream endpoint for seid %d\n", int_seid);
|
||||
log_error("avdtp_reconfigure: no initiator stream endpoint for seid %d", int_seid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stream_endpoint->remote_sep_index == 0xFF){
|
||||
log_error("avdtp_reconfigure: no associated remote sep\n");
|
||||
log_error("avdtp_reconfigure: no associated remote sep");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -821,7 +815,7 @@ void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, u
|
||||
uint8_t avdtp_remote_seps_num(uint16_t avdtp_cid, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_suspend: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_suspend: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return 0;
|
||||
}
|
||||
return connection->remote_seps_num;
|
||||
@ -830,7 +824,7 @@ uint8_t avdtp_remote_seps_num(uint16_t avdtp_cid, avdtp_context_t * context){
|
||||
avdtp_sep_t * avdtp_remote_sep(uint16_t avdtp_cid, uint8_t index, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_suspend: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
log_error("avdtp_suspend: no connection for signaling cid 0x%02x found", avdtp_cid);
|
||||
return NULL;
|
||||
}
|
||||
return &connection->remote_seps[index];
|
||||
@ -839,7 +833,7 @@ avdtp_sep_t * avdtp_remote_sep(uint16_t avdtp_cid, uint8_t index, avdtp_context_
|
||||
void avdtp_initialize_sbc_configuration_storage(avdtp_stream_endpoint_t * stream_endpoint, uint8_t * config_storage, uint16_t storage_size, uint8_t * packet, uint16_t packet_size){
|
||||
UNUSED(packet_size);
|
||||
if (storage_size < 4) {
|
||||
printf("storage must have 4 bytes\n");
|
||||
log_error("storage must have 4 bytes");
|
||||
return;
|
||||
}
|
||||
uint8_t sampling_frequency = avdtp_choose_sbc_sampling_frequency(stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_sampling_frequency_bitmap(packet));
|
||||
|
@ -338,7 +338,6 @@ typedef struct {
|
||||
typedef enum {
|
||||
AVDTP_SIGNALING_CONNECTION_IDLE,
|
||||
AVDTP_SIGNALING_W4_SDP_QUERY_COMPLETE,
|
||||
AVDTP_SIGNALING_CONNECTION_W2_L2CAP_CONNECT,
|
||||
AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED,
|
||||
AVDTP_SIGNALING_CONNECTION_OPENED,
|
||||
AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED
|
||||
|
@ -86,7 +86,7 @@ static int avdtp_acceptor_validate_msg_length(avdtp_signal_identifier_t signal_i
|
||||
void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t * packet, uint16_t size, int offset, avdtp_context_t * context){
|
||||
avdtp_stream_endpoint_t * stream_endpoint;
|
||||
connection->acceptor_transaction_label = connection->signaling_packet.transaction_label;
|
||||
// printf("avdtp_acceptor_stream_config_subsm identifier %d\n", connection->signaling_packet.signal_identifier);
|
||||
|
||||
if (!avdtp_acceptor_validate_msg_length(connection->signaling_packet.signal_identifier, size)) {
|
||||
connection->error_code = BAD_LENGTH;
|
||||
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
||||
@ -98,7 +98,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
switch (connection->signaling_packet.signal_identifier){
|
||||
case AVDTP_SI_DISCOVER:
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
printf(" ACP: AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS\n");
|
||||
log_info(" ACP: AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS");
|
||||
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS;
|
||||
avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
||||
return;
|
||||
@ -114,7 +114,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
connection->query_seid = packet[offset++] >> 2;
|
||||
stream_endpoint = avdtp_stream_endpoint_with_seid(connection->query_seid, context);
|
||||
if (!stream_endpoint){
|
||||
printf(" ACP: cmd %d - RESPONSE REJECT\n", connection->signaling_packet.signal_identifier);
|
||||
log_info(" ACP: cmd %d - RESPONSE REJECT", connection->signaling_packet.signal_identifier);
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
if (connection->signaling_packet.signal_identifier == AVDTP_SI_OPEN){
|
||||
connection->error_code = BAD_STATE;
|
||||
@ -133,18 +133,18 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
|
||||
case AVDTP_SI_SUSPEND:{
|
||||
int i;
|
||||
printf(" ACP: AVDTP_SI_SUSPEND seids: ");
|
||||
log_info(" ACP: AVDTP_SI_SUSPEND seids: ");
|
||||
connection->num_suspended_seids = 0;
|
||||
|
||||
for (i = offset; i < size; i++){
|
||||
connection->suspended_seids[connection->num_suspended_seids] = packet[i] >> 2;
|
||||
offset++;
|
||||
printf("%d, \n", connection->suspended_seids[connection->num_suspended_seids]);
|
||||
log_info("%d, ", connection->suspended_seids[connection->num_suspended_seids]);
|
||||
connection->num_suspended_seids++;
|
||||
}
|
||||
|
||||
if (connection->num_suspended_seids == 0) {
|
||||
printf(" ACP: CATEGORY RESPONSE REJECT BAD_ACP_SEID\n");
|
||||
log_info(" ACP: CATEGORY RESPONSE REJECT BAD_ACP_SEID");
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
connection->reject_service_category = connection->query_seid;
|
||||
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
@ -156,7 +156,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
connection->query_seid = connection->suspended_seids[0];
|
||||
stream_endpoint = avdtp_stream_endpoint_with_seid(connection->query_seid, context);
|
||||
if (!stream_endpoint){
|
||||
printf(" ACP: stream_endpoint not found, CATEGORY RESPONSE REJECT BAD_ACP_SEID\n");
|
||||
log_info(" ACP: stream_endpoint not found, CATEGORY RESPONSE REJECT BAD_ACP_SEID");
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
connection->reject_service_category = connection->query_seid;
|
||||
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
@ -170,7 +170,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
default:
|
||||
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_GENERAL_REJECT_WITH_ERROR_CODE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
printf("AVDTP_CMD_MSG signal %d not implemented, general reject\n", connection->signaling_packet.signal_identifier);
|
||||
log_info("AVDTP_CMD_MSG signal %d not implemented, general reject", connection->signaling_packet.signal_identifier);
|
||||
avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
||||
return;
|
||||
}
|
||||
@ -189,15 +189,15 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
||||
switch (connection->signaling_packet.signal_identifier){
|
||||
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
||||
printf(" ACP: AVDTP_SI_GET_ALL_CAPABILITIES\n");
|
||||
log_info(" ACP: AVDTP_SI_GET_ALL_CAPABILITIES");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_ALL_CAPABILITIES;
|
||||
break;
|
||||
case AVDTP_SI_GET_CAPABILITIES:
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES\n");
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES;
|
||||
break;
|
||||
case AVDTP_SI_SET_CONFIGURATION:{
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION \n");
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION ");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION;
|
||||
connection->reject_service_category = 0;
|
||||
stream_endpoint->connection = connection;
|
||||
@ -207,14 +207,14 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
sep.in_use = 1;
|
||||
|
||||
if (connection->error_code){
|
||||
printf("fire configuration parsing errors \n");
|
||||
log_info("fire configuration parsing errors ");
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
break;
|
||||
}
|
||||
// find or add sep
|
||||
stream_endpoint->remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
|
||||
printf(" ACP .. seid %d, index %d\n", sep.seid, stream_endpoint->remote_sep_index);
|
||||
log_info(" ACP .. seid %d, index %d", sep.seid, stream_endpoint->remote_sep_index);
|
||||
|
||||
if (stream_endpoint->remote_sep_index != 0xFF){
|
||||
if (stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].in_use){
|
||||
@ -233,15 +233,15 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
} else {
|
||||
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
printf(" ACP: update seid %d, to %p\n", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info(" ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
}
|
||||
} else {
|
||||
// add new
|
||||
printf(" ACP: seid %d not found in %p\n", sep.seid, stream_endpoint);
|
||||
log_info(" ACP: seid %d not found in %p", sep.seid, stream_endpoint);
|
||||
stream_endpoint->remote_sep_index = connection->remote_seps_num;
|
||||
connection->remote_seps_num++;
|
||||
connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
printf(" ACP: add seid %d, to %p\n", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info(" ACP: add seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
}
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.configuration.media_codec.media_codec_type){
|
||||
@ -262,8 +262,8 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
|
||||
avdtp_sep_t sep;
|
||||
sep.seid = connection->query_seid;
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE seid %d\n", sep.seid);
|
||||
// printf_hexdump(connection->signaling_packet.command, packet_size);
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE seid %d", sep.seid);
|
||||
// log_info_hexdump(connection->signaling_packet.command, packet_size);
|
||||
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+offset, packet_size-offset);
|
||||
|
||||
@ -277,14 +277,14 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
// find sep or raise error
|
||||
stream_endpoint->remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
|
||||
if (stream_endpoint->remote_sep_index == 0xFF){
|
||||
printf(" ACP: REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID\n");
|
||||
log_info(" ACP: REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
}
|
||||
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
printf(" ACP: update seid %d, to %p\n", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info(" ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.capabilities.media_codec.media_codec_type){
|
||||
@ -301,43 +301,43 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
}
|
||||
|
||||
case AVDTP_SI_GET_CONFIGURATION:
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION\n");
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION;
|
||||
break;
|
||||
case AVDTP_SI_OPEN:
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_CONFIGURED){
|
||||
printf(" ACP: REJECT AVDTP_SI_OPEN, BAD_STATE\n");
|
||||
log_info(" ACP: REJECT AVDTP_SI_OPEN, BAD_STATE");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
}
|
||||
printf(" ACP: AVDTP_STREAM_ENDPOINT_W2_ANSWER_OPEN_STREAM\n");
|
||||
log_info(" ACP: AVDTP_STREAM_ENDPOINT_W2_ANSWER_OPEN_STREAM");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_OPEN_STREAM;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_CONNECTED;
|
||||
connection->query_seid = stream_endpoint->sep.seid;
|
||||
break;
|
||||
case AVDTP_SI_START:
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED){
|
||||
printf(" ACP: REJECT AVDTP_SI_START, BAD_STATE\n");
|
||||
log_info(" ACP: REJECT AVDTP_SI_START, BAD_STATE");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
}
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM\n");
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM;
|
||||
break;
|
||||
case AVDTP_SI_CLOSE:
|
||||
switch (stream_endpoint->state){
|
||||
case AVDTP_STREAM_ENDPOINT_OPENED:
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM\n");
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM;
|
||||
break;
|
||||
default:
|
||||
printf(" ACP: AVDTP_SI_CLOSE, bad state %d \n", stream_endpoint->state);
|
||||
log_info(" ACP: AVDTP_SI_CLOSE, bad state %d ", stream_endpoint->state);
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
@ -350,12 +350,12 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
case AVDTP_STREAM_ENDPOINT_CLOSING:
|
||||
case AVDTP_STREAM_ENDPOINT_OPENED:
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM\n");
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM;
|
||||
break;
|
||||
default:
|
||||
printf(" ACP: AVDTP_SI_ABORT, bad state %d \n", stream_endpoint->state);
|
||||
log_info(" ACP: AVDTP_SI_ABORT, bad state %d ", stream_endpoint->state);
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
@ -363,19 +363,19 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
}
|
||||
break;
|
||||
case AVDTP_SI_SUSPEND:
|
||||
printf(" entering AVDTP_SI_SUSPEND\n");
|
||||
log_info(" entering AVDTP_SI_SUSPEND");
|
||||
switch (stream_endpoint->state){
|
||||
case AVDTP_STREAM_ENDPOINT_OPENED:
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||
connection->num_suspended_seids--;
|
||||
if (connection->num_suspended_seids <= 0){
|
||||
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM\n");
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf(" ACP: AVDTP_SI_SUSPEND, bad state \n");
|
||||
log_info(" ACP: AVDTP_SI_SUSPEND, bad state ");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
@ -386,7 +386,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
//stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_SUSPEND_STREAM;
|
||||
break;
|
||||
default:
|
||||
printf(" ACP: NOT IMPLEMENTED, Reject signal_identifier %02x\n", connection->signaling_packet.signal_identifier);
|
||||
log_info(" ACP: NOT IMPLEMENTED, Reject signal_identifier %02x", connection->signaling_packet.signal_identifier);
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
@ -397,7 +397,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
}
|
||||
|
||||
if (!request_to_send){
|
||||
printf(" ACP: NOT IMPLEMENTED\n");
|
||||
log_info(" ACP: NOT IMPLEMENTED");
|
||||
}
|
||||
avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
||||
}
|
||||
@ -475,7 +475,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
break;
|
||||
}
|
||||
if (sent){
|
||||
printf(" ACP: DONE\n");
|
||||
log_info(" ACP: DONE");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -504,9 +504,9 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
pos = avdtp_signaling_create_fragment(cid, &connection->signaling_packet, out_buffer);
|
||||
if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
|
||||
stream_endpoint->acceptor_config_state = acceptor_config_state;
|
||||
printf(" ACP: fragmented\n");
|
||||
log_info(" ACP: fragmented");
|
||||
} else {
|
||||
printf(" ACP:DONE\n");
|
||||
log_info(" ACP:DONE");
|
||||
}
|
||||
l2cap_send_prepared(cid, pos);
|
||||
break;
|
||||
@ -517,22 +517,22 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
pos = avdtp_signaling_create_fragment(cid, &connection->signaling_packet, out_buffer);
|
||||
if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
|
||||
stream_endpoint->acceptor_config_state = acceptor_config_state;
|
||||
printf(" ACP: fragmented\n");
|
||||
log_info(" ACP: fragmented");
|
||||
} else {
|
||||
printf(" ACP:DONE\n");
|
||||
log_info(" ACP:DONE");
|
||||
}
|
||||
l2cap_send_prepared(cid, pos);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION:
|
||||
printf(" ACP: DONE\n");
|
||||
printf(" -> AVDTP_STREAM_ENDPOINT_CONFIGURED\n");
|
||||
log_info(" ACP: DONE");
|
||||
log_info(" -> AVDTP_STREAM_ENDPOINT_CONFIGURED");
|
||||
stream_endpoint->connection = connection;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||
// TODO: consider reconfiguration
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SET_CONFIGURATION);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE:
|
||||
printf(" ACP: DONE \n");
|
||||
log_info(" ACP: DONE ");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_RECONFIGURE);
|
||||
break;
|
||||
|
||||
@ -544,59 +544,59 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
pos = avdtp_signaling_create_fragment(cid, &connection->signaling_packet, out_buffer);
|
||||
if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
|
||||
stream_endpoint->acceptor_config_state = acceptor_config_state;
|
||||
printf(" ACP: fragmented\n");
|
||||
log_info(" ACP: fragmented");
|
||||
} else {
|
||||
printf(" ACP:DONE\n");
|
||||
log_info(" ACP:DONE");
|
||||
}
|
||||
l2cap_send_prepared(cid, pos);
|
||||
break;
|
||||
}
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_OPEN_STREAM:
|
||||
printf(" ACP: DONE\n");
|
||||
log_info(" ACP: DONE");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_OPEN);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM:
|
||||
printf(" ACP: DONE \n");
|
||||
printf(" -> AVDTP_STREAM_ENDPOINT_STREAMING \n");
|
||||
log_info(" ACP: DONE ");
|
||||
log_info(" -> AVDTP_STREAM_ENDPOINT_STREAMING ");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_START);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM:
|
||||
printf(" ACP: DONE\n");
|
||||
log_info(" ACP: DONE");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_CLOSE);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM:
|
||||
printf(" ACP: DONE\n");
|
||||
log_info(" ACP: DONE");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_ABORT);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM:
|
||||
printf(" ACP: DONE\n");
|
||||
log_info(" ACP: DONE");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SUSPEND);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD:
|
||||
status = 1;
|
||||
printf(" ACP: DONE REJECT\n");
|
||||
log_info(" ACP: DONE REJECT");
|
||||
connection->reject_signal_identifier = 0;
|
||||
avdtp_acceptor_send_response_reject(cid, reject_signal_identifier, trid);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE:
|
||||
status = 1;
|
||||
printf(" ACP: DONE REJECT CATEGORY\n");
|
||||
log_info(" ACP: DONE REJECT CATEGORY");
|
||||
connection->reject_service_category = 0;
|
||||
avdtp_acceptor_send_response_reject_service_category(cid, reject_signal_identifier, reject_service_category, error_code, trid);
|
||||
break;
|
||||
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE:
|
||||
status = 1;
|
||||
printf(" ACP: DONE REJECT\n");
|
||||
log_info(" ACP: DONE REJECT");
|
||||
connection->reject_signal_identifier = 0;
|
||||
connection->error_code = 0;
|
||||
avdtp_acceptor_send_response_reject_with_error_code(cid, reject_signal_identifier, error_code, trid);
|
||||
break;
|
||||
default:
|
||||
status = 0;
|
||||
printf(" ACP: NOT IMPLEMENTED\n");
|
||||
log_info(" ACP: NOT IMPLEMENTED");
|
||||
sent = 0;
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->signaling_packet.signal_identifier, status);
|
||||
|
@ -81,7 +81,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
if (!stream_endpoint) return;
|
||||
sep.seid = connection->acp_seid;
|
||||
|
||||
printf(" INT: local seid %d, remote seid %d, ident %d \n", connection->int_seid, connection->acp_seid, connection->signaling_packet.signal_identifier);
|
||||
if (stream_endpoint->initiator_config_state != AVDTP_INITIATOR_W4_ANSWER) return;
|
||||
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
|
||||
}
|
||||
@ -90,15 +89,15 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
case AVDTP_RESPONSE_ACCEPT_MSG:
|
||||
switch (connection->signaling_packet.signal_identifier){
|
||||
case AVDTP_SI_DISCOVER:{
|
||||
printf("AVDTP_SI_DISCOVER\n");
|
||||
log_info("AVDTP_SI_DISCOVER");
|
||||
if (connection->signaling_packet.transaction_label != connection->initiator_transaction_label){
|
||||
printf(" unexpected transaction label, got %d, expected %d\n", connection->signaling_packet.transaction_label, connection->initiator_transaction_label);
|
||||
log_info(" unexpected transaction label, got %d, expected %d", connection->signaling_packet.transaction_label, connection->initiator_transaction_label);
|
||||
status = BAD_HEADER_FORMAT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (size == 3){
|
||||
printf(" ERROR code %02x\n", packet[offset]);
|
||||
log_info(" ERROR code %02x", packet[offset]);
|
||||
status = packet[offset];
|
||||
break;
|
||||
}
|
||||
@ -108,7 +107,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
sep.seid = packet[i] >> 2;
|
||||
offset++;
|
||||
if (sep.seid < 0x01 || sep.seid > 0x3E){
|
||||
printf(" invalid sep id\n");
|
||||
log_info(" invalid sep id");
|
||||
status = BAD_ACP_SEID;
|
||||
break;
|
||||
}
|
||||
@ -126,7 +125,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
|
||||
case AVDTP_SI_GET_CAPABILITIES:
|
||||
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
||||
printf("AVDTP_SI_GET(_ALL)_CAPABILITIES int %d, acp %d\n", connection->int_seid, connection->acp_seid);
|
||||
log_info("AVDTP_SI_GET(_ALL)_CAPABILITIES int %d, acp %d", connection->int_seid, connection->acp_seid);
|
||||
sep.registered_service_categories = avdtp_unpack_service_capabilities(connection, &sep.capabilities, packet+offset, size-offset);
|
||||
if (get_bit16(sep.registered_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.capabilities.media_codec.media_codec_type){
|
||||
@ -141,7 +140,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
|
||||
case AVDTP_SI_GET_CONFIGURATION:
|
||||
printf("AVDTP_SI_GET_CONFIGURATION\n");
|
||||
log_info("AVDTP_SI_GET_CONFIGURATION");
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, packet+offset, size-offset);
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.configuration.media_codec.media_codec_type){
|
||||
@ -156,7 +155,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
|
||||
case AVDTP_SI_RECONFIGURE:
|
||||
printf("AVDTP_SI_RECONFIGURE\n");
|
||||
log_info("AVDTP_SI_RECONFIGURE");
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+4, connection->signaling_packet.size-4);
|
||||
// TODO check if configuration is supported
|
||||
|
||||
@ -165,12 +164,12 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
stream_endpoint->remote_sep_index = remote_sep_index;
|
||||
connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||
printf(" INT: update seid %d, to %p\n", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info(" INT: update seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
}
|
||||
break;
|
||||
|
||||
case AVDTP_SI_SET_CONFIGURATION:{
|
||||
printf("AVDTP_SI_SET_CONFIGURATION\n");
|
||||
log_info("AVDTP_SI_SET_CONFIGURATION");
|
||||
sep.configured_service_categories = stream_endpoint->remote_capabilities_bitmap;
|
||||
sep.configuration = stream_endpoint->remote_capabilities;
|
||||
sep.in_use = 1;
|
||||
@ -185,13 +184,13 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
stream_endpoint->connection->remote_seps_num++;
|
||||
}
|
||||
connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
printf(" INT: configured remote seid %d, to %p\n", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info(" INT: configured remote seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||
break;
|
||||
}
|
||||
|
||||
case AVDTP_SI_OPEN:
|
||||
printf("AVDTP_SI_OPEN\n");
|
||||
log_info("AVDTP_SI_OPEN");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM) {
|
||||
log_error("AVDTP_SI_OPEN in wrong stream endpoint state");
|
||||
return;
|
||||
@ -201,16 +200,16 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
l2cap_create_channel(context->packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
|
||||
return;
|
||||
case AVDTP_SI_START:
|
||||
printf("AVDTP_SI_START\n");
|
||||
log_info("AVDTP_SI_START");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED) {
|
||||
log_error("AVDTP_SI_START in wrong stream endpoint state");
|
||||
return;
|
||||
}
|
||||
printf("AVDTP_STREAM_ENDPOINT_STREAMING\n");
|
||||
log_info("AVDTP_STREAM_ENDPOINT_STREAMING");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
||||
break;
|
||||
case AVDTP_SI_SUSPEND:
|
||||
printf("AVDTP_SI_SUSPEND\n");
|
||||
log_info("AVDTP_SI_SUSPEND");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
|
||||
log_error("AVDTP_SI_SUSPEND in wrong stream endpoint state");
|
||||
return;
|
||||
@ -218,27 +217,27 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||
break;
|
||||
case AVDTP_SI_CLOSE:
|
||||
printf("AVDTP_SI_CLOSE\n");
|
||||
log_info("AVDTP_SI_CLOSE");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
||||
break;
|
||||
case AVDTP_SI_ABORT:
|
||||
printf("AVDTP_SI_ABORT\n");
|
||||
log_info("AVDTP_SI_ABORT");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
||||
break;
|
||||
default:
|
||||
status = 1;
|
||||
printf(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented\n", connection->signaling_packet.signal_identifier);
|
||||
log_info(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->signaling_packet.signal_identifier);
|
||||
break;
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->l2cap_signaling_cid, 0, connection->signaling_packet.signal_identifier, status);
|
||||
connection->initiator_transaction_label++;
|
||||
break;
|
||||
case AVDTP_RESPONSE_REJECT_MSG:
|
||||
printf(" AVDTP_RESPONSE_REJECT_MSG signal %d\n", connection->signaling_packet.signal_identifier);
|
||||
log_info(" AVDTP_RESPONSE_REJECT_MSG signal %d", connection->signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_reject(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->signaling_packet.signal_identifier);
|
||||
return;
|
||||
case AVDTP_GENERAL_REJECT_MSG:
|
||||
printf(" AVDTP_GENERAL_REJECT_MSG signal %d\n", connection->signaling_packet.signal_identifier);
|
||||
log_info(" AVDTP_GENERAL_REJECT_MSG signal %d", connection->signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_general_reject(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->signaling_packet.signal_identifier);
|
||||
return;
|
||||
default:
|
||||
@ -250,22 +249,22 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
int sent = 1;
|
||||
switch (connection->initiator_connection_state){
|
||||
case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS:
|
||||
printf(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS\n");
|
||||
log_info(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS");
|
||||
connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
|
||||
avdtp_initiator_send_signaling_cmd(connection->l2cap_signaling_cid, AVDTP_SI_DISCOVER, connection->initiator_transaction_label);
|
||||
break;
|
||||
case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES:
|
||||
printf(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES\n");
|
||||
log_info(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES");
|
||||
connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
|
||||
avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_CAPABILITIES, connection->initiator_transaction_label, connection->acp_seid);
|
||||
break;
|
||||
case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES:
|
||||
printf(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES\n");
|
||||
log_info(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES");
|
||||
connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
|
||||
avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_ALL_CAPABILITIES, connection->initiator_transaction_label, connection->acp_seid);
|
||||
break;
|
||||
case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CONFIGURATION:
|
||||
printf(" INT: AVDTP_INITIATOR_W4_GET_CONFIGURATION\n");
|
||||
log_info(" INT: AVDTP_INITIATOR_W4_GET_CONFIGURATION");
|
||||
connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER;
|
||||
avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_CONFIGURATION, connection->initiator_transaction_label, connection->acp_seid);
|
||||
break;
|
||||
@ -348,8 +347,8 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
switch (stream_endpoint_state){
|
||||
case AVDTP_INITIATOR_W2_SET_CONFIGURATION:
|
||||
case AVDTP_INITIATOR_W2_RECONFIGURE_STREAM_WITH_SEID:{
|
||||
printf(" INT: AVDTP_INITIATOR_W2_(RE)CONFIGURATION bitmap, int seid %d, acp seid %d\n", connection->int_seid, connection->acp_seid);
|
||||
// printf_hexdump( connection->remote_capabilities.media_codec.media_codec_information, connection->remote_capabilities.media_codec.media_codec_information_len);
|
||||
log_info(" INT: AVDTP_INITIATOR_W2_(RE)CONFIGURATION bitmap, int seid %d, acp seid %d", connection->int_seid, connection->acp_seid);
|
||||
// log_info_hexdump( connection->remote_capabilities.media_codec.media_codec_information, connection->remote_capabilities.media_codec.media_codec_information_len);
|
||||
connection->signaling_packet.acp_seid = connection->acp_seid;
|
||||
connection->signaling_packet.int_seid = connection->int_seid;
|
||||
|
||||
@ -365,7 +364,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
uint16_t pos = avdtp_signaling_create_fragment(connection->l2cap_signaling_cid, &connection->signaling_packet, out_buffer);
|
||||
if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
|
||||
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_FRAGMENTATED_COMMAND;
|
||||
printf(" INT: fragmented\n");
|
||||
log_info(" INT: fragmented");
|
||||
}
|
||||
l2cap_send_prepared(connection->l2cap_signaling_cid, pos);
|
||||
break;
|
||||
@ -376,7 +375,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
uint16_t pos = avdtp_signaling_create_fragment(connection->l2cap_signaling_cid, &connection->signaling_packet, out_buffer);
|
||||
if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
|
||||
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_FRAGMENTATED_COMMAND;
|
||||
printf(" INT: fragmented\n");
|
||||
log_info(" INT: fragmented");
|
||||
}
|
||||
l2cap_send_prepared(connection->l2cap_signaling_cid, pos);
|
||||
break;
|
||||
@ -384,7 +383,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
case AVDTP_INITIATOR_W2_OPEN_STREAM:
|
||||
switch (stream_endpoint->state){
|
||||
case AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM:
|
||||
printf(" INT: AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM\n");
|
||||
log_info(" INT: AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM");
|
||||
avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_OPEN, connection->initiator_transaction_label, connection->acp_seid);
|
||||
break;
|
||||
default:
|
||||
|
@ -179,7 +179,7 @@ int avdtp_read_signaling_header(avdtp_signaling_packet_t * signaling_header, uin
|
||||
break;
|
||||
case AVDTP_CONTINUE_PACKET:
|
||||
if (signaling_header->num_packets <= 0) {
|
||||
printf(" ERROR: wrong num fragmented packets\n");
|
||||
log_info(" ERROR: wrong num fragmented packets\n");
|
||||
break;
|
||||
}
|
||||
signaling_header->num_packets--;
|
||||
@ -243,7 +243,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
|
||||
|
||||
if (category == AVDTP_SERVICE_CATEGORY_INVALID_0 ||
|
||||
(category == AVDTP_SERVICE_CATEGORY_INVALID_FF && connection->signaling_packet.signal_identifier == AVDTP_SI_RECONFIGURE)){
|
||||
printf(" ERROR: BAD SERVICE CATEGORY %d\n", category);
|
||||
log_info(" ERROR: BAD SERVICE CATEGORY %d\n", category);
|
||||
connection->reject_service_category = category;
|
||||
connection->error_code = BAD_SERV_CATEGORY;
|
||||
return 1;
|
||||
@ -251,7 +251,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
|
||||
|
||||
if (connection->signaling_packet.signal_identifier == AVDTP_SI_RECONFIGURE){
|
||||
if (category != AVDTP_CONTENT_PROTECTION && category != AVDTP_MEDIA_CODEC){
|
||||
printf(" ERROR: REJECT CATEGORY, INVALID_CAPABILITIES\n");
|
||||
log_info(" ERROR: REJECT CATEGORY, INVALID_CAPABILITIES\n");
|
||||
connection->reject_service_category = category;
|
||||
connection->error_code = INVALID_CAPABILITIES;
|
||||
return 1;
|
||||
@ -261,7 +261,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
|
||||
switch(category){
|
||||
case AVDTP_MEDIA_TRANSPORT:
|
||||
if (cap_len != 0){
|
||||
printf(" ERROR: REJECT CATEGORY, BAD_MEDIA_TRANSPORT\n");
|
||||
log_info(" ERROR: REJECT CATEGORY, BAD_MEDIA_TRANSPORT\n");
|
||||
connection->reject_service_category = category;
|
||||
connection->error_code = BAD_MEDIA_TRANSPORT_FORMAT;
|
||||
return 1;
|
||||
@ -270,7 +270,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
|
||||
case AVDTP_REPORTING:
|
||||
case AVDTP_DELAY_REPORTING:
|
||||
if (cap_len != 0){
|
||||
printf(" ERROR: REJECT CATEGORY, BAD_LENGTH\n");
|
||||
log_info(" ERROR: REJECT CATEGORY, BAD_LENGTH\n");
|
||||
connection->reject_service_category = category;
|
||||
connection->error_code = BAD_LENGTH;
|
||||
return 1;
|
||||
@ -278,7 +278,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
|
||||
break;
|
||||
case AVDTP_RECOVERY:
|
||||
if (cap_len < 3){
|
||||
printf(" ERROR: REJECT CATEGORY, BAD_MEDIA_TRANSPORT\n");
|
||||
log_info(" ERROR: REJECT CATEGORY, BAD_MEDIA_TRANSPORT\n");
|
||||
connection->reject_service_category = category;
|
||||
connection->error_code = BAD_RECOVERY_FORMAT;
|
||||
return 1;
|
||||
@ -286,7 +286,7 @@ static int avdtp_unpack_service_capabilities_has_errors(avdtp_connection_t * con
|
||||
break;
|
||||
case AVDTP_CONTENT_PROTECTION:
|
||||
if (cap_len < 2){
|
||||
printf(" ERROR: REJECT CATEGORY, BAD_CP_FORMAT\n");
|
||||
log_info(" ERROR: REJECT CATEGORY, BAD_CP_FORMAT\n");
|
||||
connection->reject_service_category = category;
|
||||
connection->error_code = BAD_CP_FORMAT;
|
||||
return 1;
|
||||
@ -316,8 +316,7 @@ uint16_t avdtp_unpack_service_capabilities(avdtp_connection_t * connection, avdt
|
||||
if (avdtp_unpack_service_capabilities_has_errors(connection, category, cap_len)) return 0;
|
||||
int processed_cap_len = 0;
|
||||
int rfa = 0;
|
||||
//printf(" size %d, cat size %d\n", size, cap_len);
|
||||
|
||||
|
||||
while (pos < size){
|
||||
if (cap_len > size - pos){
|
||||
connection->reject_service_category = category;
|
||||
@ -387,8 +386,6 @@ uint16_t avdtp_unpack_service_capabilities(avdtp_connection_t * connection, avdt
|
||||
category = (avdtp_service_category_t)packet[pos++];
|
||||
cap_len = packet[pos++];
|
||||
if (avdtp_unpack_service_capabilities_has_errors(connection, category, cap_len)) return 0;
|
||||
//printf("category %d, pos %d + 2 + %d -> %d\n", category, old_pos, cap_len, pos + cap_len);
|
||||
//printf_hexdump(packet+old_pos, size-old_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -426,10 +423,6 @@ void avdtp_prepare_capabilities(avdtp_signaling_packet_t * signaling_packet, uin
|
||||
break;
|
||||
}
|
||||
|
||||
// printf("registered_service_categories: 0x%02x\n", registered_service_categories);
|
||||
|
||||
// printf("command before packing:\n");
|
||||
// printf_hexdump(signaling_packet->command, signaling_packet->size);
|
||||
for (i = 1; i < 9; i++){
|
||||
int registered_category = get_bit16(registered_service_categories, i);
|
||||
if (!registered_category && (identifier == AVDTP_SI_SET_CONFIGURATION || identifier == AVDTP_SI_RECONFIGURE)){
|
||||
@ -440,13 +433,10 @@ void avdtp_prepare_capabilities(avdtp_signaling_packet_t * signaling_packet, uin
|
||||
}
|
||||
if (registered_category){
|
||||
// service category
|
||||
// printf("pack service category: %d\n", i);
|
||||
signaling_packet->command[signaling_packet->size++] = i;
|
||||
signaling_packet->size += avdtp_pack_service_capabilities(signaling_packet->command+signaling_packet->size, sizeof(signaling_packet->command)-signaling_packet->size, capabilities, (avdtp_service_category_t)i, pack_all_capabilities);
|
||||
}
|
||||
}
|
||||
// printf("command after packing:\n");
|
||||
// printf_hexdump(signaling_packet->command, signaling_packet->size);
|
||||
|
||||
signaling_packet->signal_identifier = identifier;
|
||||
signaling_packet->transaction_label = transaction_label;
|
||||
@ -454,17 +444,13 @@ void avdtp_prepare_capabilities(avdtp_signaling_packet_t * signaling_packet, uin
|
||||
|
||||
int avdtp_signaling_create_fragment(uint16_t cid, avdtp_signaling_packet_t * signaling_packet, uint8_t * out_buffer) {
|
||||
int mtu = l2cap_get_remote_mtu_for_local_cid(cid);
|
||||
// hack for test
|
||||
// int mtu = 6;
|
||||
int data_len = 0;
|
||||
|
||||
uint16_t offset = signaling_packet->offset;
|
||||
uint16_t pos = 1;
|
||||
// printf(" avdtp_signaling_create_fragment offset %d, packet type %d\n", signaling_packet->offset, signaling_packet->packet_type);
|
||||
|
||||
if (offset == 0){
|
||||
if (signaling_packet->size <= mtu - 2){
|
||||
// printf(" AVDTP_SINGLE_PACKET\n");
|
||||
signaling_packet->packet_type = AVDTP_SINGLE_PACKET;
|
||||
out_buffer[pos++] = signaling_packet->signal_identifier;
|
||||
data_len = signaling_packet->size;
|
||||
@ -474,21 +460,17 @@ int avdtp_signaling_create_fragment(uint16_t cid, avdtp_signaling_packet_t * sig
|
||||
out_buffer[pos++] = signaling_packet->signal_identifier;
|
||||
data_len = mtu - 3;
|
||||
signaling_packet->offset = data_len;
|
||||
// printf(" AVDTP_START_PACKET len %d, offset %d\n", signaling_packet->size, signaling_packet->offset);
|
||||
}
|
||||
} else {
|
||||
int remaining_bytes = signaling_packet->size - offset;
|
||||
if (remaining_bytes <= mtu - 1){
|
||||
//signaling_packet->fragmentation = 1;
|
||||
signaling_packet->packet_type = AVDTP_END_PACKET;
|
||||
data_len = remaining_bytes;
|
||||
signaling_packet->offset = 0;
|
||||
// printf(" AVDTP_END_PACKET len %d, offset %d\n", signaling_packet->size, signaling_packet->offset);
|
||||
} else{
|
||||
signaling_packet->packet_type = AVDTP_CONTINUE_PACKET;
|
||||
data_len = mtu - 1;
|
||||
signaling_packet->offset += data_len;
|
||||
// printf(" AVDTP_CONTINUE_PACKET len %d, offset %d\n", signaling_packet->size, signaling_packet->offset);
|
||||
}
|
||||
}
|
||||
out_buffer[0] = avdtp_header(signaling_packet->transaction_label, signaling_packet->packet_type, signaling_packet->message_type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user