Пример #1
0
/*******************************************************************************
**
** Function         PORT_ControlCnf
**
** Description      This function is called from the RFCOMM layer when
**                  peer acknowleges change of the modem signals.
**
*******************************************************************************/
void PORT_ControlCnf (tRFC_MCB *p_mcb, UINT8 dlci, tPORT_CTRL *p_pars)
{
    tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci);
    UINT32 event = 0;
    UNUSED(p_pars);

    RFCOMM_TRACE_EVENT ("PORT_ControlCnf");

    if (!p_port) {
        return;
    }

    if (!(p_port->port_ctrl & PORT_CTRL_REQ_CONFIRMED)) {
        p_port->port_ctrl |= PORT_CTRL_REQ_CONFIRMED;

        if (p_port->port_ctrl & PORT_CTRL_IND_RECEIVED) {
            event = (p_port->ev_mask & PORT_EV_CONNECTED);
        }
    }

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

    /* 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);
    }
}
Пример #2
0
/*******************************************************************************
**
** Function         PORT_FlowInd
**
** Description      This function is called from the RFCOMM layer on the flow
**                  control signal change.  Propagate change to the user.
**
*******************************************************************************/
void PORT_FlowInd (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN enable_data)
{
    tPORT  *p_port = (tPORT *)NULL;
    UINT32 events = 0;
    int    i;

    RFCOMM_TRACE_EVENT ("PORT_FlowInd fc:%d", enable_data);

    if (dlci == 0)
    {
        p_mcb->peer_ready = enable_data;
    }
    else
    {
        if ((p_port = port_find_mcb_dlci_port (p_mcb, dlci)) == NULL)
            return;

        p_port->tx.peer_fc = !enable_data;
    }

    for (i = 0; i < MAX_RFC_PORTS; i++)
    {
        /* If DLCI is 0 event applies to all ports */
        if (dlci == 0)
        {
            p_port = &rfc_cb.port.port[i];
            if (!p_port->in_use
             || (p_port->rfc.p_mcb != p_mcb)
             || (p_port->rfc.state != RFC_STATE_OPENED))
                continue;
        }
        events = 0;

        /* Check if flow of data is still enabled */
        events |= port_flow_control_user (p_port);

        /* Check if data can be sent and send it */
        events |= port_rfc_send_tx_data (p_port);

        /* Mask out all events that are not of interest to user */
        events &= p_port->ev_mask;

        /* Send event to the application */
        if (p_port->p_callback && events)
            (p_port->p_callback)(events, p_port->inx);

        /* If DLCI is not 0 event applies to one port only */
        if (dlci != 0)
            break;
    }
}
Пример #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));

}