MTK 发送短信 - jues
让Windows XP支持远程多用户登陆
解决KDE下触摸板功能不全问题

MTK 发送短信

jues posted @ 2013年9月18日 10:11 in 笔记(转载) , 1025 阅读

MTK 53,50D 测试通过,主要代码摘于网上,自己也整理下,由于太久具体忘了在什么地方找到的,请原作者见谅,如知道请告知,一定加上连接。

/*mobileNo:电话号码,mobileNoLen:号码长度
smsMsg:短信内容,smsMsgLen:短信内容长度
simid: 双卡情况下0为主卡,1为副卡
*/

#ifndef __MMI_DUAL_SIM_MASTER__
void my_send_sms(S8 mobileNo[], U32 mobileNoLen, U8 smsMsg[], U32 smsMsgLen)
#else
void my_send_sms(S8 mobileNo[], U32 mobileNoLen, U8 smsMsg[], U32 smsMsgLen, U8 simid)
#endif
{
	
#if 1
	MMI_FRM_SMS_SEND_MSG_REQ_STRUCT *sendSms;
	S32 nsize = 0;
	
	/**/
	nsize = mmi_ucs2strlen((S8*)smsMsg)*2;
	sendSms = (MMI_FRM_SMS_SEND_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*sendSms));
	memset(sendSms,0,sizeof(sizeof(*sendSms)));
	
	sendSms->ref_count = 1;
	sendSms->msg_len = sizeof(mmi_sms_send_msg_req_struct);
	sendSms->profile = 0;
	sendSms->reply_index = 0xffff;	
	mmi_frm_sms_convert_ascii_num_to_l4_num(&sendSms->dest,(U8*)mobileNo);
	sendSms->para = 0;
	
	memset((S8*)sendSms->sc_addr.number, 0xff, MAX_CC_ADDR_LEN);
	sendSms->sc_addr.length = 0xff;
	sendSms->sc_addr.type = 0xff;
	sendSms->vp = 0xff;
	sendSms->pid = 0xff;
	sendSms->udhi = 0;
	
	sendSms->dcs = SMSAL_UCS2_DCS;
	sendSms->length = nsize;
	mmi_ucs2ncpy((S8*)sendSms->msg, (S8 *)smsMsg, nsize/2);
	// sendSms->length =mmi_chset_convert(MMI_CHSET_GB2312,MMI_CHSET_UCS2,(char * )sContent,(char *)sendSms->msg,sizeof(sendSms->msg));
	////////////////////////高低位字节反顺序
	{
		int i;
		kal_uint8  tmp;
		
		for(i=0;i<sendSms->length;i+=2)
		{
			tmp = sendSms->msg[i];
			sendSms->msg[i]=sendSms->msg[i+1];
			sendSms->msg[i+1]=tmp;
		}
	}	
	
#else
	mmi_sms_send_msg_req_struct *sendSms;
	sendSms = (mmi_sms_send_msg_req_struct*)OslConstructDataPtr(sizeof(*sendSms));
	sendSms->dcs = SMSAL_UCS2_DCS;
	sendSms->udhi = 0;
	sendSms->length = smsMsgLen;
	memset(sendSms->msg,0,SMSAL_MAX_MSG_LEN);
	memcpy(sendSms->msg,smsMsg,sendSms->length);
	sendSms->profile = 0;
	sendSms->para = 0;
	sendSms->reply_index = MMI_FRM_SMS_INVALID_INDEX;
	sendSms->dest.type = CSMCC_DEFAULT_ADDR_TYPE;
	memset((S8*)sendSms->dest.number,0,MAX_CC_ADDR_LEN);
	sendSms->dest.length = mobileNoLen;
	memcpy(sendSms->dest.number,mobileNo,sendSms->dest.length);
	sendSms->seq_num = 0;
	sendSms->mms_mode = 0;
	//simsp_set_sms_ProtocolEventHandler();
#endif
	
#ifndef __MMI_DUAL_SIM_MASTER__
	mmi_frm_sms_send_message(MOD_MMI,MOD_L4C,0,PRT_MSG_ID_MMI_SMS_SEND_MSG_REQ,(
		oslParaType*)sendSms,NULL);
#else//__MMI_DUAL_SIM_MASTER__
	if(simid == 0)
		
	{
		mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0,PRT_MSG_ID_MMI_SMS_SEND_MSG_REQ, (oslParaType *)sendSms, NULL);
	}
	else
	{
		MTPNP_PFAL_Send_Message_Segment((void *)sendSms);
	}
	
#endif//__MMI_DUAL_SIM_MASTER__
	
}


/*把短信内容转换为uncode再发送*/
void my_send_sms_msg( char* sNumber,char* sContent,chset_enum src_type )
{
	
    /**/
	U8  smsMsg[ 140 * 2 ];
	U32  mobileNoLen ;
	
#ifndef WIN32
	dbg_print("\r\n*my_send_sms_msg  sNumber= %s*",sNumber );
#endif	
	/**/	 
	if ( NULL ==  sNumber  )
		return;
	
	mobileNoLen = strlen( sNumber );
	
	if ( 0 >=  mobileNoLen )
		return;
	
	mmi_chset_convert( src_type,CHSET_UCS2,
		(char*)sContent,(char*)smsMsg,sizeof( smsMsg ) );

#ifdef WIN32
	kal_print("\r\n*my_send_sms_msg  smsMsg= %s*",smsMsg );
#endif	
#ifndef __MMI_DUAL_SIM_MASTER__
	my_send_sms( sNumber,mobileNoLen,smsMsg, strlen( sContent ) * 2 );
#else
	my_send_sms( sNumber,mobileNoLen,smsMsg, strlen( sContent ) * 2,0 );
#endif /*__MMI_DUAL_SIM_MASTER__*/
	
}

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter