Merge "Bluetooth: Adding Sniff feature for PAN Profile"
diff --git a/bta/dm/bta_dm_cfg.c b/bta/dm/bta_dm_cfg.c
index 5caf04a..91b88dd 100644
--- a/bta/dm/bta_dm_cfg.c
+++ b/bta/dm/bta_dm_cfg.c
@@ -111,9 +111,9 @@
tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *)&bta_dm_rm_cfg;
#if BLE_INCLUDED == TRUE
-#define BTA_DM_NUM_PM_ENTRY (17+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
+#define BTA_DM_NUM_PM_ENTRY (19+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
#else
-#define BTA_DM_NUM_PM_ENTRY (15+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
+#define BTA_DM_NUM_PM_ENTRY (17+BTA_DM_NUM_JV_ID) /* number of entries in bta_dm_pm_cfg except the first */
#endif
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[] =
@@ -135,24 +135,26 @@
{BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
{BTA_ID_JV, BTA_JV_PM_ID_1, 6}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */
{BTA_ID_JV, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
- {BTA_ID_HL, BTA_ALL_APP_ID, 8} /* reuse fts spec table */
+ {BTA_ID_HL, BTA_ALL_APP_ID, 8}, /* reuse fts spec table */
+ {BTA_ID_PAN, BTUI_PAN_ID_PANU, 9}, /* PANU spec table */
+ {BTA_ID_PAN, BTUI_PAN_ID_NAP, 10} /* NAP spec table */
#if BLE_INCLUDED == TRUE
- ,{BTA_ID_GATTC, BTA_ALL_APP_ID, 9} /* gattc spec table */
- ,{BTA_ID_GATTS, BTA_ALL_APP_ID, 10} /* gatts spec table */
+ ,{BTA_ID_GATTC, BTA_ALL_APP_ID, 11} /* gattc spec table */
+ ,{BTA_ID_GATTS, BTA_ALL_APP_ID, 12} /* gatts spec table */
#endif
};
#if BLE_INCLUDED == TRUE /* add GATT PM entry for GATT over BR/EDR */
#ifdef BTE_SIM_APP /* For Insight builds only, see the detail below */
-#define BTA_DM_NUM_PM_SPEC (11 + 2) /* additional two */
+#define BTA_DM_NUM_PM_SPEC (13 + 2) /* additional two */
#else
-#define BTA_DM_NUM_PM_SPEC 11 /* additional JV*/
+#define BTA_DM_NUM_PM_SPEC 13 /* additional JV*/
#endif
#else
#ifdef BTE_SIM_APP /* For Insight builds only, see the detail below */
-#define BTA_DM_NUM_PM_SPEC (9 + 2) /* additional two */
+#define BTA_DM_NUM_PM_SPEC (11 + 2) /* additional two */
#else
-#define BTA_DM_NUM_PM_SPEC 9 /* additional JV*/
+#define BTA_DM_NUM_PM_SPEC 11 /* additional JV*/
#endif
#endif
@@ -328,6 +330,44 @@
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}
+ },
+
+ /* PANU */
+ {
+ (BTA_DM_PM_SNIFF), /* allow sniff */
+#if (BTM_SSR_INCLUDED == TRUE)
+ (BTA_DM_PM_SSR2), /* the SSR entry */
+#endif
+ {
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
+ {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
+ {{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
+ }
+ },
+
+ /* NAP */
+ {
+ (BTA_DM_PM_SNIFF), /* allow sniff */
+#if (BTM_SSR_INCLUDED == TRUE)
+ (BTA_DM_PM_SSR2), /* the SSR entry */
+#endif
+ {
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
+ {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
+ {{BTA_DM_PM_SNIFF, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
+ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
+ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
+ }
}
#if BLE_INCLUDED == TRUE
diff --git a/bta/pan/bta_pan_act.c b/bta/pan/bta_pan_act.c
index f9088f3..24a5ccf 100644
--- a/bta/pan/bta_pan_act.c
+++ b/bta/pan/bta_pan_act.c
@@ -42,6 +42,40 @@
#define BTA_PAN_TX_MASK 0xF0
/*******************************************************************************
+ **
+ ** Function bta_pan_pm_conn_busy
+ **
+ ** Description set pan pm connection busy state
+ **
+ ** Params p_scb: state machine control block of pan connection
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void bta_pan_pm_conn_busy(tBTA_PAN_SCB *p_scb)
+{
+ if ((p_scb != NULL) && (p_scb->state != BTA_PAN_IDLE_ST))
+ bta_sys_busy(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
+}
+
+/*******************************************************************************
+ **
+ ** Function bta_pan_pm_conn_idle
+ **
+ ** Description set pan pm connection idle state
+ **
+ ** Params p_scb: state machine control block of pan connection
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+static void bta_pan_pm_conn_idle(tBTA_PAN_SCB *p_scb)
+{
+ if ((p_scb != NULL) && (p_scb->state != BTA_PAN_IDLE_ST))
+ bta_sys_idle(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
+}
+
+/*******************************************************************************
**
** Function bta_pan_conn_state_cback
**
@@ -622,12 +656,14 @@
/* if data path configured for tx pull */
if ((bta_pan_cb.flow_mask & BTA_PAN_TX_MASK) == BTA_PAN_TX_PULL)
{
+ bta_pan_pm_conn_busy(p_scb);
/* call application callout function for tx path */
bta_pan_co_tx_path(p_scb->handle, p_scb->app_id);
/* free data that exceeds queue level */
while(p_scb->data_queue.count > bta_pan_cb.q_level)
GKI_freebuf(GKI_dequeue(&p_scb->data_queue));
+ bta_pan_pm_conn_idle(p_scb);
}
/* if configured for zero copy push */
else if ((bta_pan_cb.flow_mask & BTA_PAN_TX_MASK) == BTA_PAN_TX_PUSH_BUF)
@@ -699,6 +735,7 @@
{
if ((bta_pan_cb.flow_mask & BTA_PAN_RX_MASK) == BTA_PAN_RX_PUSH_BUF)
{
+ bta_pan_pm_conn_busy(p_scb);
PAN_WriteBuf (p_scb->handle,
((tBTA_PAN_DATA_PARAMS *)p_data)->dst,
@@ -706,6 +743,7 @@
((tBTA_PAN_DATA_PARAMS *)p_data)->protocol,
(BT_HDR *)p_data,
((tBTA_PAN_DATA_PARAMS *)p_data)->ext);
+ bta_pan_pm_conn_idle(p_scb);
}
}
diff --git a/bta/pan/bta_pan_int.h b/bta/pan/bta_pan_int.h
index 1667e57..bd75311 100644
--- a/bta/pan/bta_pan_int.h
+++ b/bta/pan/bta_pan_int.h
@@ -56,6 +56,14 @@
BTA_PAN_API_OPEN_EVT
};
+/* state machine states */
+enum
+{
+ BTA_PAN_IDLE_ST,
+ BTA_PAN_OPEN_ST,
+ BTA_PAN_CLOSING_ST
+};
+
diff --git a/bta/pan/bta_pan_main.c b/bta/pan/bta_pan_main.c
index add1c7c..bc92b36 100644
--- a/bta/pan/bta_pan_main.c
+++ b/bta/pan/bta_pan_main.c
@@ -83,14 +83,6 @@
#define BTA_PAN_NUM_COLS 2 /* number of columns in state tables */
-/* state machine states */
-enum
-{
- BTA_PAN_IDLE_ST,
- BTA_PAN_OPEN_ST,
- BTA_PAN_CLOSING_ST
-};
-
/* state table for listen state */
const UINT8 bta_pan_st_idle[][BTA_PAN_NUM_COLS] =
diff --git a/btif/src/btif_pan.c b/btif/src/btif_pan.c
index 633f6ef..e6cc1fe 100644
--- a/btif/src/btif_pan.c
+++ b/btif/src/btif_pan.c
@@ -197,7 +197,7 @@
}
static volatile int btpan_dev_local_role;
static tBTA_PAN_ROLE_INFO bta_panu_info = {PANU_SERVICE_NAME, 0, PAN_SECURITY};
-static tBTA_PAN_ROLE_INFO bta_pan_nap_info = {PAN_NAP_SERVICE_NAME, 0, PAN_SECURITY};
+static tBTA_PAN_ROLE_INFO bta_pan_nap_info = {PAN_NAP_SERVICE_NAME, 1, PAN_SECURITY};
static bt_status_t btpan_enable(int local_role)
{