mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 20:42:47 +00:00
l2cap: reduce level in l2cap_run for ertm handling
This commit is contained in:
parent
817374d931
commit
951d9d0781
117
src/l2cap.c
117
src/l2cap.c
@ -1681,70 +1681,69 @@ static void l2cap_run(void){
|
|||||||
if (!channel) continue;
|
if (!channel) continue;
|
||||||
|
|
||||||
// ERTM mode
|
// ERTM mode
|
||||||
if (channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION){
|
if (channel->mode != L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION) continue;
|
||||||
|
|
||||||
// check if we can still send
|
// check if we can still send
|
||||||
if (channel->con_handle == HCI_CON_HANDLE_INVALID) continue;
|
if (channel->con_handle == HCI_CON_HANDLE_INVALID) continue;
|
||||||
if (!hci_can_send_acl_packet_now(channel->con_handle)) continue;
|
if (!hci_can_send_acl_packet_now(channel->con_handle)) continue;
|
||||||
|
|
||||||
if (channel->send_supervisor_frame_receiver_ready){
|
if (channel->send_supervisor_frame_receiver_ready){
|
||||||
channel->send_supervisor_frame_receiver_ready = 0;
|
channel->send_supervisor_frame_receiver_ready = 0;
|
||||||
log_info("Send S-Frame: RR %u, final %u", channel->req_seq, channel->set_final_bit_after_packet_with_poll_bit_set);
|
log_info("Send S-Frame: RR %u, final %u", channel->req_seq, channel->set_final_bit_after_packet_with_poll_bit_set);
|
||||||
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_RR_RECEIVER_READY, 0, channel->set_final_bit_after_packet_with_poll_bit_set, channel->req_seq);
|
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_RR_RECEIVER_READY, 0, channel->set_final_bit_after_packet_with_poll_bit_set, channel->req_seq);
|
||||||
channel->set_final_bit_after_packet_with_poll_bit_set = 0;
|
channel->set_final_bit_after_packet_with_poll_bit_set = 0;
|
||||||
l2cap_ertm_send_supervisor_frame(channel, control);
|
l2cap_ertm_send_supervisor_frame(channel, control);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (channel->send_supervisor_frame_receiver_ready_poll){
|
if (channel->send_supervisor_frame_receiver_ready_poll){
|
||||||
channel->send_supervisor_frame_receiver_ready_poll = 0;
|
channel->send_supervisor_frame_receiver_ready_poll = 0;
|
||||||
log_info("Send S-Frame: RR %u with poll=1 ", channel->req_seq);
|
log_info("Send S-Frame: RR %u with poll=1 ", channel->req_seq);
|
||||||
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_RR_RECEIVER_READY, 1, 0, channel->req_seq);
|
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_RR_RECEIVER_READY, 1, 0, channel->req_seq);
|
||||||
l2cap_ertm_send_supervisor_frame(channel, control);
|
l2cap_ertm_send_supervisor_frame(channel, control);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (channel->send_supervisor_frame_receiver_not_ready){
|
if (channel->send_supervisor_frame_receiver_not_ready){
|
||||||
channel->send_supervisor_frame_receiver_not_ready = 0;
|
channel->send_supervisor_frame_receiver_not_ready = 0;
|
||||||
log_info("Send S-Frame: RNR %u", channel->req_seq);
|
log_info("Send S-Frame: RNR %u", channel->req_seq);
|
||||||
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_RNR_RECEIVER_NOT_READY, 0, 0, channel->req_seq);
|
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_RNR_RECEIVER_NOT_READY, 0, 0, channel->req_seq);
|
||||||
l2cap_ertm_send_supervisor_frame(channel, control);
|
l2cap_ertm_send_supervisor_frame(channel, control);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (channel->send_supervisor_frame_reject){
|
if (channel->send_supervisor_frame_reject){
|
||||||
channel->send_supervisor_frame_reject = 0;
|
channel->send_supervisor_frame_reject = 0;
|
||||||
log_info("Send S-Frame: REJ %u", channel->req_seq);
|
log_info("Send S-Frame: REJ %u", channel->req_seq);
|
||||||
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_REJ_REJECT, 0, 0, channel->req_seq);
|
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_REJ_REJECT, 0, 0, channel->req_seq);
|
||||||
l2cap_ertm_send_supervisor_frame(channel, control);
|
l2cap_ertm_send_supervisor_frame(channel, control);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (channel->send_supervisor_frame_selective_reject){
|
if (channel->send_supervisor_frame_selective_reject){
|
||||||
channel->send_supervisor_frame_selective_reject = 0;
|
channel->send_supervisor_frame_selective_reject = 0;
|
||||||
log_info("Send S-Frame: SREJ %u", channel->expected_tx_seq);
|
log_info("Send S-Frame: SREJ %u", channel->expected_tx_seq);
|
||||||
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_SREJ_SELECTIVE_REJECT, 0, channel->set_final_bit_after_packet_with_poll_bit_set, channel->expected_tx_seq);
|
uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_SREJ_SELECTIVE_REJECT, 0, channel->set_final_bit_after_packet_with_poll_bit_set, channel->expected_tx_seq);
|
||||||
channel->set_final_bit_after_packet_with_poll_bit_set = 0;
|
channel->set_final_bit_after_packet_with_poll_bit_set = 0;
|
||||||
l2cap_ertm_send_supervisor_frame(channel, control);
|
l2cap_ertm_send_supervisor_frame(channel, control);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->srej_active){
|
if (channel->srej_active){
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<channel->num_tx_buffers;i++){
|
for (i=0;i<channel->num_tx_buffers;i++){
|
||||||
l2cap_ertm_tx_packet_state_t * tx_state = &channel->tx_packets_state[i];
|
l2cap_ertm_tx_packet_state_t * tx_state = &channel->tx_packets_state[i];
|
||||||
if (tx_state->retransmission_requested) {
|
if (tx_state->retransmission_requested) {
|
||||||
tx_state->retransmission_requested = 0;
|
tx_state->retransmission_requested = 0;
|
||||||
uint8_t final = channel->set_final_bit_after_packet_with_poll_bit_set;
|
uint8_t final = channel->set_final_bit_after_packet_with_poll_bit_set;
|
||||||
channel->set_final_bit_after_packet_with_poll_bit_set = 0;
|
channel->set_final_bit_after_packet_with_poll_bit_set = 0;
|
||||||
l2cap_ertm_send_information_frame(channel, i, final);
|
l2cap_ertm_send_information_frame(channel, i, final);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == channel->num_tx_buffers){
|
|
||||||
// no retransmission request found
|
|
||||||
channel->srej_active = 0;
|
|
||||||
} else {
|
|
||||||
// packet was sent
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (i == channel->num_tx_buffers){
|
||||||
|
// no retransmission request found
|
||||||
|
channel->srej_active = 0;
|
||||||
|
} else {
|
||||||
|
// packet was sent
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user