示例#1
0
void prh_l2_chn_start_RTX_timer(prh_t_l2_channel* p_channel)
{
    p_channel->timer_active = 01;
    if (p_channel->timer_handle)
		pTimerCancel(p_channel->timer_handle);
    p_channel->timer_handle=pTimerCreate((unsigned int)PRH_L2_RTX_TIMEOUT_VALUE,prh_l2_chn_timer_expired,(void*)p_channel,pTIMER_ONESHOT);
}
示例#2
0
t_api prh_tcs_cc_core_GW_releaseNonSelectedBCastCalls(void)
{
	int i;
	struct st_t_TCS_callParams callParams;
	struct st_t_TCS_callInstance *callInstance;
	t_api status;

	callParams.bitMask = PRH_TCS_CC_PARAM_CAUSE;
	callParams.cause = PRH_TCS_CAUSE_NONSELECTEDUSERCLEARING;

	for(i=0; i<PRH_TCS_MAXTERMINALSPERGATEWAY; i++)
	{
		if(TCSInstance.TLPeer[i])
		{
			callInstance = TCSInstance.TLPeer[i]->bcastCallInstance;
			if(callInstance)
			{
				callInstance->state = PRH_TCS_DISCONNECTREQUEST;
				status = prh_tcs_cc_encodeMsg(PRH_TCS_MSG_DISCONNECT, &callParams, callInstance->cid);
				if(BT_NOERROR == status)
				{
					pDebugPrintfEX((pLOGDEBUG,pLOGTCS,"TCS: Sent RELEASE, call handle=%d", callInstance->callHandle));
				    callInstance->timerHandle=pTimerCreate(PRH_TCS_TIMER_T308, prh_tcs_cc_callback_timeout, (void *)callInstance, pTIMER_ONESHOT); 
				}
			}
			
		}
	}

	return BT_NOERROR;
}
示例#3
0
void prh_l2_acl_start_RTX_timer(u_int16 handle)
{
    prh_t_l2_acl_link* p_link = prh_l2_acl_find_handle(handle);
  
    p_link->timer_handle=pTimerCreate((unsigned int)PRH_L2_RTX_TIMEOUT_VALUE,
        prh_l2_acl_timer_expired,p_link,pTIMER_ONESHOT);
    p_link->timer_active = 0x01;
}
示例#4
0
/* this is called by a timer callback at intervals of HOST_INQDB_CULL_GRANULARITY */
void prh_mgr_cull_inquiry_db(void *unused) {

    extern u_int8 prh_mgr_inquiryInProgress;
	extern u_int32 prh_mgr_inqdb_num_entries;
    /* increment each age by one, and remove any old entry  */
    struct st_t_BT_InquiryInfo *current, *temp;
	char err_str[50]={0};




    pMutexLock(prh_mgr_inqdb_list_lock);

    if (!(prh_mgr_discoveryInProgress || prh_mgr_inquiryInProgress)) {
        if (!prh_mgr_inqdb_num_entries) {
            pMutexUnlock(prh_mgr_inqdb_list_lock);
            return;
        }
    
        current=prh_mgr_inqdb_head;

        while (current) {
            temp=current->next;
            if (current->entryAge>HOST_INQDB_CULL_THRESHOLD && prh_mgr_inqdb_num_entries>HOST_INQDB_CULL_MIN_ENTRIES && !current->entryUsage) {
                /* remove the record */
                pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_cull_inquiry_db: removing device entry for %s, age=%d, prh_mgr_inqdb_num_entries=%d\n",prh_mgr_printBDAddress(current->bdAddress),current->entryAge,prh_mgr_inqdb_num_entries));

                prh_mgr_unlink_inquiry_entry(current);
                if (current->deviceName)
                    pFree(current->deviceName);
                pFree(current);

                prh_mgr_inqdb_num_entries--;   

            } else {
                if (current->entryAge+1>current->entryAge && current->entryAge!=0) /* don't allow age to wrap, age=0 means inquiry is in progress */
                    current->entryAge++;
            }        
            current=temp;
        }
    }

    if (prh_mgr_inqdb_num_entries) /* reset the timer */
        prh_mgr_inqdb_timer_handle=pTimerCreate(HOST_INQDB_CULL_GRANULARITY,prh_mgr_cull_inquiry_db,NULL,pTIMER_ONESHOT);

    pMutexUnlock(prh_mgr_inqdb_list_lock);  
}
示例#5
0
t_api prh_tcs_cc_core_broadcastIncomingSETUP(struct st_t_TCS_callParams *callParams)
{

    u_int16 groupCID;
	t_bdaddr *bdAddress;
	t_api status = BT_NOERROR;
    static struct st_t_TCS_callParams *broadcastRepeatcallParams;
	
    prh_tcs_cc_core_freeCallParamMembers(broadcastRepeatcallParams);

	if(TCSInstance.pendingBroadcastSETUP)
		{
		pTimerCancel(TCSInstance.broadcastSETUPtimer);
		TCSInstance.broadcastSETUPtimer=0;
		}
	
	else
		TCSInstance.pendingBroadcastSETUP = 1;
	
	bdAddress = prh_tcs_l2cap_findConnectedTL();
	if(bdAddress)
	{
		status = L2_GroupCreate(PRH_TCS_PSM_TCSCORDLESS, &groupCID);
		if(BT_NOERROR == status)
        {
            prh_tcs_groupAddMemberEvent=pEventCreate(FALSE);
            status = L2_GroupAddMember(groupCID, *bdAddress, prh_tcs_groupAddMember);
        }
        if(BT_PENDING == status)
        {   
            pEventWait(prh_tcs_groupAddMemberEvent);
            if(groupAddMemberStatus == HCI_errNOERROR)
            {
                if (groupAddMemberCid != groupCID || pMemcmp(&groupAddMemberBdaddr,bdAddress,sizeof(t_bdaddr)) != 0x00)
                {
                    return BT_UNKNOWNERROR;
                }                
            }   
            else
            {
                return BT_UNKNOWNERROR;	        
            }

            status = BT_NOERROR;
        }
		if(BT_NOERROR == status)
        {    
            status = prh_tcs_cc_encodeMsg(PRH_TCS_MSG_SETUP, callParams, groupCID);
            TCSInstance.broadcastGroupCID = groupCID;
            /* set up the timer that will timeout if there is no reply */
            TCSInstance.broadcastSETUPtimer=pTimerCreate(PRH_TCS_TIMER_T303, prh_tcs_cc_callback_broadcastSETUP_timeout, NULL, pTIMER_ONESHOT); 
            prh_tcs_cc_core_storeCallParams(&broadcastRepeatcallParams, callParams);
            /* setup the timer that will fire and re-transmit the broadcast SETUP message at a period of PRH_TCS_TIMER_BCASTSETUPREPEAT */
            TCSInstance.broadcastRepeatSETUPtimer=pTimerCreate(PRH_TCS_TIMER_BCASTSETUPREPEAT, prh_tcs_cc_callback_bcast_setup_repeat_timeout, (void *)broadcastRepeatcallParams, pTIMER_ONESHOT); 
        }
        
		if(BT_NOERROR == status)
			pDebugPrintfEX((pLOGDEBUG,pLOGTCS,"TCS: Sent Broadcast SETUP, group CID=%d", groupCID));

	}
	else
		status = BT_UNKNOWNERROR;
	
	return status;
}
示例#6
0
static HUB_MSG *InsertConnectState(
    Filter &filter,
    State &state,
    HUB_MSG *pInMsg,
    BOOL pinState,
    BOOL timeout = FALSE)
{
  _ASSERTE(filter.delayDisconnect || (!timeout && !state.hDelayDisconnectTimer));

  if (!timeout)
    state.last_connect = filter.negative ? !pinState : pinState;

  //cout << "beg timeout=" << timeout << " connect=" << state.connect << " last_connect=" << state.last_connect << endl;

  if (state.connect != state.last_connect) {
    if (!state.last_connect && filter.delayDisconnect) {
      if (!timeout) {
        if (!state.hDelayDisconnectTimer) {
          state.hDelayDisconnectTimer = pTimerCreate((HTIMEROWNER)&state);

          if (state.hDelayDisconnectTimer) {
            LARGE_INTEGER firstReportTime;

            firstReportTime.QuadPart = -10000LL * filter.delayDisconnect;

            pTimerSet(
                state.hDelayDisconnectTimer,
                state.hMasterPort,
                &firstReportTime, 0,
                (HTIMERPARAM)state.hDelayDisconnectTimer);

            //cout << "pTimerSet" << endl;
          }
        }
      } else {
        pInMsg = pMsgInsertVal(pInMsg, HUB_MSG_TYPE_CONNECT, state.connect = state.last_connect);

        //cout << "HUB_MSG_TYPE_CONNECT connect=" << state.connect << endl;

        if (state.hDelayDisconnectTimer) {
          pTimerDelete(state.hDelayDisconnectTimer);
          state.hDelayDisconnectTimer = NULL;

          //cout << "pTimerDelete" << endl;
        }
      }
    } else {
      pInMsg = pMsgInsertVal(pInMsg, HUB_MSG_TYPE_CONNECT, state.connect = state.last_connect);

      //cout << "HUB_MSG_TYPE_CONNECT connect=" << state.connect << endl;
    }
  } else {
    if (state.hDelayDisconnectTimer) {
      pTimerDelete(state.hDelayDisconnectTimer);
      state.hDelayDisconnectTimer = NULL;

      cout << "pTimerDelete" << endl;
    }
  }

  return pInMsg;
}
示例#7
0
void rdabt_ServiceSearch_cb(u_int8 status)			
{
 //   t_SDP_Element *pCurrentResult = NULL;
    bt_bm_service_search_result_ind_struct * result_ind = NULL;
  //  bt_bm_service_search_cnf_struct	* service_cnf=NULL;

  //  u_int32 	numRecords = 0;
  //  u_int8 	*pData = NULL;

    u_int8  i=0, j=0, k= 0, bfinded=0;

    kal_prompt_trace(1, "rdabt_ServiceSearch_cb pResults->element.dataLen=%d  pResults->element.pData=%x", pResults->element.dataLen,pResults->element.pData);
        pincode_sent=0;
    status = pResults->status;
    if(status == BT_NOERROR)
    {
        memset(&uuid_finded, 0, sizeof(t_SDP_service_Parse_Results));
        if(pResults->element.dataLen!=0)
            status = sdp_service_parse(pResults, &uuid_finded);

        for(i=0;i<BTBM_ADP_MAX_SDAP_UUID_NO;i++)
        {
            if(uuid_finded.service[i].SC_uuid==0)
                break;
            kal_prompt_trace(1, "SC_uuid[%d]=%x, PDL_uuid=%x, chn_num=%d total_search=%d\n", i, uuid_finded.service[i].SC_uuid, uuid_finded.service[i].PDL_uuid,uuid_finded.service[i].chn_num, uuid_finded.total_searched);
        }
        kal_prompt_trace(1,"find %d profiles", i);

    }

    i=0;
    for(j=0;j<uuid_finded.total_searched;j++)
    {
        bfinded=0;
        for(k=0;k<pin_code_sdap.sdap_len;k++)
        {
            if(pin_code_sdap.sdap_uuid[k]==uuid_finded.service[j].SC_uuid)
            bfinded=1;
            i++;
            
        }
        
        if(bfinded)
        {
            result_ind = (bt_bm_service_search_result_ind_struct*)construct_local_para((kal_uint16)sizeof(bt_bm_service_search_result_ind_struct), TD_CTRL);
            result_ind->uuid = uuid_finded.service[j].SC_uuid;
   
            result_ind->bd_addr.lap = pin_code_sdap.bd_addr.lap;
            result_ind->bd_addr.uap = pin_code_sdap.bd_addr.uap;
            result_ind->bd_addr.nap = pin_code_sdap.bd_addr.nap;
	     kal_prompt_trace(1,"MSG_ID_BT_BM_SERVICE_SEARCH_RESULT_IND");
            rdabt_send_msg_up(MOD_MMI, MSG_ID_BT_BM_SERVICE_SEARCH_RESULT_IND, (void *)result_ind, NULL);
        }

    }

	  sdp_result = status;
	  sdp_searched_number = i;

    //if(MGR_GetACLState(pResults->element.deviceAddress) != 2)//CONN_CLOSED
    if(!(MGR_GetACLState(pResults->element.deviceAddress)%4))//CONN_RELEASEPENDING CONN_NONE zhou siyou 20100722
	{
		if ( (rdabt_oppsp->OPPSstatus == GOEP_Client_Connect) || (rdabt_ftpsp->FTPSstatus == GOEP_Client_Connect))
		{
			rdabt_ServiceSearch_cb_ReleaseACL(NULL,0);
		}
		else
		{
			if(!MGR_SetACLCallBack(pResults->element.deviceAddress,0,rdabt_ServiceSearch_cb_ReleaseACL))
				kal_prompt_trace(0, "MGR_SetACLCallBack!@!!!!!!");	
			else
			{
				kal_prompt_trace(0, "MGR_SetACLCallBack fail");
			}
			if(SDP_ReleaseACL_timer)
				pTimerCancel(SDP_ReleaseACL_timer);
			SDP_ReleaseACL_timer = pTimerCreate(30,(rdabt_timer_func)rdabt_ServiceSearch_cb_timeout,NULL,pTIMER_ONESHOT);//60 is 6 secend		
		}	
	}
	else
	{
		rdabt_ServiceSearch_cb_ReleaseACL(NULL,0);
	}

}
示例#8
0
/*************************************************************************************************
* FUNCTION :- prh_mgr_store_inquiry_entry
*
* DESCRIPTION :- This function stores an inquiry result in the inq db. If the device is already 
*                 in the database the parameters will be updates otherwise a new entry will be
*                 added to the inq db.
*                 NOTE:inquiryresult passed in is one set of page parameters, there may be many 
*                 in a single hci event                          
*                 
************************************************************************************************/
struct st_t_BT_InquiryInfo *prh_mgr_store_inquiry_entry(u_int8 *inquiryResult) 
{
    struct st_t_BT_InquiryInfo *current;
    
