diff --git a/src/l2cap.c b/src/l2cap.c index 53878c413..009ebdb85 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -911,10 +911,10 @@ static void l2cap_run(void){ #ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE // send s-frame to acknowledge received packets if (!hci_can_send_acl_packet_now(channel->con_handle)) continue; - if (channel->req_seq != 0xff){ - log_info("try to send s-frame"); + if (channel->send_supervisor_frame_receiver_ready){ + channel->send_supervisor_frame_receiver_ready = 0;; + log_info("Send S-Frame: RR %u", channel->req_seq); uint16_t control = l2cap_encanced_control_field_for_supevisor_frame( L2CAP_SUPERVISORY_FUNCTION_RR_RECEIVER_READY, 0, 0, channel->req_seq); - channel->req_seq = 0xff; l2cap_ertm_send_supervisor_frame(channel, control); } #endif @@ -1130,10 +1130,6 @@ static l2cap_channel_t * l2cap_create_channel_entry(btstack_packet_handler_t pac channel->remote_sig_id = L2CAP_SIG_ID_INVALID; channel->local_sig_id = L2CAP_SIG_ID_INVALID; -#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE - channel->req_seq = 0xff; -#endif - return channel; } #endif @@ -2442,6 +2438,7 @@ static void l2cap_acl_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa if (l2cap_channel->expected_tx_seq == tx_seq){ log_info("Received expected frame with TxSeq == ExpectedTxSeq == %02u", tx_seq); l2cap_channel->req_seq = tx_seq; + l2cap_channel->send_supervisor_frame_receiver_ready = 1; l2cap_channel->expected_tx_seq = l2cap_next_ertm_seq_nr(l2cap_channel->expected_tx_seq); uint16_t sdu_length; uint16_t segment_length; diff --git a/src/l2cap.h b/src/l2cap.h index 1f967196a..3c034b800 100644 --- a/src/l2cap.h +++ b/src/l2cap.h @@ -207,16 +207,19 @@ typedef struct { uint8_t local_max_transmit; uint8_t remote_max_transmit; - // if ertm is not mandatory, allow fallback to L2CAP Basic Mode + // if ertm is not mandatory, allow fallback to L2CAP Basic Mode - flag uint8_t ertm_mandatory; + // receiver: send RR frame - flag + uint8_t send_supervisor_frame_receiver_ready; + // sender: next seq nr used for sending uint8_t next_tx_seq; // receiver: value of tx_seq in next expected i-frame uint8_t expected_tx_seq; - // receiver: request transmiissoin with tx_seq = req_seq and ack up to and including req_seq - 1, 0xff if no ack to send + // receiver: request transmiissoin with tx_seq = req_seq and ack up to and including req_seq uint8_t req_seq; // max um out-of-order packets // tx_window