Ejemplo n.º 1
0
void headsetHandleAuthenticateCfm(const CL_SM_AUTHENTICATE_CFM_T *cfm)
{
    /* Leave bondable mode if successful unless we got a debug key */
    if (cfm->status == auth_status_success && cfm->key_type != cl_sm_link_key_debug)
    {
        /* Send a user event to the app for indication purposes */
        MessageSend (&theHeadset.task , EventPairingSuccessful , 0 );
    }
	
	/* Set up some default params and shuffle PDL */
	if(cfm->bonded)
	{	
		uint8 lAttributes[ATTRIBUTE_SIZE];
		/* Default volume set */
		lAttributes[attribute_hfp_volume] = theHeadset.gHfpVolumeLevel;	
		lAttributes[attribute_a2dp_volume] = theHeadset.gAvVolumeLevel;
		/* No profile set */
		lAttributes[attribute_hfp_hsp_profile] = 0;	
		lAttributes[attribute_a2dp_profile] = 0;	
		/* No SEID */
		lAttributes[attribute_seid] = 0;
		/* No clock rate mismatch */
		lAttributes[attribute_clock_mismatch] = 0;
	
		/* Write params to PS */
		ConnectionSmPutAttribute(PSKEY_ATTRIBUTE_BASE, &cfm->bd_addr, ATTRIBUTE_SIZE, lAttributes); 
		/* Shuffle the PDL around the device */
		ConnectionSmUpdateMruDevice(&cfm->bd_addr);
		
	}

    /* reset pairing info if we timed out on confirmation */
    AuthResetConfirmationFlags();
}
Ejemplo n.º 2
0
/****************************************************************************
NAME
    deviceManagerStoreAttributes
    
DESCRIPTION
    Stores given attribute values against a given device in PS.

RETURNS
    void
*/
void deviceManagerStoreAttributes(sink_attributes* attributes, const bdaddr* dev_addr)
{
#ifdef ENABLE_SHAREME
    DEV_DEBUG(("DEV: StoreAttribs   - profiles %d, peer %d, hfp_vol %d, a2dp_vol %d\n", attributes->profiles, attributes->peer_device, attributes->hfp.volume,attributes->a2dp.volume));
#else
    DEV_DEBUG(("DEV: StoreAttribs   - profiles %d, hfp_vol %d, a2dp_vol %d\n", attributes->profiles, attributes->hfp.volume,attributes->a2dp.volume));
#endif
    ConnectionSmPutAttribute(PSKEY_ATTRIBUTE_BASE, dev_addr, sizeof(sink_attributes), (uint8*)attributes); 
}
static void handleA2DPOpenInd(Sink sink, uint8 seid)
{
    bdaddr bdaddr_ind;
    
    SendEvent(EVT_A2DP_OPEN_IND,0);

	if (SinkGetBdAddr(sink, &bdaddr_ind))
	{
		uint8 lAttributes[ATTRIBUTE_SIZE];
		
		avrcpConnectReq(bdaddr_ind, FALSE);
					
		/* Retrieve attributes for this device */
    	if (ConnectionSmGetAttributeNow(PSKEY_ATTRIBUTE_BASE, &bdaddr_ind, ATTRIBUTE_SIZE, lAttributes))
		{
			bool write_params = FALSE;
			if (lAttributes[attribute_seid] != seid)
			{
				lAttributes[attribute_seid] = seid;
				write_params = TRUE;
			}
			if (lAttributes[attribute_a2dp_volume] != theHeadset.gAvVolumeLevel)
			{
				lAttributes[attribute_a2dp_volume] = theHeadset.gAvVolumeLevel;
				write_params = TRUE;
			}
			if (write_params)
			{
				/* Write params to PS */
				ConnectionSmPutAttribute(PSKEY_ATTRIBUTE_BASE, &bdaddr_ind, ATTRIBUTE_SIZE, lAttributes); 
				A2DP_MSG_DEBUG(("A2DP: Store A2DP attributes [%d][%d][%d][%d][%d][%d]\n",lAttributes[0],
			   		lAttributes[1],lAttributes[2],lAttributes[3],lAttributes[4],lAttributes[5])) ;
			}
		}
	    
		theHeadset.seid = seid;
		theHeadset.last_used_seid = seid;
		A2DP_MSG_DEBUG(("    Selected SEID = %d\n", seid));
		stateManagerEnterA2dpConnectedState();
		PROFILE_MEMORY(("A2DPOpen"))
	}
void hfpHandlerDisconnectInd(const HFP_SLC_DISCONNECT_IND_T *ind)
{	
	bdaddr ag_addr;
	bool last_ag = FALSE;
	
	/* Check if this was the result of an abnormal link loss */
    if (ind->status == hfp_disconnect_link_loss ) 
    {	
        HFP_DEBUG(("HFP: Link Loss Detect\n")) ;
               
        MessageSend( &theHeadset.task , EventLinkLoss , 0 ) ;
    }
    else
    {
		theHeadset.combined_link_loss = FALSE;
    }
	
	if (last_ag)
	{
		uint8 lAttributes[ATTRIBUTE_SIZE];
		/* Retrieve attributes for this device */
    	if (ConnectionSmGetAttributeNow(PSKEY_ATTRIBUTE_BASE, &ag_addr, ATTRIBUTE_SIZE, lAttributes))
		{
			bool write_params = FALSE;
			if (!lAttributes[attribute_hfp_hsp_profile])
			{
				lAttributes[attribute_hfp_hsp_profile] = ATTRIBUTE_GET_HF_PROFILE(theHeadset.profile_connected);
				write_params = TRUE;
			}
			if (lAttributes[attribute_hfp_volume] != theHeadset.gHfpVolumeLevel)
			{
				lAttributes[attribute_hfp_volume] = theHeadset.gHfpVolumeLevel;
				write_params = TRUE;
			}
			if (write_params)
			{
				/* Write params to PS */
				ConnectionSmPutAttribute(PSKEY_ATTRIBUTE_BASE, &ag_addr, ATTRIBUTE_SIZE, lAttributes); 
				HFP_DEBUG(("HFP: Store HFP attributes [%d][%d][%d][%d][%d][%d]\n",lAttributes[0],
				   lAttributes[1],lAttributes[2],lAttributes[3],lAttributes[4],lAttributes[5])) ;
			}
		}
	}
	
	/*	
        Handle the case where an incoming call is rejected using the headset profile.
		As we get no indicator info, the AV must be restarted on a SLC disconnect.
	*/
    if ((theHeadset.profile_connected == hfp_headset_profile))
    {
        streamControlResumeA2dpStreaming(0);
    }
    
    /* Update the app state if we are connected */
    if ( stateManagerIsHfpConnected() )
    {
        stateManagerEnterHfpConnectableState( FALSE ) ;
    }
    
    MessageSend(&theHeadset.task , EventSLCDisconnected , 0) ;
    
        /* Connection disconnected */
    theHeadset.profile_connected = hfp_no_profile;
	theHeadset.hfp_hsp = NULL;

	/* Reset in-band ring tone support flag */
	theHeadset.InBandRingEnabled = FALSE;
	
	/* Update Link Policy as HFP has disconnected. */
	linkPolicySLCdisconnect();
	
    PROFILE_MEMORY(("HFPDisco"))

}