示例#1
0
void bt_simap_start_timer(void *timer_id_p, kal_uint32 timer_duration, kal_timer_func_ptr funct_ptr)
{
	EvmTimer *p_timer;

	p_timer = (EvmTimer *) timer_id_p;
	p_timer->context = NULL;
	p_timer->func = (EvmTimerNotify)funct_ptr;
	
	EVM_StartTimer(p_timer, timer_duration);
}
示例#2
0
static void avrcpQueryCallback(SdpQueryToken *sqt, U8 result, U8 serv_chn)
{
    SdpQueryToken *token;
    BtRemoteDevice *remDev;
    AvrcpChannel *chnl = ContainingRecord(
                                                                    sqt, 
                                                                    AvrcpChannel, 
                                                                    sdpQueryToken
                                                                    );

    
    token  = sqt;
    if(chnl->cmgrHandler.bdc ==0)
    {
        /* 
            The remote side connects our AVRCP after we send avrcp connect req.
            We will reject the remote side avrcp connect req but will get a disconnect ind.
            The Avrcp connect req from our side will think the connect requestion is failed and 
            remove the cmgr and rem at the same time.
        */
        if (sqt->rm !=0)
            sqt->rm->discFlag = 1;
        return;
    }

    remDev = chnl->cmgrHandler.bdc->link;
#if 1    
    kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_QUERY_CB, result);
    switch (result) 
    {
        case BT_STATUS_SUCCESS:
//            status = AVCTP_Connect(&chnl->chnl, remDev);
            if(chnl->conntimer.func!=0)
                EVM_CancelTimer(&chnl->conntimer);
            chnl->conntimer.func = AVRCP_Connect_Timeout;
            chnl->conntimer.context = remDev;
            EVM_StartTimer(&chnl->conntimer, 20);
            /* AVRCP implementor shall handle the status report, ESI not handle it!*/                
            break;
        case BT_STATUS_CONNECTION_FAILED:
            break;
        case BT_STATUS_FAILED:
            AvrcpReportFailedConnect(chnl);
            /* Do we not indicate this back somehow? */
            break;
        case BT_STATUS_NOSERVICES:
            AvrcpReportFailedConnect(chnl);
            break;
    }
#endif