	extern u_int32 prh_mgr_inqdb_num_entries;
//    char err_str[40]={0};


	if(inquiryResult == NULL)
		return  NULL;
	
    pMutexLock(prh_mgr_inqdb_list_lock);

	current=prh_mgr_inqdb_head;

	pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: linklist is NULL? %d\n", prh_mgr_inqdb_head?1:0));

	
    while (current) 
    {
        if (BD_ADDR_CMP(current->bdAddress,*(t_bdaddr*)(inquiryResult+0))) /* check alignment correctness here */
            break;
        current=current->next;
    }
#if pDEBUG
    if (!current) 
    {
        pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: cannot find existing entry for device %s\n",prh_mgr_printBDAddress(*(t_bdaddr*)(inquiryResult+0))));
    } 
#endif

    if (current) 
   {
        if(current->entryUsage)
	{
            /* entry already exists, but is in use, so cannot be updated */
	    pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: cannot find existing entry for device %s\n",prh_mgr_printBDAddress(*(t_bdaddr*)(inquiryResult+0))));

            pMutexUnlock(prh_mgr_inqdb_list_lock);
            return current;
        }
	else 
	{
            prh_mgr_unlink_inquiry_entry(current);
        }
    } 
   else 
   {  
        pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: prh_mgr_inqdb_num_entries=%d\n", prh_mgr_inqdb_num_entries));
        if (prh_mgr_inqdb_num_entries<(u_int32)HOST_INQDB_MAX_DEVICE_ENTRIES) 
        {
            /* alloc a new record */
            current=pMalloc(sizeof(struct st_t_BT_InquiryInfo));
            if (!current) 
            {
                pMutexUnlock(prh_mgr_inqdb_list_lock);
                return NULL;
            }
			current->deviceName = NULL;

#if HOST_INQDB_CULL_THRESHOLD!=0
            if (!prh_mgr_inqdb_num_entries)  /* we are adding to an empty database */
                prh_mgr_inqdb_timer_handle=pTimerCreate(HOST_INQDB_CULL_GRANULARITY,prh_mgr_cull_inquiry_db,NULL,pTIMER_ONESHOT);
#endif

            prh_mgr_inqdb_num_entries++;
        } 
        else 
        {
            /* find the oldest non-inuse record */        
            current=prh_mgr_inqdb_tail;
            while (current) 
            {
                if (current->entryUsage)
                    current=current->prev;
                else
                    break;
            }

            if (!current) 
            {
                /* no available entry */
                pMutexUnlock(prh_mgr_inqdb_list_lock);
                pDebugPrintfEX((pLOGNOTICE,pLOGMANAGER,"prh_mgr_store_inquiry_entry: prh_mgr_inqdb_num_entries==HOST_INQDB_MAX_DEVICE_ENTRIES (%d) and  all entries in use\n",HOST_INQDB_MAX_DEVICE_ENTRIES));
                return NULL;
            }
            prh_mgr_unlink_inquiry_entry(current);
        }

        current->entryAge=1; /* only modified when an entry did not already exist for this adress */
		current->nameRetrieved = 0;
    }
    
