コード例 #1
0
/*******************************************************************************
**
** Function         PORT_PortNegCnf
**
** Description      This function is called from the RFCOMM layer to change
**                  state for the port.  Propagate change to the user.
**
*******************************************************************************/
void PORT_PortNegCnf (tRFC_MCB *p_mcb, UINT8 dlci, tPORT_STATE *p_pars, UINT16 result)
{
    tPORT  *p_port = port_find_mcb_dlci_port (p_mcb, dlci);
    UNUSED(p_pars);

    RFCOMM_TRACE_EVENT ("PORT_PortNegCnf");

    if (!p_port) {
        RFCOMM_TRACE_WARNING ("PORT_PortNegCnf no port");
        return;
    }
    /* Port negotiation failed. Drop the connection */
    if (result != RFCOMM_SUCCESS) {
        p_port->error = PORT_PORT_NEG_FAILED;

        RFCOMM_DlcReleaseReq (p_mcb, p_port->dlci);

        port_rfc_closed (p_port, PORT_PORT_NEG_FAILED);
        return;
    }

    if (!(p_port->port_ctrl & PORT_CTRL_REQ_SENT)) {
        RFCOMM_ControlReq (p_port->rfc.p_mcb, p_port->dlci, &p_port->local_ctrl);
    } else {
        RFCOMM_TRACE_WARNING ("PORT_PortNegCnf Control Already sent");
    }
}
コード例 #2
0
ファイル: port_rfc.c プロジェクト: Emill/android_bluetooth
/*******************************************************************************
**
** Function         port_start_control
**
** Description      This function is called in the BTU_TASK context to
**                  send control information
**
** Returns          void
**
*******************************************************************************/
void port_start_control (tPORT *p_port)
{
    tRFC_MCB *p_mcb = p_port->rfc.p_mcb;

    if (p_mcb == NULL)
        return;

    RFCOMM_ControlReq (p_mcb, p_port->dlci, &p_port->local_ctrl);
}
コード例 #3
0
/*******************************************************************************
**
** Function         PORT_ControlInd
**
** Description      This function is called from the RFCOMM layer on the modem
**                  signal change.  Propagate change to the user.
**
*******************************************************************************/
void PORT_ControlInd (tRFC_MCB *p_mcb, UINT8 dlci, tPORT_CTRL *p_pars)
{
    tPORT  *p_port = port_find_mcb_dlci_port (p_mcb, dlci);
    UINT32 event;
    UINT8  old_signals;

    RFCOMM_TRACE_EVENT ("PORT_ControlInd");

    if (!p_port) {
        return;
    }

    old_signals = p_port->peer_ctrl.modem_signal;

    event = port_get_signal_changes (p_port, old_signals, p_pars->modem_signal);

    p_port->peer_ctrl = *p_pars;

    if (!(p_port->port_ctrl & PORT_CTRL_REQ_SENT)) {
        RFCOMM_ControlReq (p_port->rfc.p_mcb, p_port->dlci, &p_port->local_ctrl);
    } else {
        /* If this is the first time we received control RFCOMM is connected */
        if (!(p_port->port_ctrl & PORT_CTRL_IND_RECEIVED)) {
            event |= (PORT_EV_CONNECTED & p_port->ev_mask);
        }

        if (p_port->port_ctrl & PORT_CTRL_REQ_CONFIRMED) {
            event |= port_rfc_send_tx_data(p_port);
        }
    }

    p_port->port_ctrl |= (PORT_CTRL_IND_RECEIVED | PORT_CTRL_IND_RESPONDED);

    if (p_pars->break_signal) {
        event |= (PORT_EV_BREAK & p_port->ev_mask);
    }

    /* execute call back function only if the application is registered for events */
    if (event && p_port->p_callback) {
        (p_port->p_callback)(event, p_port->inx);
    }

    RFCOMM_TRACE_EVENT ("PORT_ControlInd DTR_DSR : %d, RTS_CTS : %d, RI : %d, DCD : %d",
                        ((p_port->peer_ctrl.modem_signal & MODEM_SIGNAL_DTRDSR) ? 1 : 0),
                        ((p_port->peer_ctrl.modem_signal & MODEM_SIGNAL_RTSCTS) ? 1 : 0),
                        ((p_port->peer_ctrl.modem_signal & MODEM_SIGNAL_RI) ? 1 : 0),
                        ((p_port->peer_ctrl.modem_signal & MODEM_SIGNAL_DCD) ? 1 : 0));

}
コード例 #4
0
/*******************************************************************************
**
** Function         PORT_DlcEstablishCnf
**
** Description      This function is called from the RFCOMM layer when peer
**                  acknowledges establish procedure (SABME/UA).  Send reply
**                  to the user and set state to OPENED if result was
**                  successfull.
**
*******************************************************************************/
void PORT_DlcEstablishCnf (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT16 result)
{
    tPORT  *p_port = port_find_mcb_dlci_port (p_mcb, dlci);

    RFCOMM_TRACE_EVENT ("PORT_DlcEstablishCnf dlci:%d mtu:%d result:%d", dlci, mtu, result);

    if (!p_port) {
        return;
    }

    if (result != RFCOMM_SUCCESS) {
        p_port->error = PORT_START_FAILED;
        port_rfc_closed (p_port, PORT_START_FAILED);
        return;
    }

    /* If L2CAP's mtu less then RFCOMM's take it */
    if (mtu && (mtu < p_port->peer_mtu)) {
        p_port->peer_mtu = mtu;
    }

    /* If there was an inactivity timer running for MCB stop it */
    rfc_timer_stop (p_mcb);

    if (p_port->p_callback && (p_port->ev_mask & PORT_EV_CONNECTED)) {
        (p_port->p_callback)(PORT_EV_CONNECTED, p_port->inx);
    }

    if (p_port->p_mgmt_callback) {
        p_port->p_mgmt_callback (PORT_SUCCESS, p_port->inx);
    }

    p_port->state = PORT_STATE_OPENED;

    /* RPN is required only if we want to tell DTE how the port should be opened */
    if ((p_port->uuid == UUID_SERVCLASS_DIALUP_NETWORKING)
            || (p_port->uuid == UUID_SERVCLASS_FAX)) {
        RFCOMM_PortNegReq (p_port->rfc.p_mcb, p_port->dlci, NULL);
    } else {
        RFCOMM_ControlReq (p_port->rfc.p_mcb, p_port->dlci, &p_port->local_ctrl);
    }
}