Skip to content

Commit 79e8647

Browse files
jori-nordicaescolar
authored andcommitted
Bluetooth: L2CAP: clarify BT_L2CAP_STATUS_OUT
Makes it clearer what that bit means: If set, the channel has capacity to send at least one PDU. If unset, the channel ran out of credits and won't be able to send anything until the peer sends credits back. Also add debug logs. Signed-off-by: Jonathan Rico <[email protected]>
1 parent 61f834e commit 79e8647

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

include/zephyr/bluetooth/l2cap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ typedef enum bt_l2cap_chan_state {
120120

121121
/** @brief Status of L2CAP channel. */
122122
typedef enum bt_l2cap_chan_status {
123-
/** Channel output status */
123+
/** Channel can send at least one PDU */
124124
BT_L2CAP_STATUS_OUT,
125125

126126
/** @brief Channel shutdown status

subsys/bluetooth/host/l2cap.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,11 @@ static void l2cap_chan_tx_give_credits(struct bt_l2cap_le_chan *chan,
973973

974974
atomic_add(&chan->tx.credits, credits);
975975

976-
if (!atomic_test_and_set_bit(chan->chan.status, BT_L2CAP_STATUS_OUT) &&
977-
chan->chan.ops->status) {
978-
chan->chan.ops->status(&chan->chan, chan->chan.status);
976+
if (!atomic_test_and_set_bit(chan->chan.status, BT_L2CAP_STATUS_OUT)) {
977+
LOG_DBG("chan %p unpaused", chan);
978+
if (chan->chan.ops->status) {
979+
chan->chan.ops->status(&chan->chan, chan->chan.status);
980+
}
979981
}
980982
}
981983

@@ -2045,11 +2047,11 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch,
20452047
return err;
20462048
}
20472049

2048-
/* Check if there is no credits left clear output status and notify its
2049-
* change.
2050-
*/
2050+
/* Notify channel user that it can't send anymore on this channel. */
20512051
if (!atomic_get(&ch->tx.credits)) {
2052+
LOG_DBG("chan %p paused", ch);
20522053
atomic_clear_bit(ch->chan.status, BT_L2CAP_STATUS_OUT);
2054+
20532055
if (ch->chan.ops->status) {
20542056
ch->chan.ops->status(&ch->chan, ch->chan.status);
20552057
}

0 commit comments

Comments
 (0)