l2cap.c (7d5c2f20da25e56e90bc87f1f8b57caba59706da) | l2cap.c (4fc83f45ae1d133397ab7f645163081cf036bb7a) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2103 unchanged lines hidden (view full) --- 2112 l2cap_run(); 2113} 2114#endif 2115 2116static bool l2cap_channel_ready_to_send(l2cap_channel_t * channel){ 2117 switch (channel->channel_type){ 2118#ifdef ENABLE_CLASSIC 2119 case L2CAP_CHANNEL_TYPE_CLASSIC: | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2103 unchanged lines hidden (view full) --- 2112 l2cap_run(); 2113} 2114#endif 2115 2116static bool l2cap_channel_ready_to_send(l2cap_channel_t * channel){ 2117 switch (channel->channel_type){ 2118#ifdef ENABLE_CLASSIC 2119 case L2CAP_CHANNEL_TYPE_CLASSIC: |
2120 if (channel->state != L2CAP_STATE_OPEN) return false; |
|
2120#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE 2121 // send if we have more data and remote windows isn't full yet 2122 if (channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION) { 2123 if (channel->unacked_frames >= btstack_min(channel->num_stored_tx_frames, channel->remote_tx_window_size)) return false; 2124 return hci_can_send_acl_classic_packet_now() != 0; 2125 } 2126#endif 2127 if (!channel->waiting_for_can_send_now) return false; 2128 return (hci_can_send_acl_classic_packet_now() != 0); 2129 case L2CAP_CHANNEL_TYPE_CONNECTIONLESS: 2130 if (!channel->waiting_for_can_send_now) return false; 2131 return hci_can_send_acl_classic_packet_now() != 0; 2132#endif 2133#ifdef ENABLE_BLE 2134 case L2CAP_CHANNEL_TYPE_LE_FIXED: 2135 if (!channel->waiting_for_can_send_now) return false; 2136 return hci_can_send_acl_le_packet_now() != 0; 2137#ifdef ENABLE_LE_DATA_CHANNELS 2138 case L2CAP_CHANNEL_TYPE_LE_DATA_CHANNEL: | 2121#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE 2122 // send if we have more data and remote windows isn't full yet 2123 if (channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION) { 2124 if (channel->unacked_frames >= btstack_min(channel->num_stored_tx_frames, channel->remote_tx_window_size)) return false; 2125 return hci_can_send_acl_classic_packet_now() != 0; 2126 } 2127#endif 2128 if (!channel->waiting_for_can_send_now) return false; 2129 return (hci_can_send_acl_classic_packet_now() != 0); 2130 case L2CAP_CHANNEL_TYPE_CONNECTIONLESS: 2131 if (!channel->waiting_for_can_send_now) return false; 2132 return hci_can_send_acl_classic_packet_now() != 0; 2133#endif 2134#ifdef ENABLE_BLE 2135 case L2CAP_CHANNEL_TYPE_LE_FIXED: 2136 if (!channel->waiting_for_can_send_now) return false; 2137 return hci_can_send_acl_le_packet_now() != 0; 2138#ifdef ENABLE_LE_DATA_CHANNELS 2139 case L2CAP_CHANNEL_TYPE_LE_DATA_CHANNEL: |
2140 if (channel->state != L2CAP_STATE_OPEN) return false; |
|
2139 if (channel->send_sdu_buffer == NULL) return false; 2140 if (channel->credits_outgoing == 0u) return false; 2141 return hci_can_send_acl_le_packet_now() != 0; 2142#endif 2143#endif 2144 default: 2145 return false; 2146 } --- 1183 unchanged lines hidden (view full) --- 3330 return 0; 3331 } 3332 return 1; 3333} 3334#endif 3335 3336#ifdef ENABLE_CLASSIC 3337static void l2cap_acl_classic_handler_for_channel(l2cap_channel_t * l2cap_channel, uint8_t * packet, uint16_t size){ | 2141 if (channel->send_sdu_buffer == NULL) return false; 2142 if (channel->credits_outgoing == 0u) return false; 2143 return hci_can_send_acl_le_packet_now() != 0; 2144#endif 2145#endif 2146 default: 2147 return false; 2148 } --- 1183 unchanged lines hidden (view full) --- 3332 return 0; 3333 } 3334 return 1; 3335} 3336#endif 3337 3338#ifdef ENABLE_CLASSIC 3339static void l2cap_acl_classic_handler_for_channel(l2cap_channel_t * l2cap_channel, uint8_t * packet, uint16_t size){ |
3340 3341 // forward data only in OPEN state 3342 if (l2cap_channel->state != L2CAP_STATE_OPEN) return; 3343 |
|
3338#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE 3339 if (l2cap_channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION){ 3340 3341 int fcs_size = l2cap_channel->fcs_option ? 2 : 0; 3342 3343 // assert control + FCS fields are inside 3344 if (size < COMPLETE_L2CAP_HEADER+2+fcs_size) return; 3345 --- 859 unchanged lines hidden --- | 3344#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE 3345 if (l2cap_channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION){ 3346 3347 int fcs_size = l2cap_channel->fcs_option ? 2 : 0; 3348 3349 // assert control + FCS fields are inside 3350 if (size < COMPLETE_L2CAP_HEADER+2+fcs_size) return; 3351 --- 859 unchanged lines hidden --- |