l2cap: allow to set the max LE MTU

This commit is contained in:
Matthias Ringwald 2018-01-30 19:01:33 +01:00
parent 8f37572a30
commit 25818320b7
2 changed files with 14 additions and 0 deletions

View File

@ -151,6 +151,7 @@ static uint8_t fixed_channel_tail_index = FIXED_CHANNEL_FIFO_INVALID_INDEX;
#ifdef ENABLE_BLE
// only used for connection parameter update events
static btstack_packet_handler_t l2cap_event_packet_handler;
static uint16_t l2cap_le_custom_max_mtu;
#endif
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
@ -773,6 +774,7 @@ void l2cap_init(void){
#ifdef ENABLE_BLE
l2cap_event_packet_handler = NULL;
l2cap_le_custom_max_mtu = 0;
#endif
memset(fixed_channels, 0, sizeof(fixed_channels));
int i;
@ -1207,9 +1209,16 @@ uint16_t l2cap_max_mtu(void){
}
uint16_t l2cap_max_le_mtu(void){
if (l2cap_le_custom_max_mtu != 0) return l2cap_le_custom_max_mtu;
return l2cap_max_mtu();
}
void l2cap_set_max_le_mtu(uint16_t max_mtu){
if (max_mtu < l2cap_max_mtu()){
l2cap_le_custom_max_mtu = max_mtu;
}
}
#ifdef ENABLE_CLASSIC
static uint16_t l2cap_setup_options_mtu(uint8_t * config_options, uint16_t mtu){

View File

@ -394,6 +394,11 @@ uint16_t l2cap_max_mtu(void);
*/
uint16_t l2cap_max_le_mtu(void);
/**
* @brief Set the max MTU for LE connections, if not set l2cap_max_mtu() will be used.
*/
void l2cap_set_max_le_mtu(uint16_t max_mtu);
/**
* @brief Creates L2CAP channel to the PSM of a remote device with baseband address. A new baseband connection will be initiated if necessary.
* @param packet_handler