⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iap_s.c

📁 MTK平台绝密核心代码之 外设管理(红外线)
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------    
 *    IAP_S.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   This file contains reply part of IAP
 *
 * Author:
 * -------
 * -------
 *
 *****************************************************************************/
#include "kal_release.h"      /* Basic data type */
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h"       /* Task message communiction */
#include "stack_timer.h"      /* Stack timer */
#include "irda_enums.h"       /* irda enum */  
#include "gprs_flc_kal.h"   
#include "gprs_flc_common_data_types.h"
#include "flc_tunable_para.h"
#include "irconfig.h"	      /* IrPro system configuration */
#include "lap.h"	            /* LAP source header file */
#include "lmp.h"	            /* LMP source header file */
#include "iap_p.h"	         /* IAP primary stack header file */
#include "iap_s.h"	         /* IAP secondary stack header file */
#include "iastab.h"	         /* IAS table configuraton header file */
#include "support.h"	         /* system support functions */
#include "externs.h"	         /* system external definitions */
#include "stack_config.h"
#include "kal_trace.h"                     
#include "irda_trace.h"

kal_uint8 ias_sfsm;
kal_uint8 r_con_fsm;
static kal_uint8 remote_ias_client_sel;

extern const struct IASDATA iasdata[];
extern const kal_uint8 comm_params[];
extern const kal_uint8 comm_params_size;
extern const kal_uint16 ias_entries;
extern const kal_uint8 pnp_version[]; 


/*************************************************************************
* FUNCTION
*	Init_IAS_s
*
* DESCRIPTION
*	Initialize the IAP statemachines
*
* PARAMETERS
*  
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void Init_IAS_s ( void )
{
	ias_sfsm  = R_DISCONNECT;
	r_con_fsm = R_WAITING;
	remote_ias_client_sel=0;   
}

/*************************************************************************
* FUNCTION
*	IAS_Connect_Indication
*
* DESCRIPTION
*	Process the ias server connect indication
*
* PARAMETERS
*  kal_uint8 sel: Selector of the calling device
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void IAS_Connect_Indication( kal_uint8 sel )
{
FBUF* tmpptr;	

#ifdef IRDA_KAL_TRACE  
      kal_trace(TRACE_FUNC, IRDA_MSG51);  		
#endif   
		ias_sfsm= R_CALL;
		/* address is implicit */
		/* IAS server is at lsap 0, always! */
    	tmpptr=(FBUF*)Getbuf();    	
		/* add user data for response here */
		tmpptr->size=0;
		remote_ias_client_sel=sel;
      irda_lmp_flag=MSG_ID_LMP_CONNECT_RESPONSE;
      irda_data_buffer=tmpptr;
      local_lsap_sel=IAS_SERVER_LSAP_SEL;
      remote_lsap_sel=sel;
	
}


/*************************************************************************
* FUNCTION
*	IAS_Data_Indication
*
* DESCRIPTION
*	State Machine process frames received for the IAS server
*
* PARAMETERS
*  FBUF * frame: pointer to received frame
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void IAS_Data_Indication (kal_uint8 sel, FBUF *frame )
/* update the r-connect fsm */
{
kal_uint8 * tmpptr2;
#ifdef IRDA_KAL_TRACE  
    kal_trace(TRACE_FUNC, IRDA_MSG52);  		
#endif   
    if (ias_sfsm==R_CALL)
    {
	    tmpptr2=(kal_uint8*)frame+I_RX_OPCODE_OFFSET;

	    switch(r_con_fsm)
	    {
   		 case R_WAITING:			
   			if ((*tmpptr2&0xc0)==0x80)/*no ack and last frame*/
   			{
   				if ((*tmpptr2&0x3f)==4)/*GetValueByclass*/
   				{
   				/* we have a gvbc query *//* process and send the call-response */					
   					Decode_gvbc((kal_uint8*)tmpptr2+1);
   				}
   				else /* process and send the call-response */
   				{					
   					Send_ias_gvbc_response(UNSUPPORTED_TYP);
   				}
   			}
   			/* free the frame */ 
   			Freebuf(frame);          
   		   break;		
   		case R_RECEIVING:/* for now, these states are not necessary... */
   		   break;
   		case R_EXECUTE:
   		   break;
   		default:
   		   break;
	   }
   }
    return;
}

/*************************************************************************
* FUNCTION
*	IAS_Disconnect_Indication
*
* DESCRIPTION
*	State Machine process frames received for the IAS server
*
* PARAMETERS
*  FBUF * frame: pointer to received frame
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void IAS_Disconnect_Indication(void)
{    
   Init_IAS_s();
   Init_IAS_p();
}  


/*************************************************************************
* FUNCTION
*	Decode_gvbc
*
* DESCRIPTION
*	 Decode the GetValueByClass query
*
* PARAMETERS
*   kal_uint8 * ias_frame: pointer to the IAS argument list
* RETURNS
*	None
*
* GLOBALS AFFECTED
*  Decode the getvaluebyclass op and respond in a single frame
	       ias_frame points to first byte of the ias argument list
*************************************************************************/
void Decode_gvbc(kal_uint8* ias_frame)
{

kal_uint16 return_type=NO_CLASS_TYP;
kal_uint8 i,j;


#ifdef IRDA_KAL_TRACE  
   kal_trace(TRACE_FUNC, IRDA_MSG53);  		
#endif   
	for(i=0;i<ias_entries;i++)
	{
	    if (!xstrncmp((kal_char*)&ias_frame[1],(kal_char*)iasdata[i].class,ias_frame[0]))
	    {
		    return_type=NO_ATTR_TYP;
		    for(j=0;j<MAX_ATTRIBS;j++)
		    {
			    if (!xstrncmp((kal_char*)&ias_frame[ias_frame[0]+2],(kal_char*)iasdata[i].attrib[j],ias_frame[ias_frame[0]+1]))
			    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -