Merge branch 'bugfix/param_check_instant_tx_octets_adv_ubderrun_v3.3' into 'release/v3.3'

component/bt: add connect parameter, fix instant reverse, fix tx default octets, fix assert(1024,0)

See merge request espressif/esp-idf!9484
This commit is contained in:
Jiang Jiang Jian 2020-08-11 14:11:03 +08:00
commit 7e1c529b00
20 changed files with 229 additions and 9 deletions

View file

@ -50,9 +50,33 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
#if (BLE_INCLUDED == TRUE)
extern uint16_t L2CA_GetFreePktBufferNum_LE(void);
/**
* @brief This function is called to get currently sendable packets number on controller,
* the function is called only in BLE running core and single connection now.
*
* @return
* sendable packets number on controller
*
*/
uint16_t esp_ble_get_sendable_packets_num ()
uint16_t esp_ble_get_sendable_packets_num (void)
{
return L2CA_GetFreePktBufferNum_LE();
}
/**
* @brief This function is used to query the number of available buffers for the current connection.
* When you need to query the current available buffer number, it is recommended to use this API.
* @param[in] conn_id: current connection id.
*
* @return
* Number of available buffers for the current connection
*
*/
extern UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id);
uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid)
{
return L2CA_GetCurFreePktBufferNum_LE(connid);
}
#endif

View file

@ -431,6 +431,9 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
arg.write_char.value = value;
arg.write_char.write_type = write_type;
arg.write_char.auth_req = auth_req;
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -462,6 +465,10 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
arg.write_descr.write_type = write_type;
arg.write_descr.auth_req = auth_req;
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -274,6 +274,9 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
arg.send_ind.value_len = value_len;
arg.send_ind.value = value;
if(need_confirm == false){
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t),
btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -46,6 +46,7 @@ extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu);
#if (BLE_INCLUDED == TRUE)
extern uint16_t esp_ble_get_sendable_packets_num (void);
extern uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid);
#endif
#ifdef __cplusplus

View file

@ -31,7 +31,7 @@
#include "bta/bta_sys.h"
#include "bta/bta_gatt_api.h"
#include "bta_gattc_int.h"
#include "stack/l2c_api.h"
/*****************************************************************************
** Constants
*****************************************************************************/
@ -603,6 +603,10 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
memcpy(p_buf->p_value, p_value, len);
}
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
}
bta_sys_sendmsg(p_buf);
}
return;
@ -650,6 +654,10 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
memcpy(p_buf->p_value, p_data->p_value, p_data->len);
}
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
}
bta_sys_sendmsg(p_buf);
}
return;

View file

@ -35,6 +35,7 @@
#include "stack/btm_ble_api.h"
#include <string.h>
#include "osi/allocator.h"
#include "stack/l2c_api.h"
static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
@ -672,6 +673,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
p_msg->api_indicate.len,
p_msg->api_indicate.value);
} else {
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL);
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
p_msg->api_indicate.attr_id,
p_msg->api_indicate.len,

View file

@ -31,7 +31,7 @@
#include "bta/bta_gatt_api.h"
#include "bta_gatts_int.h"
#include "osi/allocator.h"
#include "stack/l2c_api.h"
/*****************************************************************************
** Constants
*****************************************************************************/
@ -426,6 +426,11 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
memcpy(p_buf->value, p_data, data_len);
}
if(need_confirm == false){
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
}
bta_sys_sendmsg(p_buf);
}
return;

View file