    //Lu added
    

    /* fill out the parameters */
    pMemcpy(&current->bdAddress,inquiryResult+0,6);
    current->pageScanRepetitionMode=inquiryResult[6];
    current->pageScanPeriodMode=inquiryResult[7];
    current->pageScanMode=inquiryResult[8];
    current->classOfDevice=inquiryResult[9]|(inquiryResult[10]<<8)|(inquiryResult[11]<<16);
    current->clockOffset=inquiryResult[12]|(inquiryResult[13]<<8);

	/* Do not fill in current->deviceName until RemoteNameRequest is complete */

    current->entryUsage=1; /* entry starts marked as 'in-use' */

    /* add this new record (to the head of the list) */
    current->next=prh_mgr_inqdb_head;
    current->prev=NULL;
    if (current->next)
        current->next->prev=current;
    prh_mgr_inqdb_head=current;   
    if (!prh_mgr_inqdb_tail)
        prh_mgr_inqdb_tail=current;

    pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: current->entryAge=%d, current->classOfDevice=0x%x\n", current->entryAge,current->classOfDevice));


    pMutexUnlock(prh_mgr_inqdb_list_lock);
    return current;
}
示例#9
0
void prh_l2_chn_start_cfg_timer(prh_t_l2_channel* p_channel)
{
	if (p_channel->config_timer_handle==0)
		p_channel->config_timer_handle=pTimerCreate((unsigned int)PRH_L2_CFG_TIMEOUT_VALUE,
			prh_l2_chn_cfg_timer_expired,(void*)p_channel,pTIMER_ONESHOT);
}