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

📄 mmigprs.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:
			}
			break;
	}

	return;
}


/*******************************************************************************

 $Function:    	GPRSIncomingDataCount

 $Description:	Show data counter for last incoming call

 $Returns:		

 $Arguments:	Standard menu option parameters
 
*******************************************************************************/

int GPRSIncomingDataCount(MfwMnu* m, MfwMnuItem* i)
{
	T_MFW_HND		win = mfw_parent(mfw_header());
	T_MFW_RES		result;
	
	TRACE_FUNCTION("GPRSIncomingDataCount()");

	mmi_gprs->counter_type = MMI_GPRS_COUNTER_DOWNLINK;	/* SPR#1875 - SH - Now DOWNLINK */
	mmi_gprs->display = TRUE;

	//mmi_gprs->gprsPleaseWait_win = mmiPleaseWait(win, TxtPleaseWait, NULL);  //ganchh primary code , comment out
	mmi_gprs->gprsPleaseWait_win =mmiPleaseWaitWindow(win, NULL,TxtPleaseWait ,0);   //0 means display
	result = gprs_counter(TRUE);

	switch(result)
	{
		case MFW_RES_OK:		/* Send request for counter information; don't reset */
			#ifdef TRACE_MMIGPRS
			TRACE_EVENT("gprs_counter executing, awaiting confirmation.");
			#endif
			break;

		case MfwResDone:
			mmiPleaseWaitDestroy();
			mmi_gprs->display = FALSE;
			mmiGprsShowCounter(win, mmi_gprs->counter_type);
			break;

		default:
			mmiPleaseWaitDestroy();
			mmi_gprs->display = FALSE;
            info_screen(win,NULL ,TxtAlreadyAttached , NULL,REMIND_NORECORD);
          break;
	}
	return;
}


/*******************************************************************************

 $Function:    	GPRSOutgoingDataCount

 $Description:	Show data counter for last incoming call

 $Returns:		

 $Arguments:	Standard menu option parameters
 
*******************************************************************************/

int GPRSOutgoingDataCount(MfwMnu* m, MfwMnuItem* i)
{
	T_MFW_HND		win = mfw_parent(mfw_header());
	T_MFW_RES		result;
	
	TRACE_FUNCTION("GPRSOutgoingDataCount()");

	mmi_gprs->counter_type = MMI_GPRS_COUNTER_UPLINK;
	mmi_gprs->display = TRUE;

	mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win, TxtPleaseWait, NULL,FlashSettingData.gprsattachmode);

	result = gprs_counter(TRUE);

	switch(result)
	{
		/* Waiting for rAT_PercentSNCNT callback, don't update display yet */
		
		case MFW_RES_OK:
			#ifdef TRACE_MMIGPRS
			TRACE_EVENT("gprs_counter executing, awaiting confirmation.");
			#endif
			break;

		/* We're not connected - display current total */
		case MfwResDone:
			mmiPleaseWaitDestroy();
			mmi_gprs->display = FALSE;
			mmiGprsShowCounter(win, mmi_gprs->counter_type);
			break;

		/* Error has occurred */
		default:
			mmiPleaseWaitDestroy();
			mmi_gprs->display = FALSE;
			info_screen(win,NULL ,TxtAlreadyAttached , NULL,REMIND_NORECORD);
			break;
	}	
	return;
}



/*******************************************************************************

 $Function:    	GPRSselectSms

 $Description:	Sets cursor position for this menu based on the current settings
 
 $Returns:		

 $Arguments:	menu		- pointer to the current menu
 				item		- pointer to the current menu item
 
*******************************************************************************/

int GPRSselectSms(MfwMnu* menu, MfwMnuItem* item)
{
	T_MFW_HND		parent_win		= mfwParent( mfw_header());					// WAP menu window
	T_MFW_WIN		*win_data   	= ((T_MFW_HDR *)parent_win)->data;
	tBookStandard	*parent_data	= (tBookStandard *)win_data->user;			// data for WAP menu window
	T_MFW_HND		win 			= parent_data->parent_win;					// WAP data window
	T_MFW_GPRS		*gprs;
	
	TRACE_FUNCTION("GPRSselectSms()");
	
	if (mmi_gprs->gprsHandle)
	{
		gprs = mmi_gprs->gprsHandle->data;
		gprs->data.SMSService = gprs_getServiceSMS();
		mmi_gprs->SMSService = gprs->data.SMSService;
	}

	mmi_gprs->menu_win = bookMenuStart(win, SMSServiceAttributes(), 0);
	
	SEND_EVENT(mmi_gprs->menu_win, DEFAULT_OPTION, NULL, &mmi_gprs->SMSService); // Add our own callback
	
	return;
}


/*******************************************************************************

 $Function:    	GPRSselectSms_set

 $Description:	Send SMS by GPRS/CSD
 
 $Returns:		

 $Arguments:	menu		- pointer to the current menu
 				item		- pointer to the current menu item
 
*******************************************************************************/

int GPRSselectSms_set(MfwMnu* menu, MfwMnuItem* item)
{
	T_MFW_HND		parent_win		= mfwParent( mfw_header());					// WAP menu window
	T_MFW_WIN		*win_data   	= ((T_MFW_HDR *)parent_win)->data;
	tBookStandard	*parent_data	= (tBookStandard *)win_data->user;			// data for WAP menu window
	T_MFW_HND		win 			= parent_data->parent_win;					// WAP data window

	TRACE_FUNCTION("GPRSselectSms_set()");

	mmi_gprs->SMSService = menu->lCursor[menu->level];

	if (mmi_gprs->gprsHandle)
	{
		mmi_gprs->display = TRUE;
		if(gprs_setServiceSMS(mmi_gprs->SMSService)==MFW_RES_OK)
		{
			info_screen(win, TxtGPRS, TxtChanged, NULL,REMIND_SUCCEED);
		}
		else
		{
			info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
		}
	}
	else
	{
		info_screen(win, TxtWillChangeOn, TxtAttach, NULL,REMIND_NORECORD);						// Changed in memory, will set when attach
	}
	
	return 1;
}

void GPRStest(MfwMnu* m, MfwMnuItem* i)
{
	T_GPRS_CONT_REC context;
	T_ACI_RETURN ret1,ret2;
	UBYTE minsize;

	memset(&context.apn,'\0',MAX_APN_LEN);
	strcpy((char *)&context.apn,"INTERNET");
	strcpy((char*)context.pdp_type,"IP");
	memset(&context.pdp_addr,'\0',MAX_PDP_ADDR_LEN);
	context.d_comp = CGDCONT_D_COMP_OMITTED;
	context.h_comp = CGDCONT_H_COMP_OMITTED;
	memset(&context.qos,0,sizeof(T_QOS));
	memset(&context.min_qos,0,sizeof(T_QOS));

	ret1 = sAT_PlusCGDCONT(CMD_SRC_LCL,1,&context);

    {
         TRACE_EVENT_P1("ret1 %d",ret1);
    }
	switch (ret1)
	{
	    case (AT_CMPL):                         /*operation completed*/
	    case (AT_EXCT):
#ifdef _M188_			//glowing,200406-16, for GPRSTest is not referenced in any place
		sAT_PercentCGPCO (CMD_SRC_LCL,1,ACI_PCO_AUTH_PROT_PAP,"web", "web");
		ret2 = sAT_Dn(CMD_SRC_LCL,"*98**1*1#",D_CLIR_OVRD_Default,D_CUG_CTRL_NotPresent,D_TOC_Data);
#endif		
		switch (ret2)
		{
		    case (AT_CMPL):                         /*operation completed*/
		    case (AT_EXCT):
		    default:
			break;
		}
	}
}
/* SH - Only included for GPRS testing */

#ifdef TEST_MMIGPRS
static T_GPRS_CONT_REC		inputCtxt = {
				"", "", "", CGDCONT_D_COMP_OMITTED, CGDCONT_H_COMP_OMITTED,GPRS_QOS_OMITTED, GPRS_QOS_OMITTED};

enum
{
	QOS_PRECED_HIGH = 1,
	QOS_PRECED_NORMAL,
	QOS_PRECED_LOW
};

enum
{
	QOS_BEST = 1
};
/*******************************************************************************

 $Function:    	GPRSContextDefine

 $Description:	Define a context!

 $Returns:		

 $Arguments:	Standard menu option parameters
 
*******************************************************************************/

int GPRSContextDefine(MfwMnu* m, MfwMnuItem* i)
{
 	SHORT				*cids;
	SHORT				count;
	T_MFW_GPRS			*gprs;
	SHORT				numContexts;	
	T_MFW_HND			win = mfw_parent(mfw_header());
	T_QOS 			Qos = {QOS_PRECED_NORMAL, QOS_BEST, QOS_BEST, QOS_BEST, QOS_BEST};
	T_QOS 			Min_Qos = {QOS_PRECED_LOW, QOS_BEST, QOS_BEST, QOS_BEST, QOS_BEST};
#ifdef TRACE_MMIGPRS
	TRACE_FUNCTION("GPRSContextDefine()");
#endif

	/* Check to make sure gprs handle exists */
	
	if (!mmi_gprs->gprsHandle)
	{
		info_screen(win,NULL ,TxtNotAttached , NULL,REMIND_SUCCEED);
		return;
	}

	gprs = ((T_MFW_HDR *) mmi_gprs->gprsHandle)->data;
	numContexts = gprs->data.numContexts;
	
	strcpy(inputCtxt.apn, "Vizzavi UK");
	strcpy(inputCtxt.pdp_addr, "212.183.137.012");
	strcpy(inputCtxt.pdp_type, "ISDN");
	inputCtxt.d_comp = NULL;
	inputCtxt.h_comp = NULL;
	memcpy(&inputCtxt.qos, &Qos, sizeof(Qos));
	memcpy(&inputCtxt.min_qos, &Min_Qos, sizeof(Qos));
	
	if (gprs_definePDPContext(GPRS_CID_1, &inputCtxt)==MFW_RES_OK)
	{
 		#ifdef TRACE_MMIGPRS
 		TRACE_EVENT("GPRSContextDefine: Activated OK.");
 		#endif
 		info_screen(win,NULL ,TxtActivated , NULL,REMIND_SUCCEED);
	}
 	else
	{
 		#ifdef TRACE_MMIGPRS
		TRACE_EVENT("GPRSContextDefine: Failed.");
 		#endif
 		info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
	}
	return 0;
}


/*******************************************************************************

 $Function:    	GPRSActivate

 $Description:	

 $Returns:		

 $Arguments:	Standard menu option parameters
 
*******************************************************************************/

int GPRSActivate(MfwMnu* m, MfwMnuItem* i)
{
 	SHORT			*cids;
	SHORT			count;
	T_MFW_GPRS		*gprs;
	SHORT			numContexts;	
	T_MFW_HND		win = mfw_parent(mfw_header());

	TRACE_FUNCTION("GPRSActivate()");

	// Check to make sure gprs handle exists
	
	if (!mmi_gprs->gprsHandle)
	{
		info_screen(win,NULL ,TxtNotAttached , NULL,REMIND_SUCCEED);
		return;
	}
	
	gprs = ((T_MFW_HDR *) mmi_gprs->gprsHandle)->data;
	numContexts = gprs->data.numContexts;

#ifdef TRACE_MMIGPRS
	TRACE_EVENT_P1("GPRSActivate: No. of contexts: %d", numContexts);
#endif

 	if (numContexts>0)
	{
 		cids = (SHORT *) mfwAlloc(sizeof(SHORT)*numContexts);

		for (count=0; count<numContexts; count++)
			cids[count] = gprs->data.contexts[count].id;
  
 	 	if (gprs_contextActivation(CGACT_STATE_ACTIVATED, cids)==MFW_RES_OK)
 		{
			#ifdef TRACE_MMIGPRS
 	 		TRACE_EVENT("GPRSActivate: Activation executing, awaiting confirmation.");
			#endif
 	 		mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win, TxtPleaseWait, NULL,FlashSettingData.gprsattachmode);
 		}
 	 	else
 		{
			#ifdef TRACE_MMIGPRS
			TRACE_EVENT("GPRSActivate: Failed.");
			#endif
 	 		info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
 		}
 	 	
		mfwFree((U8 *) cids, sizeof(SHORT)*numContexts);
	}
 	else
	{
		#ifdef TRACE_MMIGPRS
 		TRACE_EVENT("GPRSActivate: No contexts to activate.");
		#endif
 		info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
	}
	return 0;
}


/*******************************************************************************

 $Function:    	GPRSDeactivate

 $Description:	

 $Returns:		

 $Arguments:	Standard menu option parameters
 
*******************************************************************************/

int GPRSDeactivate(MfwMnu* m, MfwMnuItem* i)
{
	SHORT 			*cids;
	SHORT			count;
	T_MFW_GPRS		*gprs;
	SHORT			numContexts;	
	T_MFW_HND		win = mfw_parent(mfw_header());

	TRACE_FUNCTION("GPRSDeactivate()");

	if (!mmi_gprs->gprsHandle)
	{
		info_screen(win,NULL ,TxtNotAttached , NULL,REMIND_SUCCEED);
		return;
	}
	
	gprs = ((T_MFW_HDR *) mmi_gprs->gprsHandle)->data;
	numContexts = gprs->data.numContexts;

	if (numContexts>0)
	{
	 	cids = (SHORT *) mfwAlloc(sizeof(SHORT)*numContexts);

	 	for (count=0; count<numContexts; count++)
			cids[count] = gprs->data.contexts[count].id;
	  
		if (gprs_contextActivation(CGACT_STATE_DEACTIVATED, cids)==MFW_RES_OK)
 		{
			#ifdef TRACE_MMIGPRS
 	 		TRACE_EVENT("GPRSDeactivate: Deactivated OK.");
			#endif
 	 		info_screen(win,NULL ,TxtDeActivated , NULL,REMIND_SUCCEED);
 		}
 	 	else
 		{
			#ifdef TRACE_MMIGPRS
			TRACE_EVENT("GPRSDeactivate: Failed.");
			#endif
 	 		info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
 		}
 	 	
		mfwFree((U8 *) cids, sizeof(SHORT)*numContexts);
	}
	else
 	{
		#ifdef TRACE_MMIGPRS
 		TRACE_EVENT("GPRSDeactivate: No contexts to deactivate.");
		#endif
 		info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
	}
	
	return 0;
}
/*******************************************************************************

 $Function:    	GPRSsetQos

 $Description:	Set quality of service

 $Returns:		

 $Arguments:	Standard menu option parameters
 
*******************************************************************************/

int GPRSsetQos(MfwMnu* m, MfwMnuItem* i)
{
	T_MFW_HND		win = mfw_parent(mfw_header());
	T_QOS 			Qos = {QOS_PRECED_NORMAL, QOS_BEST, QOS_BEST, QOS_BEST, QOS_BEST};

	TRACE_FUNCTION("GPRSsetQos()");

	if (gprs_setQOS(mmi_gprs->cid, &Qos)==MFW_RES_OK)
	{
		#ifdef TRACE_MMIGPRS
		TRACE_EVENT("GPRSsetQos: OK");
		#endif
		info_screen(win,NULL ,TxtActivated , NULL,REMIND_SUCCEED);
	}
	else
	{
		#ifdef TRACE_MMIGPRS
		TRACE_EVENT("GPRSsetQos: Failed");
		#endif
		info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
	}
	return;
}


/*******************************************************************************

 $Function:    	GPRSsetMinQos

 $Description:	Set minimum quality of service

 $Returns:		

 $Arguments:	Standard menu option parameters
 
*******************************************************************************/

int GPRSsetMinQos(MfwMnu* m, MfwMnuItem* i)
{
	T_MFW_HND		win = mfw_parent(mfw_header());
	T_QOS 			Qos = {QOS_PRECED_LOW, QOS_BEST, QOS_BEST, QOS_BEST, QOS_BEST};

	TRACE_FUNCTION("GPRSsetMinQos()");

	if (gprs_setQOSMin(mmi_gprs->cid, &Qos)==MFW_RES_OK)
	{
		#ifdef TRACE_MMIGPRS
		TRACE_EVENT("GPRSsetMinQos: OK");
		#endif
		info_screen(win,NULL ,TxtActivated , NULL,REMIND_SUCCEED);
	}
	else
	{
		#ifdef TRACE_MMIGPRS
		TRACE_EVENT("GPRSsetMinQos: Failed");
		#endif
		info_screen(win,NULL ,TxtFailed , NULL,REMIND_FAILURE);
	}
	return;
}

int csdConnection(MfwMnu* m, MfwMnuItem* i)
{
}

int setClassBConnection(MfwMnu* m, MfwMnuItem* i)
{
  
}

int setClasCConnection(MfwMnu* m, MfwMnuItem* i)
{

}

int showIPAddress(MfwMnu* m, MfwMnuItem* i)
{	
}

int GPRSCompressionStatus(MfwMnu* m, MfwMnuItem* i)
{	
}


int GPRSCompressionOn(MfwMnu* m, MfwMnuItem* i)
{

}
int GPRSCompressionOff(MfwMnu* m, MfwMnuItem* i)
{

}
int setClassCVoice(MfwMnu* m, MfwMnuItem* i){}	

int setClassCData(MfwMnu* m, MfwMnuItem* i){}	
#endif
void SaveGprsCounter(void)
{ 
	FlashDCTbData.GPRSOUTCOUNTER=FlashDCTbData.GPRSOUTCOUNTER+mmi_gprs->uplink_counter;
    FlashDCTbData.GPRSINCOUNTER=FlashDCTbData.GPRSINCOUNTER+mmi_gprs->downlink_counter;
    flash_DCTbwrite();
}

⌨️ 快捷键说明

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