mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
fix(bt/bluedroid): enable sniff power management for PBAP client
This commit is contained in:
@@ -125,15 +125,23 @@ tBTA_DM_RM *const p_bta_dm_rm_cfg = (tBTA_DM_RM *) &bta_dm_rm_cfg;
|
||||
#endif
|
||||
|
||||
#if (BTA_PAN_INCLUDED == TRUE)
|
||||
# define BTA_DM_NUM_PM_ENTRY (BTA_DM_NUM_PM_ENTRY_BASE + 3)
|
||||
# define BTA_DM_NUM_PM_PAN_ENTRY 3
|
||||
# define BTA_DM_NUM_PM_SPEC (BTA_DM_NUM_PM_SPEC_BASE + 2)
|
||||
# define BTA_DM_PM_PANU_SPEC_IDX BTA_DM_NUM_PM_SPEC_BASE
|
||||
# define BTA_DM_PM_NAP_SPEC_IDX (BTA_DM_NUM_PM_SPEC_BASE + 1)
|
||||
#else
|
||||
# define BTA_DM_NUM_PM_ENTRY BTA_DM_NUM_PM_ENTRY_BASE
|
||||
# define BTA_DM_NUM_PM_PAN_ENTRY 0
|
||||
# define BTA_DM_NUM_PM_SPEC BTA_DM_NUM_PM_SPEC_BASE
|
||||
#endif
|
||||
|
||||
#if (BTA_PBA_CLIENT_INCLUDED == TRUE)
|
||||
# define BTA_DM_NUM_PM_PBC_ENTRY 1
|
||||
#else
|
||||
# define BTA_DM_NUM_PM_PBC_ENTRY 0
|
||||
#endif
|
||||
|
||||
#define BTA_DM_NUM_PM_ENTRY (BTA_DM_NUM_PM_ENTRY_BASE + BTA_DM_NUM_PM_PAN_ENTRY + BTA_DM_NUM_PM_PBC_ENTRY)
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
|
||||
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1] = {
|
||||
@@ -155,6 +163,9 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1]
|
||||
, {BTA_ID_PAN, BTUI_PAN_ID_NAP, BTA_DM_PM_NAP_SPEC_IDX} /* NAP spec table */
|
||||
, {BTA_ID_PAN, BTUI_PAN_ID_GN, BTA_DM_PM_NAP_SPEC_IDX} /* GN reuses NAP spec table */
|
||||
#endif
|
||||
#if (BTA_PBA_CLIENT_INCLUDED == TRUE)
|
||||
, {BTA_ID_PBC, BTA_ALL_APP_ID, 2} /* pbc reuses ftc/opc spec table */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define BTA_DM_PM_SPEC_TO_OFFSET (197) /* timeout offset to avoid conflict with other bluedroid host */
|
||||
@@ -197,7 +208,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* FTC, OPC, JV : 2 */
|
||||
/* FTC, OPC, JV, PBC : 2 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
|
||||
@@ -25,6 +25,14 @@ static const char *type_pull_vcard_entry = "x-bt/vcard";
|
||||
#define TYPE_LEN_PULL_VCARD_LISTING 19
|
||||
#define TYPE_LEN_PULL_VCARD_ENTRY 11
|
||||
|
||||
static void bta_pba_client_pm_conn_close(tBTA_PBA_CLIENT_CCB *p_ccb)
|
||||
{
|
||||
if (p_ccb->pm_open) {
|
||||
bta_sys_conn_close(BTA_ID_PBC, p_ccb->allocated, p_ccb->bd_addr);
|
||||
p_ccb->pm_open = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void free_ccb(tBTA_PBA_CLIENT_CCB *p_ccb)
|
||||
{
|
||||
UINT8 sdp_seq;
|
||||
@@ -52,6 +60,8 @@ static void close_goepc_and_report(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_E
|
||||
conn.error = reason;
|
||||
bdcpy(conn.bd_addr, p_ccb->bd_addr);
|
||||
|
||||
bta_pba_client_pm_conn_close(p_ccb);
|
||||
|
||||
/* free ccb */
|
||||
free_ccb(p_ccb);
|
||||
|
||||
@@ -425,6 +435,7 @@ void bta_pba_client_api_req(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_DATA *p_
|
||||
if (ret != GOEP_SUCCESS) {
|
||||
goto error;
|
||||
}
|
||||
bta_sys_busy(BTA_ID_PBC, p_ccb->allocated, p_ccb->bd_addr);
|
||||
return;
|
||||
|
||||
error:
|
||||
@@ -550,6 +561,11 @@ void bta_pba_client_authenticate(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_DAT
|
||||
void bta_pba_client_connect(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_DATA *p_data)
|
||||
{
|
||||
tBTA_PBA_CLIENT_CONN conn;
|
||||
UNUSED(p_data);
|
||||
|
||||
bta_sys_conn_open(BTA_ID_PBC, p_ccb->allocated, p_ccb->bd_addr);
|
||||
p_ccb->pm_open = TRUE;
|
||||
|
||||
conn.handle = p_ccb->allocated;
|
||||
conn.peer_supported_repo = p_ccb->peer_supported_repo;
|
||||
conn.peer_supported_feat = p_ccb->peer_supported_feat;
|
||||
@@ -680,6 +696,7 @@ void bta_pba_client_response_final(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_D
|
||||
}
|
||||
bta_pba_client_report_get_headers(p_ccb, p_data->goep_response.pkt, &info, TRUE);
|
||||
p_data->goep_response.pkt = NULL;
|
||||
bta_sys_idle(BTA_ID_PBC, p_ccb->allocated, p_ccb->bd_addr);
|
||||
return;
|
||||
}
|
||||
/* unexpected response code or body data not found */
|
||||
@@ -687,6 +704,7 @@ void bta_pba_client_response_final(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_D
|
||||
report_error_data_event(p_ccb, reason);
|
||||
osi_free(p_data->goep_response.pkt);
|
||||
p_data->goep_response.pkt = NULL;
|
||||
bta_sys_idle(BTA_ID_PBC, p_ccb->allocated, p_ccb->bd_addr);
|
||||
|
||||
/* state machine is good, don't goto error */
|
||||
}
|
||||
@@ -699,6 +717,7 @@ void bta_pba_client_response_final(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_D
|
||||
report_error_data_event(p_ccb, reason);
|
||||
}
|
||||
osi_free(p_data->goep_response.pkt);
|
||||
bta_sys_idle(BTA_ID_PBC, p_ccb->allocated, p_ccb->bd_addr);
|
||||
}
|
||||
else if (p_data->goep_response.opcode == OBEX_OPCODE_DISCONNECT) {
|
||||
/* received disconnect response, close goep connection now */
|
||||
@@ -756,6 +775,7 @@ void bta_pba_client_goep_connect(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_DAT
|
||||
|
||||
void bta_pba_client_goep_disconnect(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
p_ccb->goep_handle = 0;
|
||||
|
||||
/* report connection closed event */
|
||||
@@ -763,6 +783,7 @@ void bta_pba_client_goep_disconnect(tBTA_PBA_CLIENT_CCB *p_ccb, tBTA_PBA_CLIENT_
|
||||
conn.handle = p_ccb->allocated;
|
||||
bdcpy(conn.bd_addr, p_ccb->bd_addr);
|
||||
conn.error = BTA_PBA_CLIENT_GOEP_ERROR;
|
||||
bta_pba_client_pm_conn_close(p_ccb);
|
||||
free_ccb(p_ccb);
|
||||
bta_pba_client_cb.p_cback(BTA_PBA_CLIENT_CONN_CLOSE_EVT, (tBTA_PBA_CLIENT *)&conn);
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ typedef struct {
|
||||
UINT16 max_rx; /* max rx bytes */
|
||||
UINT16 max_tx; /* max tx bytes */
|
||||
BOOLEAN authenticate; /* whether we are authenticated */
|
||||
BOOLEAN pm_open; /* TRUE after bta_sys_conn_open until conn_close */
|
||||
tBTA_PBA_CLIENT_OP operation; /* ongoing or last operations */
|
||||
UINT8 state; /* main state machine */
|
||||
UINT8 allocated; /* index + 1 if allocated, otherwise 0 */
|
||||
|
||||
Reference in New Issue
Block a user