feat(bt/bluedroid): Report sniff interval to application layer

This commit is contained in:
xiongweichao 2024-09-19 14:36:31 +08:00
parent 0a935f1c1b
commit e5984120ac
5 changed files with 12 additions and 7 deletions

View File

@ -415,6 +415,7 @@ typedef union {
struct mode_chg_param { struct mode_chg_param {
esp_bd_addr_t bda; /*!< remote bluetooth device address */ esp_bd_addr_t bda; /*!< remote bluetooth device address */
esp_bt_pm_mode_t mode; /*!< PM mode */ esp_bt_pm_mode_t mode; /*!< PM mode */
uint16_t interval; /*!< Number of baseband slots. unit is 0.625ms */
} mode_chg; /*!< mode change event parameter struct */ } mode_chg; /*!< mode change event parameter struct */
/** /**

View File

@ -75,7 +75,7 @@ void bta_dm_init_pm(void)
{ {
memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs)); memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs));
/* if there are no power manger entries, so not register */ /* if there are no power manager entries, so not register */
if (p_bta_dm_pm_cfg[0].app_id != 0) { if (p_bta_dm_pm_cfg[0].app_id != 0) {
bta_sys_pm_register((tBTA_SYS_CONN_CBACK *)bta_dm_pm_cback); bta_sys_pm_register((tBTA_SYS_CONN_CBACK *)bta_dm_pm_cback);
@ -694,9 +694,9 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
#endif #endif
{ {
#if (BTM_SSR_INCLUDED == TRUE) #if (BTM_SSR_INCLUDED == TRUE)
/* Dont initiate Sniff if controller has alreay accepted /* Dont initiate Sniff if controller has already accepted
* remote sniff params. This avoid sniff loop issue with * remote sniff params. This avoid sniff loop issue with
* some agrresive headsets who use sniff latencies more than * some aggressive headsets who use sniff latencies more than
* DUT supported range of Sniff intervals.*/ * DUT supported range of Sniff intervals.*/
if ((mode == BTM_PM_MD_SNIFF) && (p_peer_dev->info & BTA_DM_DI_ACP_SNIFF)) { if ((mode == BTM_PM_MD_SNIFF) && (p_peer_dev->info & BTA_DM_DI_ACP_SNIFF)) {
APPL_TRACE_DEBUG("%s: already in remote initiate sniff", __func__); APPL_TRACE_DEBUG("%s: already in remote initiate sniff", __func__);
@ -917,7 +917,7 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
} else { } else {
#if (BTM_SSR_INCLUDED == TRUE) #if (BTM_SSR_INCLUDED == TRUE)
if (p_dev->prev_low) { if (p_dev->prev_low) {
/* need to send the SSR paramaters to controller again */ /* need to send the SSR parameters to controller again */
bta_dm_pm_ssr(p_dev->peer_bdaddr); bta_dm_pm_ssr(p_dev->peer_bdaddr);
} }
p_dev->prev_low = BTM_PM_STS_ACTIVE; p_dev->prev_low = BTM_PM_STS_ACTIVE;
@ -980,6 +980,7 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
) { ) {
tBTA_DM_SEC conn; tBTA_DM_SEC conn;
conn.mode_chg.mode = p_data->pm_status.status; conn.mode_chg.mode = p_data->pm_status.status;
conn.mode_chg.interval = p_data->pm_status.value;
bdcpy(conn.mode_chg.bd_addr, p_data->pm_status.bd_addr); bdcpy(conn.mode_chg.bd_addr, p_data->pm_status.bd_addr);
bta_dm_cb.p_sec_cback(BTA_DM_PM_MODE_CHG_EVT, (tBTA_DM_SEC *)&conn); bta_dm_cb.p_sec_cback(BTA_DM_PM_MODE_CHG_EVT, (tBTA_DM_SEC *)&conn);
} }

View File

@ -997,6 +997,7 @@ typedef struct {
typedef struct { typedef struct {
BD_ADDR bd_addr; /* BD address peer device. */ BD_ADDR bd_addr; /* BD address peer device. */
tBTA_PM_MODE mode; /* the new connection role */ tBTA_PM_MODE mode; /* the new connection role */
UINT16 interval; /* Number of baseband slots */
} tBTA_DM_MODE_CHG; } tBTA_DM_MODE_CHG;
typedef struct { typedef struct {

View File

@ -625,6 +625,7 @@ static void btc_dm_pm_mode_chg_evt(tBTA_DM_MODE_CHG *p_mode_chg)
msg->act = BTC_GAP_BT_MODE_CHG_EVT; msg->act = BTC_GAP_BT_MODE_CHG_EVT;
memcpy(param.mode_chg.bda, p_mode_chg->bd_addr, ESP_BD_ADDR_LEN); memcpy(param.mode_chg.bda, p_mode_chg->bd_addr, ESP_BD_ADDR_LEN);
param.mode_chg.mode = p_mode_chg->mode; param.mode_chg.mode = p_mode_chg->mode;
param.mode_chg.interval= p_mode_chg->interval;
memcpy(msg->arg, &param, sizeof(esp_bt_gap_cb_param_t)); memcpy(msg->arg, &param, sizeof(esp_bt_gap_cb_param_t));
ret = btc_inter_profile_call(msg); ret = btc_inter_profile_call(msg);

View File

@ -99,7 +99,8 @@ static void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
/* when GAP mode changed, this event comes */ /* when GAP mode changed, this event comes */
case ESP_BT_GAP_MODE_CHG_EVT: case ESP_BT_GAP_MODE_CHG_EVT:
ESP_LOGI(BT_AV_TAG, "ESP_BT_GAP_MODE_CHG_EVT mode: %d", param->mode_chg.mode); ESP_LOGI(BT_AV_TAG, "ESP_BT_GAP_MODE_CHG_EVT mode: %d, interval: %.2f ms",
param->mode_chg.mode, param->mode_chg.interval * 0.625);
break; break;
/* when ACL connection completed, this event comes */ /* when ACL connection completed, this event comes */
case ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT: case ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT: