** Action Functions
*****************************************************************************/
+
+void bta_gattc_reset_discover_st(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_STATUS status);
+
/*******************************************************************************
**
** Function bta_gattc_enable
if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE)
{
p_clcb->p_srcb->state = BTA_GATTC_SERV_LOAD;
- bta_gattc_sm_execute(p_clcb, BTA_GATTC_START_CACHE_EVT, NULL);
+ if (bta_gattc_cache_load(p_clcb)) {
+ bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
+ } else {
+ p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
+ /* cache load failure, start discovery */
+ bta_gattc_start_discover(p_clcb, NULL);
+ }
}
else /* cache is building */
p_clcb->state = BTA_GATTC_DISCOVER_ST;
}
/* used to reset cache in application */
- bta_gattc_co_cache_reset(p_clcb->p_srcb->server_bda);
+ bta_gattc_cache_reset(p_clcb->p_srcb->server_bda);
}
if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_list) {
/* release pending attribute list buffer */
{
bta_gattc_enqueue(p_clcb, p_data);
}
-/*******************************************************************************
-**
-** Function bta_gattc_cache_open
-**
-** Description open a NV cache for loading
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
-{
- UNUSED(p_data);
-
- bta_gattc_set_discover_st(p_clcb->p_srcb);
-
- APPL_TRACE_DEBUG("bta_gattc_cache_open conn_id=%d",p_clcb->bta_conn_id);
- bta_gattc_co_cache_open(p_clcb->p_srcb->server_bda, BTA_GATTC_CI_CACHE_OPEN_EVT,
- p_clcb->bta_conn_id, FALSE);
-}
-/*******************************************************************************
-**
-** Function bta_gattc_start_load
-**
-** Description start cache loading by sending callout open cache
-**
-** Returns None.
-**
-*******************************************************************************/
-void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
-{
- APPL_TRACE_DEBUG("bta_gattc_ci_open conn_id=%d server state=%d" ,
- p_clcb->bta_conn_id, p_clcb->p_srcb->state);
- if (p_clcb->p_srcb->state == BTA_GATTC_SERV_LOAD)
- {
- if (p_data->ci_open.status == BTA_GATT_OK)
- {
- p_clcb->p_srcb->attr_index = 0;
- bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
- BTA_GATTC_CI_CACHE_LOAD_EVT,
- p_clcb->p_srcb->attr_index,
- p_clcb->bta_conn_id);
- }
- else
- {
- p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
- /* cache open failure, start discovery */
- bta_gattc_start_discover(p_clcb, NULL);
- }
- }
- if (p_clcb->p_srcb->state == BTA_GATTC_SERV_SAVE)
- {
- if (p_data->ci_open.status == BTA_GATT_OK)
- {
- if (!bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id))
- {
- p_data->ci_open.status = BTA_GATT_ERROR;
- }
- }
- if (p_data->ci_open.status != BTA_GATT_OK)
- {
- p_clcb->p_srcb->attr_index = 0;
- bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, p_clcb->bta_conn_id);
- bta_gattc_reset_discover_st(p_clcb->p_srcb, p_clcb->status);
- }
- }
-}
-/*******************************************************************************
-**
-** Function bta_gattc_ci_load
-**
-** Description cache loading received.
-**
-** Returns None.
-**
-*******************************************************************************/
-void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
-{
-
- APPL_TRACE_DEBUG("bta_gattc_ci_load conn_id=%d load status=%d",
- p_clcb->bta_conn_id, p_data->ci_load.status);
-
- if (p_data->ci_load.status == BTA_GATT_OK ||
- p_data->ci_load.status == BTA_GATT_MORE)
- {
- if (p_data->ci_load.num_attr != 0)
- bta_gattc_rebuild_cache(p_clcb->p_srcb, p_data->ci_load.num_attr,
- p_data->ci_load.attr, p_clcb->p_srcb->attr_index);
-
- if (p_data->ci_load.status == BTA_GATT_OK)
- {
- p_clcb->p_srcb->attr_index = 0;
- bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
- bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
- }
- else /* load more */
- {
- p_clcb->p_srcb->attr_index += p_data->ci_load.num_attr;
-
- bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
- BTA_GATTC_CI_CACHE_LOAD_EVT,
- p_clcb->p_srcb->attr_index,
- p_clcb->bta_conn_id);
- }
- }
- else
- {
- bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
- p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
- p_clcb->p_srcb->attr_index = 0;
- /* cache load failure, start discovery */
- bta_gattc_start_discover(p_clcb, NULL);
- }
-}
-/*******************************************************************************
-**
-** Function bta_gattc_ci_save
-**
-** Description cache loading received.
-**
-** Returns None.
-**
-*******************************************************************************/
-void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
-{
- UNUSED(p_data);
-
- APPL_TRACE_DEBUG("bta_gattc_ci_save conn_id=%d " ,
- p_clcb->bta_conn_id );
-
- if (!bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id))
- {
- p_clcb->p_srcb->attr_index = 0;
- bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
- bta_gattc_reset_discover_st(p_clcb->p_srcb, p_clcb->status);
- }
-}
/*******************************************************************************
**
** Function bta_gattc_fail
}
}
/* used to reset cache in application */
- bta_gattc_co_cache_reset(p_msg->api_conn.remote_bda);
+ bta_gattc_cache_reset(p_msg->api_conn.remote_bda);
}
/*******************************************************************************