Example #1
0
/****************************************************************************
NAME    
    slcConnectionComplete
    
DESCRIPTION
    SLC connection has completed

RETURNS
    void
*/
static void slcConnectionComplete(hfp_link_priority priority, Sink sink, bdaddr* bd_addr)
{
    	
    /* mark as connected */
    theSink.profile_data[PROFILE_INDEX(priority)].status.connected = TRUE;

    /* Another connection made, update number of current connections */
 	SLC_DEBUG(("SLC: Pro Connected[%x], NoOfDev=%x\n", (int)sink,deviceManagerNumConnectedDevs())) ;

	/* Enter connected state if applicable */
    if(!stateManagerIsConnected())
        stateManagerEnterConnectedState();
    
    /* Ensure the underlying ACL is encrypted */
    if(theSink.features.EncryptOnSLCEstablishment)
        ConnectionSmEncrypt( &theSink.task , sink , TRUE );
            
    /* send message to do indicate a stop of the paging process when in connectable state */
    if(theSink.paging_in_progress)
        MessageSend(&theSink.task, EventSysStopPagingInConnState ,0);

    /* if device initiated connection */
    if(!gSlcData.gSlcConnectRemote)
    {
        /* If no event is queued send button press */
        if(!theSink.gEventQueuedOnConnection)
            HfpHsButtonPressRequest(priority);
            
        /* Continue trying to connect to next device in 0.1 seconds time to allow current device to finish connecting */
        MessageSendLater(&theSink.task,EventSysContinueSlcConnectRequest,0,theSink.conf1->timeouts.SecondAGConnectDelayTime_s);
    }

    /* Initialise call transfer flag */
    gSlcData.gCallTransferInProgress = FALSE ;
}       
static void handleAVRCPConnectCfm(AVRCP_CONNECT_CFM_T *msg)
{
	AVRCP_MSG_DEBUG(("AVRCP_CONNECT_CFM : \n"));

    SendEvent(EVT_AVRCP_SIGNAL_CONNECT_CFM,msg->status);

	if (stateManagerGetAvrcpState() == avrcpConnecting)
	{
	    if(msg->status == avrcp_success)
	    {	
			stateManagerSetAvrcpState(avrcpConnected);
			
			/* Ensure the underlying ACL is encrypted */       
		    ConnectionSmEncrypt( &theHeadset.task , msg->sink , TRUE );
			
			/* If a request was made to send an avrcp_play when AVRCP was connected
			   then do it now. 
			*/
			theHeadset.avrcp_data.send_play = 0;
				
			/* Assume music won't be playing */
			theHeadset.PlayingState = 0;				
	    }
	    else
	    {
			MessageCancelAll( &theHeadset.task , APP_SEND_PLAY );
			stateManagerSetAvrcpState(avrcpReady);
			theHeadset.PlayingState = 1;
			if ( stateManagerGetA2dpState () == headsetA2dpPaused )
				stateManagerEnterA2dpStreamingState();
				
	    }
	    
		PROFILE_MEMORY(("AVRCPConnect"))
	}
	else
	{