/*******************************************************************************
**
** Function         bta_ag_rfc_data
**
** Description      Read and process data from RFCOMM.
**
**
** Returns          void
**
*******************************************************************************/
void bta_ag_rfc_data(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
{
    UINT16  len;
    char    buf[BTA_AG_RFC_READ_MAX];
    UNUSED(p_data);

    memset(buf, 0, BTA_AG_RFC_READ_MAX);

    APPL_TRACE_DEBUG ("bta_ag_rfc_data");
    /* do the following */
    for(;;)
    {
        /* read data from rfcomm; if bad status, we're done */
        if (PORT_ReadData(p_scb->conn_handle, buf, BTA_AG_RFC_READ_MAX, &len) != PORT_SUCCESS)
        {
            break;
        }

        /* if no data, we're done */
        if (len == 0)
        {
            break;
        }

        /* run AT command interpreter on data */
        bta_sys_busy(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
        bta_ag_at_parse(&p_scb->at_cb, buf, len);
        if ((p_scb->sco_idx != BTM_INVALID_SCO_INDEX) && bta_ag_sco_is_open(p_scb))
        {
            APPL_TRACE_IMP ("bta_ag_rfc_data, change link policy for SCO");
            bta_sys_sco_open(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
        }
        else
        {
            bta_sys_idle(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
        }
        /* no more data to read, we're done */
        if (len < BTA_AG_RFC_READ_MAX)
        {
            break;
        }
    }
}
/*******************************************************************************
**
** Function         bta_ag_ci_rx_data
**
** Description      Send result code
**
** Returns          void
**
*******************************************************************************/
void bta_ag_ci_rx_data(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
{
    UINT16 len;
    tBTA_AG_CI_RX_WRITE *p_rx_write_msg = (tBTA_AG_CI_RX_WRITE *)p_data;
    char *p_data_area = (char *)(p_rx_write_msg+1);     /* Point to data area after header */

    APPL_TRACE_DEBUG ("bta_ag_ci_rx_data:");
    /* send to RFCOMM */
    bta_sys_busy(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
    PORT_WriteData(p_scb->conn_handle, p_data_area, strlen(p_data_area), &len);
    if ((p_scb->sco_idx != BTM_INVALID_SCO_INDEX) && bta_ag_sco_is_open(p_scb))
    {
        APPL_TRACE_IMP ("bta_ag_rfc_data, change link policy for SCO");
        bta_sys_sco_open(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
    }
    else
    {
        bta_sys_idle(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
    }
}
コード例 #3
0
/*******************************************************************************
 **
 ** 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);
}