Skip to content

Commit

Permalink
Merge branch 'bugfix/config_tpoll_fail' into 'master'
Browse files Browse the repository at this point in the history
Bugfix/config tpoll fail

Closes BTQABR2023-40 and BTQABR2023-101

See merge request espressif/esp-idf!25846
  • Loading branch information
wmy-espressif committed Sep 25, 2023
2 parents 23095c7 + 87af877 commit d637880
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32
4 changes: 4 additions & 0 deletions components/bt/host/bluedroid/api/esp_gap_bt_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ esp_err_t esp_bt_gap_set_qos(esp_bd_addr_t remote_bda, uint32_t t_poll)
return ESP_ERR_INVALID_STATE;
}

if (t_poll < ESP_BT_GAP_TPOLL_MIN || t_poll > ESP_BT_GAP_TPOLL_MAX) {
return ESP_ERR_INVALID_ARG;
}

msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SET_QOS;
Expand Down
5 changes: 5 additions & 0 deletions components/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ typedef enum {
#define ESP_BT_GAP_MIN_INQ_LEN (0x01) /*!< Minimum inquiry duration, unit is 1.28s */
#define ESP_BT_GAP_MAX_INQ_LEN (0x30) /*!< Maximum inquiry duration, unit is 1.28s */

/** Minimum, Default and Maximum poll interval **/
#define ESP_BT_GAP_TPOLL_MIN (0x0006) /*!< Minimum poll interval, unit is 625 microseconds */
#define ESP_BT_GAP_TPOLL_DFT (0x0028) /*!< Default poll interval, unit is 625 microseconds */
#define ESP_BT_GAP_TPOLL_MAX (0x1000) /*!< Maximum poll interval, unit is 625 microseconds */

/// GAP state callback parameters
typedef union {
/**
Expand Down
14 changes: 7 additions & 7 deletions components/bt/host/bluedroid/bta/dm/bta_dm_qos.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
void bta_dm_set_qos(tBTA_DM_MSG *p_data)
{
FLOW_SPEC p_flow = {
.qos_flags = 0, /* TBD */
.service_type = GUARANTEED, /* see below */
.token_rate = 0, /* bytes/second */
.token_bucket_size = 0, /* bytes */
.peak_bandwidth = 0, /* bytes/second */
.latency = 625 * p_data->qos_set.t_poll, /* microseconds */
.delay_variation = 0xFFFFFFFF /* microseconds */
.qos_flags = 0, /* TBD */
.service_type = NO_TRAFFIC, /* service_type */
.token_rate = 0, /* bytes/second */
.token_bucket_size = 0, /* bytes */
.peak_bandwidth = 0, /* bytes/second */
.latency = 625 * p_data->qos_set.t_poll, /* microseconds */
.delay_variation = 0xFFFFFFFF /* microseconds */
};

tBTM_STATUS status = BTM_SetQoS (p_data->qos_set.bd_addr, &p_flow, p_data->qos_set.p_cb);
Expand Down
38 changes: 17 additions & 21 deletions components/bt/host/bluedroid/stack/btm/btm_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2659,37 +2659,33 @@ void btm_acl_connected(BD_ADDR bda, UINT16 handle, UINT8 link_type, UINT8 enc_mo
*******************************************************************************/
void btm_acl_disconnected(UINT16 handle, UINT8 reason)
{
BOOLEAN need_report = TRUE;

/* Report BR/EDR ACL disconnection result to upper layer */
tACL_CONN *conn = btm_handle_to_acl(handle);
if (conn) {
#if BLE_INCLUDED == TRUE
if (conn->transport == BT_TRANSPORT_BR_EDR)
#endif
{
tBTM_ACL_LINK_STAT_EVENT_DATA evt_data = {
.event = BTM_ACL_DISCONN_CMPL_EVT,
.link_act.disconn_cmpl.reason = reason,
.link_act.disconn_cmpl.handle = handle,
};
bdcpy(evt_data.link_act.disconn_cmpl.bd_addr, conn->remote_addr);
btm_acl_link_stat_report(&evt_data);
}
}

#if BTM_SCO_INCLUDED == TRUE
/* If L2CAP doesn't know about it, send it to SCO */
if (!l2c_link_hci_disc_comp (handle, reason)) {
btm_sco_removed (handle, reason);
need_report = FALSE;
}
#else
l2c_link_hci_disc_comp(handle, reason);
#endif /* BTM_SCO_INCLUDED */

if (need_report) {
/* Report BR/EDR ACL disconnection result to upper layer */
tACL_CONN *conn = btm_handle_to_acl(handle);
if (conn) {
#if BLE_INCLUDED == TRUE
if (conn->transport == BT_TRANSPORT_BR_EDR)
#endif
{
tBTM_ACL_LINK_STAT_EVENT_DATA evt_data = {
.event = BTM_ACL_DISCONN_CMPL_EVT,
.link_act.disconn_cmpl.reason = reason,
.link_act.disconn_cmpl.handle = handle,
};
bdcpy(evt_data.link_act.disconn_cmpl.bd_addr, conn->remote_addr);
btm_acl_link_stat_report(&evt_data);
}
}
}

#if (SMP_INCLUDED == TRUE)
/* Notify security manager */
btm_sec_disconnected(handle, reason);
Expand Down

0 comments on commit d637880

Please sign in to comment.