l2cap-ertm: send tx packets from l2cap_run

This commit is contained in:
Matthias Ringwald 2017-07-17 15:06:38 +02:00
parent f0fb4cd727
commit 675e6881a7
2 changed files with 21 additions and 4 deletions

View File

@ -89,6 +89,7 @@
#endif
// prototypes
static void l2cap_run(void);
static void l2cap_hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void l2cap_acl_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size );
static void l2cap_notify_channel_can_send(void);
@ -591,8 +592,8 @@ static int l2cap_ertm_send(l2cap_channel_t * channel, uint8_t * data, uint16_t l
// update
channel->next_tx_seq = l2cap_next_ertm_seq_nr(channel->next_tx_seq);
l2cap_ertm_next_tx_write_index(channel);
// test sendiging it right away
l2cap_ertm_send_information_frame(channel, index);
// try to send
l2cap_run();
return 0;
}
#endif
@ -938,11 +939,24 @@ 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->tx_send_index != channel->tx_write_index){
// packet ready to send!
int index = channel->tx_send_index;
channel->tx_send_index++;
if (channel->tx_send_index >= channel->num_tx_buffers){
channel->tx_send_index = 0;
}
l2cap_ertm_send_information_frame(channel, index);
continue;
}
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);
l2cap_ertm_send_supervisor_frame(channel, control);
continue;
}
#endif

View File

@ -211,11 +211,14 @@ typedef struct {
// if ertm is not mandatory, allow fallback to L2CAP Basic Mode - flag
uint8_t ertm_mandatory;
// sender: buffer index to store tx packet
// sender: buffer index of oldest packet
uint8_t tx_read_index;
// sender: buffer index to store next tx packet
uint8_t tx_write_index;
// sender: buffer index of packet to send next
uint8_t tx_read_index;
uint8_t tx_send_index;
// sender: next seq nr used for sending
uint8_t next_tx_seq;