//    AVCTP_Connect(&chnl->chnl, remDev);

}
示例#3
0
void BT_Gatt_ResetDisconnectTimer(BtGattConn *conn)
{
#if 0
    BtDeviceContext *bdc;
    
    Report(("BT_Gatt_ResetDisconnectTimer value:%d", conn->disconnectTimerValue));
    bdc = DS_FindDevice((const BD_ADDR *)&conn->link->bdAddr);
    if (bdc)
    {
        if(bdc->devType != BT_DEV_TYPE_LE) 
        {
            Report(("Not BLE type, return directly"));
            return;
        }
    }
    conn->disconnectTimer.func = BT_GATT_DisconnectTimeoutHandler;
    conn->disconnectTimer.context = conn;
    EVM_StartTimer(&conn->disconnectTimer, conn->disconnectTimerValue);
#endif
}
示例#4
0
void btadp_jsr82_session_disconnect(BT_ADP_JSR82_SESSION *session)
{
	SESSION_RESULT	sret = SR_NOERROR;

	ASSERT(session);

	OS_Report("[JSR82]btadp_jsr82_session_disconnect");

	if (session->conn_state != BT_ADP_JSR82_STATE_CONNECTED )
	{
		OS_Report("[JSR82]SR_E_INVALID_PARAM");	
		sret = SR_E_INVALID_PARAM;
		goto exit;
	}
	session->attach_state == BT_JSR82_SESSION_STATE_DETACHED;

	if (BT_ADP_JSR82_STATE_DISCONNECTING == session->conn_state)
	{
		OS_Report("[JSR82]channel has already been being disconnecting");
		goto exit;
	}

	//TODO: these code should be remove to btcore layer
	if (TRUE == jsr82_session_DataRemainInBuff(session->ps_type, 
													session->index,
													session->l2cap_id))
	{
		EVM_ResetTimer(&(session->timer));
		session->timer.func = btadp_jsr82_session_disconnect_timeout;
		session->timer.context = session;
		EVM_StartTimer(&(session->timer), 1000);
	}
	else
	{
		session->timer.context = session;
		btadp_jsr82_session_disconnect_timeout(&(session->timer));
	}
exit:
	bt_session_destroy(session->sessionid);

}
示例#5
0
/*************************************************************************
* FUNCTION                                                            
*	avrcpQueryCTCallback
* DESCRIPTION                                                           
*   The function is called by SDAP to indicate the profiles the search result
*   Modified by MTK Dlight mtk01239
*
* PARAMETERS
*	sqt  : SdpQueryToken contains information such as remote device information. uuid...
*	result  : The service search result.
*      serv_chn: It is not used in AVRCP profile
* RETURNS
*	None
* LOCAL AFFECTED
*   
*************************************************************************/
void avrcpQueryCTCallback(SdpQueryToken *sqt, U8 result, U8 attribute_index, U8 *attribute_value)
{
    SdpQueryToken *token;
    BtRemoteDevice *remDev;
    U16 feature = 0;
    BtStatus status = 0;
    
    AvrcpChannel *chnl = ContainingRecord(
                                                                    sqt, 
                                                                    AvrcpChannel, 
                                                                    sdpQueryToken
                                                                    );

    
    token  = sqt;
    if(chnl->cmgrHandler.bdc ==0)
    {
        /* 
            The remote side connects our AVRCP after we send avrcp connect req.
            We will reject the remote side avrcp connect req but will get a disconnect ind.
            The Avrcp connect req from our side will think the connect requestion is failed and 
            remove the cmgr and rem at the same time.
        */
        if (sqt->rm !=0)
            sqt->rm->discFlag = 1;
        return;
    }

    remDev = chnl->cmgrHandler.bdc->link;
    
    if( chnl ){
    	/// has do the search 
    	chnl->remoteCTSdp.ctValid = TRUE;
    }
    
	kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_CT_CALLBACK , result, attribute_index);
    switch (result) 
    {
        case BT_STATUS_SUCCESS:
        	{
        		/// remote has a TG record
        		chnl->remoteCTSdp.ctAvailable= TRUE;
        		
	        	switch( avrcp_sdp_attribute_id_list[attribute_index] ){
	        		case AID_PROTOCOL_DESC_LIST:
	        			{
	        				/// update the result
	        				chnl->remoteCTSdp.ctVersion = BEtoHost16(attribute_value);

	        			}
	        			break;
					case AID_SUPPORTED_FEATURES:
	        			{
	        				/// update the result
	        				chnl->remoteCTSdp.ctFeatureFlag = BEtoHost16(attribute_value);
                            OS_Report("[AVRCP] SDP attr_value[0]:0x%x attr_value[1]:0x%x attr_value[2]:0x%x attr_value[3]:0x%x", attribute_value[0], attribute_value[1], attribute_value[2], attribute_value[3]);

    						chnl->remoteCTSdp.ctSupportBrowse = chnl->remoteCTSdp.ctFeatureFlag && 0x40;
                            OS_Report("[AVRCP] SDP chnl->remoteCTSdp.ctFeatureFlag:%d", chnl->remoteCTSdp.ctFeatureFlag);
							/// search is finished. try to connect
							if( 2 == avrcp_sdp_attribute_num ){
                                if( chnl->connFlag == 1 ){
								if(chnl->conntimer.func!=0)
									EVM_CancelTimer(&chnl->conntimer);
								chnl->conntimer.func = AVRCP_Connect_Timeout;
								chnl->conntimer.context = remDev;
								EVM_StartTimer(&chnl->conntimer, 20);
                                
                                AVRCP_UtilAVRCPSDPQueryInd(chnl, 0, chnl->remoteTGSdp.tgVersion, chnl->remoteTGSdp.tgFeatureFlag, chnl->remoteCTSdp.ctVersion, chnl->remoteCTSdp.ctFeatureFlag);
							}

	        			}

	        			}
	        			break;

					case AID_BT_PROFILE_DESC_LIST: //case AID_ADDITIONAL_PROT_DESC_LISTS:
						{
   	        				chnl->remoteCTSdp.ctVersion = BEtoHost16(attribute_value);
   	        				status = parseAvrcpVersion(attribute_value, &feature);
							if( BT_STATUS_SUCCESS == status ){
							    chnl->remoteCTSdp.ctVersion = feature;
							}else{
							    OS_Report("[AVRCP] SDP error status:%d", status);    
							}
							kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_CT_INFO , chnl->remoteCTSdp.ctAvailable, chnl->remoteCTSdp.ctVersion, chnl->remoteCTSdp.ctFeatureFlag, chnl->remoteCTSdp.ctSupportBrowse);
                            OS_Report("[AVRCP] SDP ctVersion:%d", chnl->remoteCTSdp.ctVersion);

                            
                            if( chnl->connFlag == 1 ){
							if(chnl->conntimer.func!=0)
								EVM_CancelTimer(&chnl->conntimer);
							chnl->conntimer.func = AVRCP_Connect_Timeout;
							chnl->conntimer.context = remDev;
							EVM_StartTimer(&chnl->conntimer, 20);
						    }
                            
                            AVRCP_UtilAVRCPSDPQueryInd(chnl, 0, chnl->remoteTGSdp.tgVersion, chnl->remoteTGSdp.tgFeatureFlag, chnl->remoteCTSdp.ctVersion, chnl->remoteCTSdp.ctFeatureFlag);
						}
						break;
	        	}
	        }             
            break;
        case BT_STATUS_CONNECTION_FAILED:
        case BT_STATUS_FAILED:
        case BT_STATUS_NOSERVICES:
        	{
				kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_CT_INFO , chnl->remoteCTSdp.ctAvailable, chnl->remoteCTSdp.ctVersion, chnl->remoteCTSdp.ctFeatureFlag, chnl->remoteCTSdp.ctSupportBrowse);

	        	/// NO TG record available => search CT
	        	/// One of CT or TG is available => try to conne	ct
	        	if( FALSE == chnl->remoteCTSdp.ctAvailable && FALSE == chnl->remoteTGSdp.tgAvailable ){
	            	AvrcpReportFailedConnect(chnl);
	            }else{
	            	/// After a TG connect
		            if(chnl->conntimer.func!=0)
		                EVM_CancelTimer(&chnl->conntimer);
		            chnl->conntimer.func = AVRCP_Connect_Timeout;
		            chnl->conntimer.context = remDev;
		            EVM_StartTimer(&chnl->conntimer, 20);
	            }
                
                AVRCP_UtilAVRCPSDPQueryInd(chnl, 1, 0, 0, 0 , 0);
        	}
            break;
    }

}
示例#6
0
/*************************************************************************
* FUNCTION                                                            
*	avrcpQueryTGCallback
* DESCRIPTION                                                           
*   The function is called by SDAP to indicate the profiles the search result
*
* PARAMETERS
*	sqt  : SdpQueryToken contains information such as remote device information. uuid...
*	result  : The service search result.
*   serv_chn: It is not used in AVRCP profile
* RETURNS
*	None
* LOCAL AFFECTED
*   
*************************************************************************/
void avrcpQueryTGCallback(SdpQueryToken *sqt, U8 result, U8 attribute_index, U8 *attribute_value)
{
    SdpQueryToken *token;
    BtRemoteDevice *remDev;
    AvrcpChannel *chnl = ContainingRecord(
                                                                    sqt, 
                                                                    AvrcpChannel, 
                                                                    sdpQueryToken
                                                                    );
    
    token  = sqt;
    if(chnl->cmgrHandler.bdc ==0)
    {
        /* 
            The remote side connects our AVRCP after we send avrcp connect req.
            We will reject the remote side avrcp connect req but will get a disconnect ind.
            The Avrcp connect req from our side will think the connect requestion is failed and 
            remove the cmgr and rem at the same time.
        */
        if (sqt->rm !=0)
            sqt->rm->discFlag = 1;
        return;
    }

    if( chnl ){
    	/// has do the search 
    	chnl->remoteTGSdp.tgValid = TRUE;
    }
    remDev = chnl->cmgrHandler.bdc->link;

    kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_TG_CALLBACK , result, attribute_index);
    switch (result) 
    {
        case BT_STATUS_SUCCESS:
        	{
        		/// remote has a TG record
        		chnl->remoteTGSdp.tgAvailable= TRUE;
        		
	        	switch( avrcp_sdp_attribute_id_list[attribute_index] ){
	        		case AID_PROTOCOL_DESC_LIST:
	        			{
	        				/// update the result
	        				chnl->remoteTGSdp.tgVersion = BEtoHost16(attribute_value);
	        			}
	        			break;
					case AID_SUPPORTED_FEATURES:
						{
	        				/// update the result
	        				chnl->remoteTGSdp.tgFeatureFlag = BEtoHost16(attribute_value);
	        				
							/// search is finished. try to connect
							if( 2 == avrcp_sdp_attribute_num ){
                                if( chnl->connFlag == 1 ){ // pending connect
								if(chnl->conntimer.func!=0)
									EVM_CancelTimer(&chnl->conntimer);
								chnl->conntimer.func = AVRCP_Connect_Timeout;
								chnl->conntimer.context = remDev;
								EVM_StartTimer(&chnl->conntimer, 20);
							}

                                AVRCP_UtilAVRCPSDPQueryInd(chnl, 0, chnl->remoteCTSdp.ctFeatureFlag, chnl->remoteTGSdp.tgFeatureFlag);
							}
	        			}
	        			break;
					case AID_BT_PROFILE_DESC_LIST: //AID_ADDITIONAL_PROT_DESC_LISTS:
						{
							chnl->remoteTGSdp.tgSupportBrowse = BEtoHost16(attribute_value);

							kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_TG_INFO , chnl->remoteTGSdp.tgVersion, chnl->remoteTGSdp.tgFeatureFlag, chnl->remoteTGSdp.tgSupportBrowse);
                            if( chnl->connFlag == 1 ){ // pending connect
							if(chnl->conntimer.func!=0)
								EVM_CancelTimer(&chnl->conntimer);
							chnl->conntimer.func = AVRCP_Connect_Timeout;
							chnl->conntimer.context = remDev;
							EVM_StartTimer(&chnl->conntimer, 20);
						}
                            AVRCP_UtilAVRCPSDPQueryInd(chnl, 0, chnl->remoteTGSdp.tgFeatureFlag, chnl->remoteCTSdp.ctFeatureFlag);

						}
						break;
	        	}
	        }
            /* AVRCP implementor shall handle the status report, ESI not handle it!*/                
            break;
        case BT_STATUS_CONNECTION_FAILED:
        case BT_STATUS_FAILED:
        case BT_STATUS_NOSERVICES:
        	/// NO CT or TG record available => report fail
        	/// One of CT or TG is available => try to connect
			kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_TG_INFO , chnl->remoteTGSdp.tgAvailable, chnl->remoteTGSdp.tgVersion, chnl->remoteTGSdp.tgFeatureFlag, chnl->remoteTGSdp.tgSupportBrowse);

        	if( FALSE == chnl->remoteCTSdp.ctAvailable && FALSE == chnl->remoteTGSdp.tgAvailable ){
				// search remote's CT role and try to connect it
                AvrcpStartMultiServiceQuery(chnl, BSQM_FIRST, AVRCP_TG); // local is TG
            }else{
            	/// After a TG connect
	            if(chnl->conntimer.func!=0)
	                EVM_CancelTimer(&chnl->conntimer);
	            chnl->conntimer.func = AVRCP_Connect_Timeout;
	            chnl->conntimer.context = remDev;
	            EVM_StartTimer(&chnl->conntimer, 20);
            }
            
            AVRCP_UtilAVRCPSDPQueryInd(chnl, 1, 0, 0);

            break;
    }
}