/*******************************************************************************
**
** Function         bta_ag_rfc_open
**
** Description      Handle RFCOMM channel open.
**
**
** Returns          void
**
*******************************************************************************/
void bta_ag_rfc_open(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
{
    /* initialize AT feature variables */
    p_scb->clip_enabled = FALSE;
    p_scb->ccwa_enabled = FALSE;
    p_scb->cmer_enabled = FALSE;
    p_scb->cmee_enabled = FALSE;
    p_scb->inband_enabled = ((p_scb->features & BTA_AG_FEAT_INBAND) == BTA_AG_FEAT_INBAND);

    /* set up AT command interpreter */
    p_scb->at_cb.p_at_tbl = (tBTA_AG_AT_CMD *) bta_ag_at_tbl[p_scb->conn_service];
    p_scb->at_cb.p_cmd_cback = (tBTA_AG_AT_CMD_CBACK *) bta_ag_at_cback_tbl[p_scb->conn_service];
    p_scb->at_cb.p_err_cback = (tBTA_AG_AT_ERR_CBACK *) bta_ag_at_err_cback;
    p_scb->at_cb.p_user = p_scb;
    p_scb->at_cb.cmd_max_len = BTA_AG_CMD_MAX;
    bta_ag_at_init(&p_scb->at_cb);

    /* call app open call-out */
    bta_ag_co_data_open(bta_ag_scb_to_idx(p_scb), bta_ag_svc_id[p_scb->conn_service]);

    bta_sys_conn_open(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);

    bta_ag_cback_open(p_scb, NULL, BTA_AG_SUCCESS);

    if (p_scb->conn_service == BTA_AG_HFP)
    {
        /* if hfp start timer for service level conn */
        bta_sys_start_timer(&p_scb->act_timer, BTA_AG_SVC_TOUT_EVT, p_bta_ag_cfg->conn_tout);
    }
    else
    {
        /* else service level conn is open */
        bta_ag_svc_conn_open(p_scb, p_data);
    }
}
/*******************************************************************************
**
** Function         bta_pan_conn_open
**
** Description      process connection open event
**
** Returns          void
**
*******************************************************************************/
void bta_pan_conn_open(tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
{

    tBTA_PAN_OPEN data;

    bdcpy(data.bd_addr, p_scb->bd_addr);
    data.handle = p_scb->handle;
    data.local_role = p_scb->local_role;
    data.peer_role = p_scb->peer_role;

    if(p_data->conn.result == PAN_SUCCESS)
    {
        data.status = BTA_PAN_SUCCESS;
        bta_pan_co_open(p_scb->handle, p_scb->app_id, p_scb->local_role, p_scb->peer_role, p_scb->bd_addr);

    }
    else
    {
        bta_pan_scb_dealloc(p_scb);
        data.status = BTA_PAN_FAIL;
    }

    p_scb->pan_flow_enable = TRUE;
    p_scb->app_flow_enable = TRUE;

    bta_sys_conn_open( BTA_ID_PAN ,p_scb->app_id, p_scb->bd_addr);

    bta_pan_cb.p_cback(BTA_PAN_OPEN_EVT, (tBTA_PAN *)&data);


}
/*******************************************************************************
**
** Function         bta_hf_client_rfc_open
**
** Description      Handle RFCOMM channel open.
**
**
** Returns          void
**
*******************************************************************************/
void bta_hf_client_rfc_open(tBTA_HF_CLIENT_DATA *p_data)
{
    UNUSED(p_data);

    bta_sys_conn_open(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);

    bta_hf_client_cback_open(NULL, BTA_HF_CLIENT_SUCCESS);

    /* start SLC procedure */
    bta_hf_client_slc_seq(FALSE);
}