@ -219,6 +219,7 @@ void gatt_act_write (tGATT_CLCB *p_clcb, UINT8 sec_act)
if (p_attr) {
switch (p_clcb->op_subtype) {
case GATT_WRITE_NO_RSP:
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL);
p_clcb->s_handle = p_attr->handle;
op_code = (sec_act == GATT_SEC_SIGN_DATA) ? GATT_SIGN_CMD_WRITE : GATT_CMD_WRITE;
rt = gatt_send_write_msg(p_tcb,

View file

@ -29,6 +29,7 @@
#include "common/bt_target.h"
#include "stack/l2cdefs.h"
#include "stack/hcidefs.h"
#include "osi/fixed_queue.h"
/*****************************************************************************
** Constants
@ -1227,6 +1228,21 @@ extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transp
extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, UINT16 handle);
#define L2CA_GET_ATT_NUM 0
#define L2CA_ADD_BTC_NUM 1
#define L2CA_DECREASE_BTC_NUM 2
#define L2CA_ADD_BTU_NUM 3
#define L2CA_DECREASE_BTU_NUM 4
#define L2CA_BUFF_INI 5
#define L2CA_BUFF_DEINIT 6
typedef struct {
UINT16 conn_id;
UINT16 * get_num;
} tl2c_buff_param_t;
extern void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param);
#endif /* (BLE_INCLUDED == TRUE) */

View file

@ -73,7 +73,7 @@
#define L2CAP_DEFAULT_RETRANS_TOUT 2000 /* 2000 milliseconds */
#define L2CAP_DEFAULT_MONITOR_TOUT 12000 /* 12000 milliseconds */
#define L2CAP_FCR_ACK_TOUT 200 /* 200 milliseconds */
#define L2CAP_CACHE_ATT_ACL_NUM 10
/* Define the possible L2CAP channel states. The names of
** the states may seem a bit strange, but they are taken from
** the Bluetooth specification.
@ -165,6 +165,10 @@ typedef enum {
#define L2CAP_MAX_FCR_CFG_TRIES 2 /* Config attempts before disconnecting */
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK;
typedef struct {

View file

@ -36,6 +36,8 @@
#include "stack/btu.h"
#include "stack/btm_api.h"
#include "osi/allocator.h"
#include "gatt_int.h"
#include "freertos/semphr.h"
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
@ -1877,6 +1879,16 @@ UINT16 L2CA_GetFreePktBufferNum_LE(void)
{
return l2cb.controller_le_xmit_window;
}
UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id)
{
uint16_t num = 0;
tl2c_buff_param_t param;
param.conn_id = conn_id;
param.get_num = &num;
l2ble_update_att_acl_pkt_num(L2CA_GET_ATT_NUM, &param);
return num;
}
#endif
/*******************************************************************************
@ -2265,3 +2277,111 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
return (num_left);
}
/******************************************************************************
**
** Function update_acl_pkt_num
**
** Description Update the number of att acl packets to be sent in xmit_hold_q.
**
** Returns None
**
*******************************************************************************/
#if BLE_INCLUDED == TRUE
void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param)
{
static SemaphoreHandle_t buff_semaphore = NULL ;
static INT16 btc_buf;
static INT16 btu_buf;
if(buff_semaphore == NULL && type != L2CA_BUFF_INI){
L2CAP_TRACE_ERROR("%s buff_semaphore not init", __func__);
return;
}
switch (type)
{
case L2CA_ADD_BTC_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btc_buf ++;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_DECREASE_BTC_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btc_buf --;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_ADD_BTU_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btu_buf ++;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_DECREASE_BTU_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btu_buf --;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_GET_ATT_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
INT16 att_acl_pkt_num = 0;
INT16 att_max_num = 0;
*(param->get_num) = 0;
UINT8 tcb_idx = param->conn_id;
tGATT_TCB * p_tcb = gatt_get_tcb_by_idx(tcb_idx);
if (p_tcb == NULL){
L2CAP_TRACE_ERROR("%s not found p_tcb", __func__);
xSemaphoreGive(buff_semaphore);
break;
}
tL2C_LCB * p_lcb = l2cu_find_lcb_by_bd_addr (p_tcb->peer_bda, BT_TRANSPORT_LE);
if (p_lcb == NULL){
L2CAP_TRACE_ERROR("%s not found p_lcb", __func__);
xSemaphoreGive(buff_semaphore);
break;
}
fixed_queue_t * queue = p_lcb->p_fixed_ccbs[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q;
att_max_num = MIN(p_lcb->link_xmit_quota, L2CAP_CACHE_ATT_ACL_NUM);
if (queue == NULL){
L2CAP_TRACE_ERROR("%s not found queue", __func__);
xSemaphoreGive(buff_semaphore);
break;
}
att_acl_pkt_num = fixed_queue_length(queue);
if(att_acl_pkt_num < att_max_num){
if(btc_buf + btu_buf < att_max_num - att_acl_pkt_num){
*(param->get_num) = att_max_num - att_acl_pkt_num - (btc_buf + btu_buf);
}
}
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_BUFF_INI:{
btc_buf = 0;
btu_buf = 0;
buff_semaphore = xSemaphoreCreateBinary();
if (buff_semaphore == NULL) {
L2CAP_TRACE_ERROR("%s NO MEMORY", __func__);
break;
}
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_BUFF_DEINIT:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btc_buf = 0;
btu_buf = 0;
xSemaphoreGive(buff_semaphore);
vSemaphoreDelete(buff_semaphore);
buff_semaphore = NULL;
break;
}
default:
break;
}
}
#endif

View file

@ -1127,6 +1127,12 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf)
while ((l2cb.controller_xmit_window != 0) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota))
#endif
{
//need check flag: partial_segment_being_sent.
if ( (p_lcb->partial_segment_being_sent)
|| (p_lcb->link_state != LST_CONNECTED)
|| (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) {
break;
}
//L2CAP_TRACE_DEBUG("l2cu_get_next_buffer_to_send = %p",l2cu_get_next_buffer_to_send(p_lcb));
if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) == NULL) {
break;

View file

@ -880,6 +880,10 @@ void l2c_init (void)
if (l2cb.rcv_pending_q == NULL) {
L2CAP_TRACE_ERROR("%s unable to allocate memory for link layer control block", __func__);
}
#if BLE_INCLUDED == TRUE
l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL);
#endif
}
void l2c_free(void)
@ -889,6 +893,9 @@ void l2c_free(void)
#if L2C_DYNAMIC_MEMORY
FREE_AND_RESET(l2c_cb_ptr);
#endif
#if BLE_INCLUDED == TRUE
l2ble_update_att_acl_pkt_num(L2CA_BUFF_DEINIT, NULL);
#endif
}
/*******************************************************************************

View file

@ -3657,7 +3657,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
} else {
tL2C_LCB *p_lcb = p_ccb->p_lcb;
/* If this channel was not congested but it is congested now, tell the app */
if ((q_count > p_ccb->buff_quota) || (p_lcb && (p_ccb->local_cid == L2CAP_ATT_CID) && (p_lcb->link_xmit_quota > 0) && (p_lcb->link_xmit_quota <= p_lcb->sent_not_acked))) {
if (q_count > p_ccb->buff_quota || (p_lcb && (p_lcb->link_xmit_data_q) && (list_length(p_lcb->link_xmit_data_q) + q_count) > p_ccb->buff_quota)) {
p_ccb->cong_sent = TRUE;
if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb) {
L2CAP_TRACE_DEBUG ("L2CAP - Calling CongestionStatus_Cb (TRUE),CID:0x%04x,XmitQ:%u,Quota:%u",

@ -1 +1 @@
Subproject commit 1f1002a2c4589d1873fa41c49cb616208082cdb9
Subproject commit 425c7ca0e5ed0684260db123e673a1e7c78a749f

View file

@ -84,6 +84,20 @@ esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status);
*/
esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status);
/**
* @brief Enable BLE connection dynamic priority
* @attention If the parameter is true, BLE connection performance will be better but WiFi performance
* will be poorer. And vice versa.
* @param low_interval : true - Increase BLE connection priority to be higher than WiFi's when BLE
* connection interval is less or equal than 50 ms. The default value
* is false.
* false - not increace
* @param high_interval : true - Increase BLE connection priority to be higher than WiFi's when BLE
* connection interval is more than 50 ms. The default value is true.
* false - not increace
* @return : ESP_OK - success, other - failed
*/
esp_err_t esp_coex_ble_conn_dynamic_prio_enable(bool low_interval, bool high_interval);
#ifdef __cplusplus
}

