Beispiel #1
0
void SIMAP_RejectIncomingRequest(void)
{
	if (cur_rfchannel != NULL)
		RF_RejectChannel(cur_rfchannel);

	cur_rfchannel = NULL;
}
Beispiel #2
0
/*---------------------------------------------------------------------------
 *            HfRfCallback()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  RFCOMM callback for the HF state machine.
 *
 * Return:    void
 */
void ChnRfCallback(RfChannel *rfChannel, RfCallbackParms *Parms)
{
    ChnChannel  *Channel;
    /*AtCommands  atParms;*/
    U8          event = 0;
    U16         offset = 0;
    BtStatus status = BT_STATUS_SUCCESS;

    Report(("[CHN][ChnRfCallback] +rfChannel==x%X, RfEvent==0x%X", (U32)rfChannel, Parms->event) );

    Channel = ChnFindRegisteredChannel(rfChannel);
    Assert(Channel != 0);

    switch (Parms->event) 
    {
    case RFEVENT_OPEN_IND:
        DBG_PRINT_EVENT(("[CHN][EVENT] RFCOMM Event : RFEVENT_OPEN_IND."));
        if(Channel)
        {
            Channel->remDev = Parms->ptrs.remDev;
            if(ChnGetSubstate(Channel) == CHN_SUBSTATE_CLOSED1)
            {
                ChnChangeSubstate(Channel, CHN_SUBSTATE_CONN_IN1);
            }
            else
            {
                Report(("ChnRfCallback: Only in C1, the server channel is registered."));
                /* Only in C1, the server channel is registered, so there shall no open ind received in other 
                substates other than C1. */
                (void)RF_RejectChannel(rfChannel);
            }
        }
        else
        {
            Report(("ChnRfCallback: RFEVENT_OPEN_IND: HFP shall never get into this case."));
            /* HFP shall never get into this case */
            DBG_PRINT_ERROR( ("[CHN][ERR] Unexpected substate==0x%X - (%s,%d)", ChnGetSubstate(Channel), __FILE__, __LINE__) );
            (void)RF_RejectChannel(rfChannel);
        }
        break;

    case RFEVENT_OPEN:
        DBG_PRINT_EVENT(("[CHN][EVENT] RFCOMM Event : RFEVENT_OPEN."));
        /* Register a SCO handler */
        if (Channel) 
        {
            Channel->remDev = Parms->ptrs.remDev;
            //CMGR_SetDeviceAsMaster(&(Channel->cmgrHandler));
            //HfgEnableSniffTimerMode(&(Channel->cmgrHandler));
            Channel->linkFlags |= CHN_LINK_HANDSFREE;
            Report(("ChnRfCallback: RFCOMM HF connection established."));

            switch(ChnGetSubstate(Channel))
            {
            case CHN_SUBSTATE_CONN_OUT3:
            case CHN_SUBSTATE_CONN_IN2:
		  // Direct change state to SLC1
                ChnChangeSubstate(Channel, CHN_SUBSTATE_SLC1);
                break;
            case CHN_SUBSTATE_DISC1:
                ChnDisconnecting(Channel);
                break;
            default:
                Report(("ChnRfCallback: RFEVENT_OPEN:CHN shall not get into this case."));
                /* CHN shall not get into this case. */
                DBG_PRINT_ERROR( ("[CHN][ERR] Unexpected substate==0x%X - (%s,%d)", ChnGetSubstate(Channel), __FILE__, __LINE__) );
                Assert(0);
                RF_CloseChannel(rfChannel);
                break;
            }
        }
        else
        {
            RF_CloseChannel(rfChannel);
        }
        break;
    case RFEVENT_DATA_IND:
        DBG_PRINT_EVENT(("[CHN][EVENT] RFCOMM Event : RFEVENT_DATA_IND."));
        if (Channel) 
        {
        	RfBuffer	rfBuf;
        	rfBuf.len = Parms->dataLen;
        	rfBuf.buf = Parms->ptrs.data;
            	Report(("ChnRfCallback: RFCOMM HF data received."));
            	RF_AdvanceCredit(rfChannel, 1);

		ChnAppCallback(Channel, CHN_EVENT_RX_DATA, Parms->status, (U32)&rfBuf);
        }
        break;

    case RFEVENT_PACKET_HANDLED:
        DBG_PRINT_EVENT(("[CHN][EVENT] RFCOMM Event : RFEVENT_PACKET_HANDLED, Status=%d", Parms->status));
        if (Channel) 
        {
        	Channel->bTxInProgress = FALSE;
            status = Parms->status;
            if(status != BT_STATUS_SUCCESS)
            {
                /* Only when RFCOMM channel is closed, it does not return success */
                DBG_PRINT_AT(("[CHN][AT] RFEVENT_PACKET_HANDLED : Fail"));
            }
            else
            {
	            	if(ChnRemainTxData(Channel) > 0)
			{
				DBG_PRINT_AT(("[CHN][AT] Bytestosend=%d", ChnRemainTxData(Channel) ));
				status = ChnSendTxBuffer(Channel);
				if (status == BT_STATUS_PENDING) 
				{
				    DBG_PRINT_AT(("[CHN] ChnSendTxBuffer return Pending"));
				}
            		}
            }
        } 
        else 
        {
            Report(("ChnRfCallback: RFEVENT_PACKET_HANDLED: No CHN channel."));
            return;
        }
        break;

    case RFEVENT_CLOSED:
        DBG_PRINT_EVENT(("[CHN][EVENT] RFCOMM Event : RFEVENT_CLOSED"));
        if (Channel) 
        {
            //HfgDisableSniffTimerMode(&(Channel->cmgrHandler));
            Channel->linkFlags &= ~CHN_LINK_HANDSFREE;

            switch(ChnGetSubstate(Channel))
            {
            case CHN_SUBSTATE_CONN_OUT3:
            case CHN_SUBSTATE_CONN_IN1:
            case CHN_SUBSTATE_CONN_IN2:
            case CHN_SUBSTATE_OPEN1:
                ChnChangeSubstate(Channel, CHN_SUBSTATE_CLOSED1);
                break;
            case CHN_SUBSTATE_OPEN2:
            case CHN_SUBSTATE_SLC1:
            case CHN_SUBSTATE_SLC2:
            case CHN_SUBSTATE_DISC1:
                ChnDisconnecting(Channel);
                break;
            default:
                DBG_PRINT_ERROR( ("[CHN][ERR] Unexpected substate==0x%X - (%s,%d)", ChnGetSubstate(Channel), __FILE__, __LINE__) );
                Assert(0);
                break;
            }
        }
        break;

    default:
        DBG_PRINT_EVENT(("[CHN][EVENT] RFCOMM ignore other events : %d", Parms->event));
        /* Ignore other events */
        break;
    }
    Report(("- ChnRfCallback."));
}