mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 21:35:16 +00:00
avdtp: introduce is_initiator param in accept and reject events
This commit is contained in:
parent
9bd07b2616
commit
63274943dc
@ -1674,28 +1674,31 @@ typedef uint8_t sm_key_t[16];
|
||||
/** AVDTP Subevent */
|
||||
|
||||
/**
|
||||
* @format 1211
|
||||
* @format 12111
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param local_seid
|
||||
* @param is_initiator
|
||||
* @param signal_identifier
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_ACCEPT 0x01
|
||||
|
||||
/**
|
||||
* @format 1211
|
||||
* @format 12111
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param local_seid
|
||||
* @param local_seid
|
||||
* @param is_initiator
|
||||
* @param signal_identifier
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_REJECT 0x02
|
||||
|
||||
/**
|
||||
* @format 1211
|
||||
* @format 12111
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param local_seid
|
||||
* @param is_initiator
|
||||
* @param signal_identifier
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT 0x03
|
||||
|
@ -4284,6 +4284,15 @@ static inline uint16_t avdtp_subevent_signaling_accept_get_avdtp_cid(const uint8
|
||||
static inline uint8_t avdtp_subevent_signaling_accept_get_local_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field is_initiator from event AVDTP_SUBEVENT_SIGNALING_ACCEPT
|
||||
* @param event packet
|
||||
* @return is_initiator
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_accept_get_is_initiator(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field signal_identifier from event AVDTP_SUBEVENT_SIGNALING_ACCEPT
|
||||
* @param event packet
|
||||
@ -4291,7 +4300,7 @@ static inline uint8_t avdtp_subevent_signaling_accept_get_local_seid(const uint8
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_accept_get_signal_identifier(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[7];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4312,6 +4321,15 @@ static inline uint16_t avdtp_subevent_signaling_reject_get_avdtp_cid(const uint8
|
||||
static inline uint8_t avdtp_subevent_signaling_reject_get_local_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field is_initiator from event AVDTP_SUBEVENT_SIGNALING_REJECT
|
||||
* @param event packet
|
||||
* @return is_initiator
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_reject_get_is_initiator(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field signal_identifier from event AVDTP_SUBEVENT_SIGNALING_REJECT
|
||||
* @param event packet
|
||||
@ -4319,7 +4337,7 @@ static inline uint8_t avdtp_subevent_signaling_reject_get_local_seid(const uint8
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_reject_get_signal_identifier(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[7];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4340,6 +4358,15 @@ static inline uint16_t avdtp_subevent_signaling_general_reject_get_avdtp_cid(con
|
||||
static inline uint8_t avdtp_subevent_signaling_general_reject_get_local_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field is_initiator from event AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT
|
||||
* @param event packet
|
||||
* @return is_initiator
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_general_reject_get_is_initiator(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field signal_identifier from event AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT
|
||||
* @param event packet
|
||||
@ -4347,7 +4374,7 @@ static inline uint8_t avdtp_subevent_signaling_general_reject_get_local_seid(con
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_general_reject_get_signal_identifier(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[7];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -397,7 +397,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
// TODO check cid
|
||||
signal_identifier = avdtp_subevent_signaling_accept_get_signal_identifier(packet);
|
||||
cid = avdtp_subevent_signaling_accept_get_avdtp_cid(packet);
|
||||
log_info("A2DP cmd %s accepted , cid 0x%2x, local seid %d, active remote seid %d", avdtp_si2str(signal_identifier), cid, avdtp_subevent_signaling_accept_get_local_seid(packet), sc.active_remote_sep->seid);
|
||||
log_info("A2DP cmd %s accepted , cid 0x%2x, local seid %d", avdtp_si2str(signal_identifier), cid, avdtp_subevent_signaling_accept_get_local_seid(packet));
|
||||
|
||||
switch (app_state){
|
||||
case A2DP_W2_GET_CAPABILITIES:
|
||||
|
@ -96,11 +96,16 @@ void avdtp_configuration_timeout_handler(btstack_timer_source_t * timer){
|
||||
void avdtp_configuration_timer_start(avdtp_connection_t * connection){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = (avdtp_stream_endpoint_t*) connection->active_stream_endpoint;
|
||||
if (!stream_endpoint) {
|
||||
log_error("avdtp_configuration_timeout_handler: no initiator stream endpoint for seid %d", connection->initiator_local_seid);
|
||||
log_error("avdtp_configuration_timer_start: no initiator stream endpoint for seid %d", connection->initiator_local_seid);
|
||||
return;
|
||||
}
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_CONFIGURATION_SUBSTATEMACHINE) return;
|
||||
|
||||
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_CONFIGURATION_SUBSTATEMACHINE){
|
||||
log_info("avdtp_configuration_timer_start: stream endpoint in wrong state %d, expected %d", stream_endpoint->state, AVDTP_STREAM_ENDPOINT_CONFIGURATION_SUBSTATEMACHINE);
|
||||
return;
|
||||
}
|
||||
log_info("avdtp_configuration_timer_start: start");
|
||||
|
||||
btstack_run_loop_remove_timer(&connection->configuration_timer);
|
||||
btstack_run_loop_set_timer_handler(&connection->configuration_timer, avdtp_configuration_timeout_handler);
|
||||
btstack_run_loop_set_timer_context(&connection->configuration_timer, connection);
|
||||
|
@ -129,7 +129,7 @@ static void avdtp_acceptor_handle_configuration_command(avdtp_connection_t *conn
|
||||
}
|
||||
|
||||
avdtp_emit_configuration(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), avdtp_remote_seid(stream_endpoint), &sep.configuration, sep.configured_service_categories);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->acceptor_signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->acceptor_signaling_packet.signal_identifier, false);
|
||||
}
|
||||
|
||||
void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t * packet, uint16_t size, int offset, avdtp_context_t * context){
|
||||
@ -383,9 +383,6 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
connection->reject_signal_identifier = connection->acceptor_signaling_packet.signal_identifier;
|
||||
break;
|
||||
}
|
||||
|
||||
//stream_endpoint->state = AVDTP_STREAM_ENDPOINT_SUSPENDING;
|
||||
//stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_SUSPEND_STREAM;
|
||||
break;
|
||||
default:
|
||||
log_info("ACP: NOT IMPLEMENTED, Reject signal_identifier %02x", connection->acceptor_signaling_packet.signal_identifier);
|
||||
@ -537,7 +534,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
connection->configuration_state = AVDTP_CONFIGURATION_STATE_REMOTE_CONFIGURED;
|
||||
// TODO: consider reconfiguration
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SET_CONFIGURATION);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->acceptor_signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->acceptor_signaling_packet.signal_identifier, false);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE:
|
||||
log_info("ACP: DONE ");
|
||||
@ -603,7 +600,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
sent = 0;
|
||||
break;
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->acceptor_signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->acceptor_signaling_packet.signal_identifier, false);
|
||||
// check fragmentation
|
||||
if ((connection->acceptor_signaling_packet.packet_type != AVDTP_SINGLE_PACKET) && (connection->acceptor_signaling_packet.packet_type != AVDTP_END_PACKET)){
|
||||
avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
||||
|
@ -246,7 +246,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
log_info(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->initiator_signaling_packet.signal_identifier);
|
||||
break;
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, 0, connection->initiator_signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, 0, connection->initiator_signaling_packet.signal_identifier, true);
|
||||
connection->initiator_transaction_label++;
|
||||
break;
|
||||
case AVDTP_RESPONSE_REJECT_MSG:
|
||||
@ -259,12 +259,12 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
default:
|
||||
break;
|
||||
}
|
||||
log_info(" AVDTP_RESPONSE_REJECT_MSG signal %d", connection->initiator_signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_reject(context->avdtp_callback, connection->avdtp_cid, connection->initiator_local_seid, connection->initiator_signaling_packet.signal_identifier);
|
||||
log_info(" AVDTP_RESPONSE_REJECT_MSG signal %s", avdtp_si2str(connection->initiator_signaling_packet.signal_identifier));
|
||||
avdtp_signaling_emit_reject(context->avdtp_callback, connection->avdtp_cid, connection->initiator_local_seid, connection->initiator_signaling_packet.signal_identifier, true);
|
||||
return;
|
||||
case AVDTP_GENERAL_REJECT_MSG:
|
||||
log_info(" AVDTP_GENERAL_REJECT_MSG signal %d", connection->initiator_signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_general_reject(context->avdtp_callback, connection->avdtp_cid, connection->initiator_local_seid, connection->initiator_signaling_packet.signal_identifier);
|
||||
log_info(" AVDTP_GENERAL_REJECT_MSG signal %s", avdtp_si2str(connection->initiator_signaling_packet.signal_identifier));
|
||||
avdtp_signaling_emit_general_reject(context->avdtp_callback, connection->avdtp_cid, connection->initiator_local_seid, connection->initiator_signaling_packet.signal_identifier, true);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
|
@ -657,9 +657,9 @@ void avdtp_signaling_emit_delay(btstack_packet_handler_t callback, uint16_t avdt
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, avdtp_signal_identifier_t identifier){
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, avdtp_signal_identifier_t identifier, bool is_initiator){
|
||||
if (!callback) return;
|
||||
uint8_t event[7];
|
||||
uint8_t event[8];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
@ -667,13 +667,14 @@ void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avd
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = local_seid;
|
||||
event[pos++] = is_initiator ? 1 : 0;
|
||||
event[pos++] = identifier;
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, avdtp_signal_identifier_t identifier){
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, avdtp_signal_identifier_t identifier, bool is_initiator){
|
||||
if (!callback) return;
|
||||
uint8_t event[7];
|
||||
uint8_t event[8];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
@ -681,13 +682,14 @@ void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avd
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = local_seid;
|
||||
event[pos++] = is_initiator ? 1 : 0;
|
||||
event[pos++] = identifier;
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, avdtp_signal_identifier_t identifier){
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, avdtp_signal_identifier_t identifier, bool is_initiator){
|
||||
if (!callback) return;
|
||||
uint8_t event[7];
|
||||
uint8_t event[8];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
@ -695,6 +697,7 @@ void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = local_seid;
|
||||
event[pos++] = is_initiator ? 1 : 0;
|
||||
event[pos++] = identifier;
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ void avdtp_signaling_emit_sep(btstack_packet_handler_t callback, uint16_t avdtp_
|
||||
void avdtp_signaling_emit_sep_done(btstack_packet_handler_t callback, uint16_t avdtp_cid);
|
||||
void avdtp_signaling_emit_delay(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, uint16_t delay);
|
||||
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t seid, avdtp_signal_identifier_t identifier);
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier);
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier);
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t seid, avdtp_signal_identifier_t identifier, bool is_initiator);
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier, bool is_initiator);
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier, bool is_initiator);
|
||||
void avdtp_streaming_emit_can_send_media_packet_now(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint16_t sequence_number);
|
||||
|
||||
void avdtp_emit_capabilities(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, avdtp_capabilities_t * configuration, uint16_t configured_service_categories);
|
||||
|
Loading…
x
Reference in New Issue
Block a user