调用 mmi_frm_sms_send_sms 发短信时,手机重启了,估计是 smsdata 某些参数设置不对,希望高手来指教下,给出函数,
void mmi_send_sms_test(void)
{
mmi_frm_sms_send_struct * smsdata;
char* pNum="15821320750"; // number
char* content="hello!"; // content
E_MTPNP_AD_SIMCARD_USABLE_SIDE simcard_usable_side;
smsdata=OslMalloc(sizeof(mmi_frm_sms_send_struct));
#ifdef __MMI_DUAL_SIM_MASTER__
simcard_usable_side=MTPNP_AD_Get_UsableSide();
if(simcard_usable_side==MTPNP_AD_SIMCARD1_USABLE|| simcard_usable_side==MTPNP_AD_DUALSIM_USABLE)
{
MTPNP_AD_Set_Channel(MTPNP_AD_SMS_CHANNEL,MTPNP_AD_CHANNEL_MASTER);
}
else if(simcard_usable_side==MTPNP_AD_SIMCARD2_USABLE)
{
MTPNP_AD_Set_Channel(MTPNP_AD_SMS_CHANNEL,MTPNP_AD_CHANNEL_SLAVE);
}
else
{
return;
}
smsdata->sendrequire &= ~MMI_FRM_SMS_DISP_SIM_OPT;
#else
MTPNP_AD_Set_Channel(MTPNP_AD_SMS_CHANNEL,MTPNP_AD_CHANNEL_MASTER);
#endif
memset(smsdata->number,0x00, sizeof(smsdata->number));
memcpy(smsdata->number,pNum, strlen(pNum));
smsdata->dcs_class = SMSAL_CLASS1;
smsdata->dcs = SMSAL_8BIT_DCS;
smsdata->sendcheck = smsdata->sendcheck | MMI_FRM_SMS_SCR;
smsdata->string=OslMalloc((strlen(content)+1)*2);
mmi_asc_to_ucs2(smsdata->string, content);
smsdata->stringlength=strlen(content);
mmi_frm_sms_send_sms(send_msg_cb_fun, MOD_MMI, smsdata);
OslMfree(smsdata);
}
------解决方案--------------------------------------------------------
- C/C++ code
S8 Entertainment_SendSms(U8 *pNumber,U8 *pContent){S8 *textbufUCS2 ;S8 smsPhoneNumber[(MAX_DIGITS 1) * ENCODING_LENGTH];EMSData *pEMS;byte result;U8 len, i;if (!Entertainment_IsReady4SendSms()){return FALSE;}len = strlen((char *) pContent);ReleaseEMSEditBuffer();pEMS = GetEMSDataForEdit(0,1);g_msg_cntx.sendSaveStatus = SEND_SAVE_NIL;memset(g_msg_cntx.smsPhoneNumber,0,sizeof(g_msg_cntx.smsPhoneNumber)); AnsiiToUnicodeString((S8 *) smsPhoneNumber,(S8 *) pNumber);pfnUnicodeStrcpy(g_msg_cntx.smsPhoneNumber,(S8 *) smsPhoneNumber);PendingSaveSendData.totalSegments = 1;PendingSaveSendData.mti = SMSAL_MTI_SUBMIT;memset(PendingSaveSendData.TPUD,0,sizeof(PendingSaveSendData.TPUD));for (i = 1; i < mmi_msg_get_seg_num(); i ){PendingSaveSendData.TPUDLen = 0;PendingSaveSendData.TPUD_p = NULL;PendingSaveSendData.l4index = SMS_INVALID_INDEX;PendingSaveSendData.TPUD_udhi = FALSE;}g_msg_cntx.sendMessageCase = SEND_CASE_SEND_ONLY;textbufUCS2 = (S8 *) OslMalloc((len 1) * 2);memset(textbufUCS2,0,((len 1) * 2));AnsiiToUnicodeString((S8 *) textbufUCS2,(S8 *) pContent);result = AppendEMSString(INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,pEMS,(U8 *) textbufUCS2,SMSAL_DEFAULT_DCS,NULL); OslMfree(textbufUCS2);if (result){mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));if (DeliveryRepyStates[0] == 1) {CloseDeliveryRepyStatesFlag = 1;DeliveryRepyStates[0] = 0;mmi_frm_sms_set_common_settings(NULL,MOD_MMI,DeliveryRepyStates);}memset((S8 *) sendData,0,sizeof(mmi_frm_sms_send_struct));memset(sendData->number,0,MAX_DIGITS_SMS); if (pfnUnicodeStrlen((S8 *) smsPhoneNumber))UnicodeToAnsii((S8 *) sendData->number,(S8 *) smsPhoneNumber);MdogSendMessage = 1; mmi_frm_sms_send_sms(Entertainment_send_message_response,MOD_MMI,sendData);OslMfree(sendData);return TRUE;}return FALSE;}