コード例 #1
0
ファイル: sink_link_policy.c プロジェクト: NemProjects/BC
/****************************************************************************
NAME    
    linkPolicyGetRole
    
DESCRIPTION
    Request CL to get the role for a specific sink if one passed, or all
    connected HFP sinks if NULL passed.

RETURNS
    void
*/
void linkPolicyGetRole(Sink* sink_passed)
{
    /* no specific sink to check, check all available - happens on the back of each hfp connect cfm 
     * and handleA2DPSignallingConnected
     */
    LP_DEBUG(("LP: linkPolicyGetRole - sink = %x\n",(uint16)*sink_passed));
    if (sink_passed)
    {
        if (SinkIsValid(*sink_passed) )
        {
            /*only attempt to switch the sink that has failed to switch*/
            ConnectionGetRole(&theSink.task , *sink_passed) ;
            LP_DEBUG(("LP: GET 1 role[%x]\n", (int)*sink_passed));
        }
    }
}
コード例 #2
0
/****************************************************************************
NAME
    handleAghfpSlcConnectCfm

DESCRIPTION
    Handles the AGHFP library connection confirmation message.

*/
static void handleAghfpSlcConnectCfm(const AGHFP_SLC_CONNECT_CFM_T *cfm)
{
    devInstanceTaskData *inst = devInstanceFindFromAG(cfm->aghfp);
    mvdAvrcpState current_state = getAghfpState(inst);
    
    if (inst == NULL)
        return;

    switch (current_state)
    {
        case AghfpStatePaging:
        case AghfpStatePaged:
        {
            if ( cfm->status == aghfp_success )
            {    /* SLC connect attempt succeeded */    
                the_app->s_connect_attempts = 0;
                /* Store aghfp pointer to this instance */
                inst->aghfp = cfm->aghfp;
                /* Store sink */
                inst->aghfp_sink = cfm->rfcomm_sink;
                /* Update state */
                setAghfpState(inst, AghfpStateConnected);
				/* Get the current role */
				ConnectionGetRole(&the_app->task, inst->aghfp_sink);
                /* Profile connection complete function */
                profileSlcConnectCfm(inst, ProfileAghfp, current_state == AghfpStatePaged ? TRUE : FALSE);    
            }
            else
            {    
                /* SLC connect attempt failed */   
				/* don't retry to connect */
#if 0				
                the_app->s_connect_attempts += 1;
                             
                if ( (current_state == AghfpStatePaging) )
                {    /* Try connection attempt again */
                    AghfpSlcConnect(inst->aghfp, &inst->bd_addr);
                }
                else 
#endif					
				if ( cfm->status == aghfp_connect_key_missing )
                {
                    /* Delete link key from our side and try again */
                    ConnectionSmDeleteAuthDevice( &inst->bd_addr );
                    AghfpSlcConnect(inst->aghfp, &inst->bd_addr);
                }
                else
                {
                    inst->aghfp = 0;
                    setAghfpState(inst, AghfpStateDisconnected);
                    MessageSend(&inst->task, APP_INTERNAL_DESTROY_REQ, 0);
					if (the_app->app_state == AppStateConnecting)
						setAppState(AppStateIdle);
                }
            }
            break;
        }      
        case AghfpStateConnected:
        {
            DEBUG_AGHFP(("  - ignored\n"));
            break;
        }
        default:
        {
            aghfpUnhandledMessage(inst, AGHFP_SLC_CONNECT_CFM);
        }
    }
}