mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-01 04:20:33 +00:00
l2cap: split l2cap_run into sub statemachines
This commit is contained in:
parent
67c6c9dce6
commit
ea6a43fa4b
69
src/l2cap.c
69
src/l2cap.c
@ -50,6 +50,7 @@
|
||||
#include "hci_dump.h"
|
||||
#include "bluetooth_sdp.h"
|
||||
#include "bluetooth_psm.h"
|
||||
#include "btstack_bool.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_event.h"
|
||||
#include "btstack_memory.h"
|
||||
@ -1640,11 +1641,7 @@ static void l2cap_run_for_classic_channel(l2cap_channel_t * channel){
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: L2CAP_RUN
|
||||
// process outstanding signaling tasks
|
||||
static void l2cap_run(void){
|
||||
|
||||
// log_info("l2cap_run: entered");
|
||||
static void l2cap_run_signaling_response() {
|
||||
|
||||
// check pending signaling responses
|
||||
while (signaling_responses_pending){
|
||||
@ -1724,13 +1721,12 @@ static void l2cap_run(void){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(ENABLE_CLASSIC) || defined(ENABLE_BLE)
|
||||
btstack_linked_list_iterator_t it;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
|
||||
static bool l2ap_run_ertm(void){
|
||||
// send l2cap information request if neccessary
|
||||
btstack_linked_list_iterator_t it;
|
||||
hci_connections_get_iterator(&it);
|
||||
while(btstack_linked_list_iterator_has_next(&it)){
|
||||
hci_connection_t * connection = (hci_connection_t *) btstack_linked_list_iterator_next(&it);
|
||||
@ -1740,25 +1736,16 @@ static void l2cap_run(void){
|
||||
uint8_t sig_id = l2cap_next_sig_id();
|
||||
uint8_t info_type = L2CAP_INFO_TYPE_EXTENDED_FEATURES_SUPPORTED;
|
||||
l2cap_send_signaling_packet(connection->con_handle, INFORMATION_REQUEST, sig_id, info_type);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_CLASSIC
|
||||
btstack_linked_list_iterator_init(&it, &l2cap_channels);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
|
||||
l2cap_channel_t * channel = (l2cap_channel_t *) btstack_linked_list_iterator_next(&it);
|
||||
|
||||
if (channel->channel_type != L2CAP_CHANNEL_TYPE_CLASSIC) continue;
|
||||
|
||||
// log_info("l2cap_run: channel %p, state %u, var 0x%02x", channel, channel->state, channel->state_var);
|
||||
l2cap_run_for_classic_channel(channel);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LE_DATA_CHANNELS
|
||||
static void l2cap_run_le_data_channels(void){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, &l2cap_channels);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
uint16_t mps;
|
||||
@ -1827,8 +1814,44 @@ static void l2cap_run(void){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: L2CAP_RUN
|
||||
// process outstanding signaling tasks
|
||||
static void l2cap_run(void){
|
||||
|
||||
// log_info("l2cap_run: entered");
|
||||
l2cap_run_signaling_response();
|
||||
|
||||
bool done;
|
||||
|
||||
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
|
||||
done = l2ap_run_ertm();
|
||||
if (done) return;
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_CLASSIC) || defined(ENABLE_BLE)
|
||||
btstack_linked_list_iterator_t it;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_CLASSIC
|
||||
btstack_linked_list_iterator_init(&it, &l2cap_channels);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
|
||||
l2cap_channel_t * channel = (l2cap_channel_t *) btstack_linked_list_iterator_next(&it);
|
||||
|
||||
if (channel->channel_type != L2CAP_CHANNEL_TYPE_CLASSIC) continue;
|
||||
|
||||
// log_info("l2cap_run: channel %p, state %u, var 0x%02x", channel, channel->state, channel->state_var);
|
||||
l2cap_run_for_classic_channel(channel);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LE_DATA_CHANNELS
|
||||
l2cap_run_le_data_channels();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BLE
|
||||
// send l2cap con paramter update if necessary
|
||||
hci_connections_get_iterator(&it);
|
||||
|
Loading…
x
Reference in New Issue
Block a user