mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
Merge branch 'master' into ble-api-cleanup
This commit is contained in:
commit
c0be408cdc
@ -1251,9 +1251,6 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
|
||||
case L2CAP_DATA_PACKET:
|
||||
// process l2cap packet...
|
||||
err = l2cap_send_internal(channel, data, length);
|
||||
if (err == BTSTACK_ACL_BUFFERS_FULL) {
|
||||
l2cap_block_new_credits(1);
|
||||
}
|
||||
break;
|
||||
case RFCOMM_DATA_PACKET:
|
||||
// process l2cap packet...
|
||||
@ -1374,10 +1371,6 @@ static void daemon_retry_parked(void){
|
||||
// ... try sending again
|
||||
socket_connection_retry_parked();
|
||||
|
||||
if (!socket_connection_has_parked_connections()){
|
||||
l2cap_block_new_credits(0);
|
||||
}
|
||||
|
||||
// unlock mutex
|
||||
retry_mutex = 0;
|
||||
}
|
||||
|
@ -323,7 +323,6 @@ static void rfcomm_channel_initialize(rfcomm_channel_t *channel, rfcomm_multiple
|
||||
|
||||
channel->credits_incoming = 0;
|
||||
channel->credits_outgoing = 0;
|
||||
channel->packets_granted = 0;
|
||||
|
||||
// set defaults for port configuration (even for services)
|
||||
rfcomm_rpn_data_set_defaults(&channel->rpn_data);
|
||||
@ -884,9 +883,7 @@ static int rfcomm_multiplexer_hci_event_handler(uint8_t *packet, uint16_t size){
|
||||
l2cap_cid = READ_BT_16(packet, 2);
|
||||
multiplexer = rfcomm_multiplexer_for_l2cap_cid(l2cap_cid);
|
||||
if (!multiplexer) break;
|
||||
// log_info("L2CAP_EVENT_CREDITS: %u (now %u)", packet[4], multiplexer->l2cap_credits);
|
||||
|
||||
// new credits, continue with signaling
|
||||
rfcomm_run();
|
||||
|
||||
if (multiplexer->state != RFCOMM_MULTIPLEXER_OPEN) break;
|
||||
@ -1128,17 +1125,12 @@ static void rfcomm_hand_out_credits(void){
|
||||
// log_info("RFCOMM_EVENT_CREDITS: multiplexer not open");
|
||||
continue;
|
||||
}
|
||||
if (channel->packets_granted) {
|
||||
// log_info("RFCOMM_EVENT_CREDITS: already packets granted");
|
||||
continue;
|
||||
}
|
||||
if (!channel->credits_outgoing) {
|
||||
// log_info("RFCOMM_EVENT_CREDITS: no outgoing credits");
|
||||
continue;
|
||||
}
|
||||
// channel open, multiplexer has l2cap credits and we didn't hand out credit before -> go!
|
||||
// log_info("RFCOMM_EVENT_CREDITS: 1");
|
||||
channel->packets_granted += 1;
|
||||
rfcomm_emit_credits(channel, 1);
|
||||
}
|
||||
}
|
||||
@ -1982,17 +1974,11 @@ int rfcomm_send_prepared(uint16_t rfcomm_cid, uint16_t len){
|
||||
|
||||
// send might cause l2cap to emit new credits, update counters first
|
||||
channel->credits_outgoing--;
|
||||
int packets_granted_decreased = 0;
|
||||
if (channel->packets_granted) {
|
||||
channel->packets_granted--;
|
||||
packets_granted_decreased++;
|
||||
}
|
||||
|
||||
int result = rfcomm_send_uih_prepared(channel->multiplexer, channel->dlci, len);
|
||||
|
||||
if (result != 0) {
|
||||
channel->credits_outgoing++;
|
||||
channel->packets_granted += packets_granted_decreased;
|
||||
log_info("rfcomm_send_internal: error %d", result);
|
||||
return result;
|
||||
}
|
||||
|
@ -239,9 +239,6 @@ typedef struct {
|
||||
uint8_t outgoing;
|
||||
uint8_t dlci;
|
||||
|
||||
// number of packets granted to client
|
||||
uint8_t packets_granted;
|
||||
|
||||
// credits for outgoing traffic
|
||||
uint8_t credits_outgoing;
|
||||
|
||||
|
24
src/l2cap.c
24
src/l2cap.c
@ -78,7 +78,6 @@ static linked_list_t l2cap_services;
|
||||
static linked_list_t l2cap_le_channels;
|
||||
static linked_list_t l2cap_le_services;
|
||||
static void (*packet_handler) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) = null_packet_handler;
|
||||
static int new_credits_blocked = 0;
|
||||
|
||||
static btstack_packet_handler_t attribute_protocol_packet_handler;
|
||||
static btstack_packet_handler_t security_protocol_packet_handler;
|
||||
@ -95,7 +94,6 @@ static int l2cap_channel_ready_for_open(l2cap_channel_t *channel);
|
||||
|
||||
|
||||
void l2cap_init(void){
|
||||
new_credits_blocked = 0;
|
||||
signaling_responses_pending = 0;
|
||||
|
||||
l2cap_channels = NULL;
|
||||
@ -192,8 +190,6 @@ static void l2cap_emit_connection_parameter_update_response(uint16_t handle, uin
|
||||
static void l2cap_emit_credits(l2cap_channel_t *channel, uint8_t credits) {
|
||||
|
||||
log_info("L2CAP_EVENT_CREDITS local_cid 0x%x credits %u", channel->local_cid, credits);
|
||||
// track credits
|
||||
channel->packets_granted += credits;
|
||||
|
||||
uint8_t event[5];
|
||||
event[0] = L2CAP_EVENT_CREDITS;
|
||||
@ -204,23 +200,14 @@ static void l2cap_emit_credits(l2cap_channel_t *channel, uint8_t credits) {
|
||||
l2cap_dispatch(channel, HCI_EVENT_PACKET, event, sizeof(event));
|
||||
}
|
||||
|
||||
void l2cap_block_new_credits(uint8_t blocked){
|
||||
new_credits_blocked = blocked;
|
||||
}
|
||||
|
||||
static void l2cap_hand_out_credits(void){
|
||||
|
||||
if (new_credits_blocked) return; // we're told not to. used by daemon
|
||||
|
||||
linked_list_iterator_t it;
|
||||
linked_list_iterator_init(&it, &l2cap_channels);
|
||||
while (linked_list_iterator_has_next(&it)){
|
||||
l2cap_channel_t * channel = (l2cap_channel_t *) linked_list_iterator_next(&it);
|
||||
if (channel->state != L2CAP_STATE_OPEN) continue;
|
||||
if (!hci_number_free_acl_slots_for_handle(channel->handle)) return;
|
||||
if (hci_number_outgoing_packets(channel->handle) < NR_BUFFERED_ACL_PACKETS && channel->packets_granted == 0) {
|
||||
l2cap_emit_credits(channel, 1);
|
||||
}
|
||||
l2cap_emit_credits(channel, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,12 +374,7 @@ int l2cap_send_prepared(uint16_t local_cid, uint16_t len){
|
||||
return BTSTACK_ACL_BUFFERS_FULL;
|
||||
}
|
||||
|
||||
if (channel->packets_granted){
|
||||
--channel->packets_granted;
|
||||
}
|
||||
|
||||
log_debug("l2cap_send_prepared cid 0x%02x, handle %u, 1 credit used, credits left %u;",
|
||||
local_cid, channel->handle, channel->packets_granted);
|
||||
log_debug("l2cap_send_prepared cid 0x%02x, handle %u, 1 credit used", local_cid, channel->handle);
|
||||
|
||||
uint8_t *acl_buffer = hci_get_outgoing_packet_buffer();
|
||||
|
||||
@ -783,7 +765,6 @@ uint8_t l2cap_create_channel(btstack_packet_handler_t channel_packet_handler, bd
|
||||
chan->packet_handler = channel_packet_handler;
|
||||
chan->remote_mtu = L2CAP_MINIMAL_MTU;
|
||||
chan->local_mtu = mtu;
|
||||
chan->packets_granted = 0;
|
||||
chan->local_cid = l2cap_next_local_cid();
|
||||
|
||||
// set initial state
|
||||
@ -1082,7 +1063,6 @@ static void l2cap_handle_connection_request(hci_con_handle_t handle, uint8_t sig
|
||||
channel->remote_cid = source_cid;
|
||||
channel->local_mtu = service->mtu;
|
||||
channel->remote_mtu = L2CAP_DEFAULT_MTU;
|
||||
channel->packets_granted = 0;
|
||||
channel->remote_sig_id = sig_id;
|
||||
channel->required_security_level = service->required_security_level;
|
||||
|
||||
|
@ -123,8 +123,6 @@ typedef struct {
|
||||
|
||||
gap_security_level_t required_security_level;
|
||||
|
||||
uint8_t packets_granted; // number of L2CAP/ACL packets client is allowed to send
|
||||
|
||||
uint8_t reason; // used in decline internal
|
||||
|
||||
timer_source_t rtx; // also used for ertx
|
||||
@ -164,8 +162,6 @@ typedef struct l2cap_signaling_response {
|
||||
} l2cap_signaling_response_t;
|
||||
|
||||
|
||||
void l2cap_block_new_credits(uint8_t blocked);
|
||||
|
||||
int l2cap_can_send_fixed_channel_packet_now(uint16_t handle);
|
||||
|
||||
// @deprecated use l2cap_can_send_fixed_channel_packet_now instead
|
||||
|
Loading…
x
Reference in New Issue
Block a user