l2cap: provide access to number of available credits in cbm/ecbm

This commit is contained in:
Matthias Ringwald 2024-08-14 11:26:45 +02:00
parent 075e5583df
commit 60a1ee1b36
3 changed files with 32 additions and 0 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## Unreleased
### Added
- L2CAP: provide access to number of available credits in CBM/ECBM
- HFP HF: support Apple Accessory information with:
- hfp_hf_apple_set_identification
- hfp_hf_apple_set_battery_level

View File

@ -5250,6 +5250,15 @@ static void l2cap_credit_based_notify_channel_can_send(l2cap_channel_t *channel)
log_debug("le can send now, local_cid 0x%x", channel->local_cid);
l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CAN_SEND_NOW);
}
static uint16_t l2cap_credit_based_available_credits(uint16_t local_cid){
l2cap_channel_t * channel = l2cap_get_channel_for_local_cid(local_cid);
if (channel != NULL) {
return channel->credits_outgoing;
}
return 0;
}
#endif
#ifdef ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
@ -5485,6 +5494,10 @@ uint8_t l2cap_cbm_create_channel(btstack_packet_handler_t packet_handler, hci_co
uint8_t l2cap_cbm_provide_credits(uint16_t local_cid, uint16_t credits){
return l2cap_credit_based_provide_credits(local_cid, credits);
}
uint16_t l2cap_cbm_available_credits(uint16_t local_cid){
return l2cap_credit_based_available_credits(local_cid);
}
#endif
#ifdef ENABLE_L2CAP_ENHANCED_CREDIT_BASED_FLOW_CONTROL_MODE
@ -5719,6 +5732,10 @@ uint8_t l2cap_ecbm_reconfigure_channels(uint8_t num_cids, uint16_t * local_cids,
uint8_t l2cap_ecbm_provide_credits(uint16_t local_cid, uint16_t credits){
return l2cap_credit_based_provide_credits(local_cid, credits);
}
uint16_t l2cap_ecbm_available_credits(uint16_t local_cid){
return l2cap_credit_based_available_credits(local_cid);
}
#endif
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE

View File

@ -702,6 +702,13 @@ uint8_t l2cap_cbm_create_channel(btstack_packet_handler_t packet_handler, hci_co
*/
uint8_t l2cap_cbm_provide_credits(uint16_t local_cid, uint16_t credits);
/**
* @brief Returns the number of credits provided by peer
* @param local_cid
* @return number of credits
*/
uint16_t l2cap_cbm_available_credits(uint16_t local_cid);
//
// L2CAP Connection-Oriented Channels in Enhanced Credit-Based Flow-Control Mode - ECBM
//
@ -813,6 +820,13 @@ uint8_t l2cap_ecbm_reconfigure_channels(uint8_t num_cids, uint16_t * local_cids,
*/
void l2cap_ecbm_trigger_pending_connection_responses(hci_con_handle_t con_handle);
/**
* @brief Returns the number of outgoing credits provided by peer
* @param local_cid
* @return number of credits
*/
uint16_t l2cap_ecbm_available_credits(uint16_t local_cid);
/**
* @brief De-Init L2CAP
*/