Track TX empty event to manage sniff timer
am: 4e972d8c24
* commit '4e972d8c24ecfb808757ef5c81eb3877ebc93027':
Track TX empty event to manage sniff timer
diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c
index 0d19b76..52c5481 100644
--- a/bta/jv/bta_jv_act.c
+++ b/bta/jv/bta_jv_act.c
@@ -1021,6 +1021,10 @@
bta_jv_pm_conn_idle(p_cb->p_pm_cb);
break;
+ case GAP_EVT_TX_EMPTY:
+ bta_jv_pm_conn_idle(p_cb->p_pm_cb);
+ break;
+
case GAP_EVT_CONN_CONGESTED:
case GAP_EVT_CONN_UNCONGESTED:
p_cb->cong = (event == GAP_EVT_CONN_CONGESTED) ? TRUE : FALSE;
@@ -1186,6 +1190,10 @@
bta_jv_pm_conn_idle(p_cb->p_pm_cb);
break;
+ case GAP_EVT_TX_EMPTY:
+ bta_jv_pm_conn_idle(p_cb->p_pm_cb);
+ break;
+
case GAP_EVT_CONN_CONGESTED:
case GAP_EVT_CONN_UNCONGESTED:
p_cb->cong = (event == GAP_EVT_CONN_CONGESTED) ? TRUE : FALSE;
@@ -1375,7 +1383,6 @@
evt_data.status = BTA_JV_SUCCESS;
}
ls->p_cb->p_cback(BTA_JV_L2CAP_WRITE_EVT, (tBTA_JV *)&evt_data, ls->user_data);
- bta_jv_set_pm_conn_state(ls->p_cb->p_pm_cb, BTA_JV_CONN_IDLE);
} else {
/* As this pointer is checked in the API function, this occurs only when the channel is
* disconnected after the API function is called, but before the message is handled. */
diff --git a/stack/gap/gap_conn.c b/stack/gap/gap_conn.c
index 5be3810..6f537c0 100644
--- a/stack/gap/gap_conn.c
+++ b/stack/gap/gap_conn.c
@@ -38,6 +38,7 @@
static void gap_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed);
static void gap_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg);
static void gap_congestion_ind (UINT16 lcid, BOOLEAN is_congested);
+static void gap_tx_complete_ind (UINT16 l2cap_cid, UINT16 sdu_sent);
static tGAP_CCB *gap_find_ccb_by_cid (UINT16 cid);
static tGAP_CCB *gap_find_ccb_by_handle (UINT16 handle);
@@ -83,7 +84,7 @@
gap_cb.conn.reg_info.pL2CA_QoSViolationInd_Cb = NULL;
gap_cb.conn.reg_info.pL2CA_DataInd_Cb = gap_data_ind;
gap_cb.conn.reg_info.pL2CA_CongestionStatus_Cb = gap_congestion_ind;
- gap_cb.conn.reg_info.pL2CA_TxComplete_Cb = NULL;
+ gap_cb.conn.reg_info.pL2CA_TxComplete_Cb = gap_tx_complete_ind;
#endif
}
@@ -712,6 +713,28 @@
return (p_ccb->connection_id);
}
+/*******************************************************************************
+**
+** Function gap_tx_connect_ind
+**
+** Description Sends out GAP_EVT_TX_EMPTY when transmission has been
+** completed.
+**
+** Returns void
+**
+*******************************************************************************/
+void gap_tx_complete_ind (UINT16 l2cap_cid, UINT16 sdu_sent)
+{
+ tGAP_CCB *p_ccb = gap_find_ccb_by_cid (l2cap_cid);
+ if (p_ccb == NULL)
+ return;
+
+ if ((p_ccb->con_state == GAP_CCB_STATE_CONNECTED) && (sdu_sent == 0xFFFF))
+ {
+ GAP_TRACE_EVENT("%s: GAP_EVT_TX_EMPTY", __func__);
+ p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_TX_EMPTY);
+ }
+}
/*******************************************************************************
**
diff --git a/stack/include/gap_api.h b/stack/include/gap_api.h
index 755c49c..a758b61 100644
--- a/stack/include/gap_api.h
+++ b/stack/include/gap_api.h
@@ -55,6 +55,8 @@
#define GAP_EVT_CONN_DATA_AVAIL 0x0102
#define GAP_EVT_CONN_CONGESTED 0x0103
#define GAP_EVT_CONN_UNCONGESTED 0x0104
+#define GAP_EVT_TX_EMPTY 0x0105
+
/* Values for 'chan_mode_mask' field */
/* GAP_ConnOpen() - optional channels to negotiate */
#define GAP_FCR_CHAN_OPT_BASIC L2CAP_FCR_CHAN_OPT_BASIC