feat(nimble): Added option to disable automatically sending extra credits to peer

This commit is contained in:
Sumeet Singh
2024-10-29 19:23:36 +05:30
parent b2f4081e44
commit 0ca073c7f4
2 changed files with 15 additions and 2 deletions
+2 -2
View File
@@ -283,7 +283,7 @@ ble_l2cap_coc_rx_fn(struct ble_l2cap_chan *chan)
* However, we still have buffer to for next LE Frame so lets give one more
* credit to peer so it can send us full SDU
*/
if (rx->credits == 0) {
if (chan->disable_auto_credit_update == false && rx->credits == 0) {
/* Remote did not send full SDU. Lets give him one more credits to do
* so since we have still buffer to handle it
*/
@@ -598,7 +598,7 @@ ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx)
/* We want to back only that much credits which remote side is missing
* to be able to send complete SDU.
*/
if (chan->coc_rx.credits < c->initial_credits) {
if (chan->disable_auto_credit_update == false && chan->coc_rx.credits < c->initial_credits) {
ble_hs_unlock();
ble_l2cap_sig_le_credits(chan->conn_handle, chan->scid,
c->initial_credits - chan->coc_rx.credits);
+13
View File
@@ -92,6 +92,19 @@ struct ble_l2cap_chan {
struct ble_l2cap_coc_endpoint coc_rx;
struct ble_l2cap_coc_endpoint coc_tx;
uint16_t initial_credits;
/**
* Disable automatically sending credits to a remote
*
* This field disables automatically sending extra credit to a
* remote that has exhausted all of its available credits.
* Setting this field to "true" will enable behaviour to
* "not automatically send credits to a peer whose credits are exhausted"
* Setting this field to "false" will enable behaviour to
* "automatically send credits to a peer whose credits are exhausted"
* this behaviour.
*
*/
bool disable_auto_credit_update;
ble_l2cap_event_fn *cb;
void *cb_arg;
#endif