kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/fix_gattc_disc_crash' into 'master'
Bluedroid: configurable max gattc cache characteristic count See merge request espressif/esp-idf!19842pull/9950/head
commit
a5e19246df
|
@ -215,6 +215,14 @@ config BT_GATTC_ENABLE
|
|||
help
|
||||
This option can be close when the app work only on gatt server mode
|
||||
|
||||
config BT_GATTC_MAX_CACHE_CHAR
|
||||
int "Max gattc cache characteristic for discover"
|
||||
depends on BT_GATTC_ENABLE
|
||||
range 1 500
|
||||
default 40
|
||||
help
|
||||
Maximum GATTC cache characteristic count
|
||||
|
||||
config BT_GATTC_CACHE_NVS_FLASH
|
||||
bool "Save gattc cache data to nvs flash"
|
||||
depends on BT_GATTC_ENABLE
|
||||
|
|
|
@ -94,7 +94,7 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
|
|||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (max_nb_attr > ESP_GATT_ATTR_HANDLE_MAX) {
|
||||
LOG_ERROR("%s the number of attribute should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES\n");
|
||||
LOG_ERROR("The number of attribute should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES\n");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
|
|
@ -541,7 +541,6 @@ void bta_gattc_start_disc_char_dscp(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
|
|||
if (bta_gattc_discover_procedure(conn_id, p_srvc_cb, GATT_DISC_CHAR_DSCPT) != 0) {
|
||||
bta_gattc_char_dscpt_disc_cmpl(conn_id, p_srvc_cb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void bta_gattc_update_include_service(const list_t *services) {
|
||||
|
@ -693,7 +692,9 @@ static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_sr
|
|||
{
|
||||
tBTA_GATTC_ATTR_REC *p_rec = NULL;
|
||||
|
||||
if (--p_srvc_cb->total_char > 0) {
|
||||
/* Recursive function will cause BTU stack overflow when there are a large number of characteristic
|
||||
* without descriptor to discover. So replace it with while function */
|
||||
while (--p_srvc_cb->total_char > 0) {
|
||||
p_rec = p_srvc_cb->p_srvc_list + (++ p_srvc_cb->cur_char_idx);
|
||||
/* add the next characteristic into cache */
|
||||
bta_gattc_add_char_to_cache (p_srvc_cb,
|
||||
|
@ -701,11 +702,14 @@ static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_sr
|
|||
p_rec->s_handle,
|
||||
&p_rec->uuid,
|
||||
p_rec->property);
|
||||
/* start to discover next characteristic for descriptor */
|
||||
if (bta_gattc_discover_procedure(conn_id, p_srvc_cb, GATT_DISC_CHAR_DSCPT) == 0) {
|
||||
/* send att req and wait for att rsp */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* start discoverying next characteristic for char descriptor */
|
||||
bta_gattc_start_disc_char_dscp(conn_id, p_srvc_cb);
|
||||
} else
|
||||
/* all characteristic has been explored, start with next service if any */
|
||||
if (p_srvc_cb->total_char == 0) /* all characteristic has been explored, start with next service if any */
|
||||
{
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
APPL_TRACE_ERROR("all char has been explored");
|
||||
|
@ -772,7 +776,7 @@ static tBTA_GATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV *p_srvc_cb,
|
|||
/* allocate bigger buffer ?? */
|
||||
status = GATT_DB_FULL;
|
||||
|
||||
APPL_TRACE_ERROR("service not added, no resources or wrong state");
|
||||
APPL_TRACE_ERROR("service not added, no resources or wrong state, see CONFIG_BT_GATTC_MAX_CACHE_CHAR");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
@ -814,7 +818,7 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV *p_srvc_cb,
|
|||
}
|
||||
p_srvc_cb->next_avail_idx ++;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("char not added, no resources");
|
||||
APPL_TRACE_ERROR("char not added, no resources, see CONFIG_BT_GATTC_MAX_CACHE_CHAR");
|
||||
/* allocate bigger buffer ?? */
|
||||
status = BTA_GATT_DB_FULL;
|
||||
}
|
||||
|
|
|
@ -270,7 +270,6 @@ typedef struct {
|
|||
} tBTA_GATTC_ATTR_REC;
|
||||
|
||||
|
||||
#define BTA_GATTC_MAX_CACHE_CHAR 40
|
||||
#define BTA_GATTC_ATTR_LIST_SIZE (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))
|
||||
|
||||
#ifndef BTA_GATTC_CACHE_SRVR_SIZE
|
||||
|
@ -305,10 +304,10 @@ typedef struct {
|
|||
|
||||
tBTA_GATTC_ATTR_REC *p_srvc_list;
|
||||
UINT8 cur_srvc_idx;
|
||||
UINT8 cur_char_idx;
|
||||
UINT8 next_avail_idx;
|
||||
UINT16 cur_char_idx;
|
||||
UINT16 next_avail_idx;
|
||||
UINT8 total_srvc;
|
||||
UINT8 total_char;
|
||||
UINT16 total_char;
|
||||
UINT16 total_attr;
|
||||
UINT8 srvc_hdl_chg; /* service handle change indication pending */
|
||||
UINT16 attr_index; /* cahce NV saving/loading attribute index */
|
||||
|
|
|
@ -134,6 +134,12 @@
|
|||
#endif
|
||||
|
||||
//GATTC CACHE
|
||||
#ifdef CONFIG_BT_GATTC_MAX_CACHE_CHAR
|
||||
#define UC_BT_GATTC_MAX_CACHE_CHAR CONFIG_BT_GATTC_MAX_CACHE_CHAR
|
||||
#else
|
||||
#define UC_BT_GATTC_MAX_CACHE_CHAR 40
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_GATTC_CACHE_NVS_FLASH
|
||||
#define UC_BT_GATTC_CACHE_NVS_FLASH_ENABLED CONFIG_BT_GATTC_CACHE_NVS_FLASH
|
||||
#else
|
||||
|
|
|
@ -2247,6 +2247,10 @@ The maximum number of payload octets that the local device can receive in a sing
|
|||
#define BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_GATTC_MAX_CACHE_CHAR
|
||||
#define BTA_GATTC_MAX_CACHE_CHAR UC_BT_GATTC_MAX_CACHE_CHAR
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Tracing: Include trace header file here.
|
||||
|
|
Ładowanie…
Reference in New Issue