View file

@ -1392,6 +1392,8 @@ PROVIDE ( g_rom_spiflash_chip = 0x3ffae270 );
PROVIDE ( hci_le_rd_rem_used_feats_cmd_handler = 0x400417b4 );
PROVIDE ( llcp_length_req_handler = 0x40043808 );
PROVIDE ( llcp_unknown_rsp_handler = 0x40043ba8 );
PROVIDE ( llcp_channel_map_req_handler = 0x4004291c );
PROVIDE ( llcp_con_up_req_handler = 0x400426f0 );
/*
These functions are xtos-related (or call xtos-related functions) and do not play well

@ -1 +1 @@
Subproject commit dab12d8e83eab47f7ee2698ba491a42c76f475d7
Subproject commit d615eeaadf55960eee64f44ca53fe0d50813dda1

View file

@ -504,7 +504,7 @@ static void throughput_client_task(void *param)
assert(res == pdTRUE);
} else {
if (is_connect) {
int free_buff_num = esp_ble_get_sendable_packets_num();
int free_buff_num = esp_ble_get_cur_sendable_packets_num(gl_profile_tab[PROFILE_A_APP_ID].conn_id);
if(free_buff_num > 0) {
for( ; free_buff_num > 0; free_buff_num--) {
// the app data set to 490 just for divided into two packages to send in the low layer

View file

@ -624,7 +624,7 @@ void throughput_server_task(void *param)
assert(res == pdTRUE);
} else {
if (is_connect) {
int free_buff_num = esp_ble_get_sendable_packets_num();
int free_buff_num = esp_ble_get_cur_sendable_packets_num(gl_profile_tab[PROFILE_A_APP_ID].conn_id);
if(free_buff_num > 0) {
for( ; free_buff_num > 0; free_buff_num--) {
esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_A_APP_ID].gatts_if, gl_profile_tab[PROFILE_A_APP_ID].conn_id,