[DESCRIPTION]
MT2503如何使用UCS2方式发送短信
[SOLUTION]
提供sample code如下,重点要注意的是,发送的时候记得要传的UCS2编码值要用小端发送 kal_uint8 chinese_content_buff[4]={96,79,125,89};///你好的UCS2编码值,UCS2-LIT,请 记得使用小端发送,使用大端发送会导致对方收到后显示乱码
void MMI_send_chinese_SMS_callback(srv_sms_callback_struct* callback_data)
{
kal_pROMpt_trace(MOD_SMS, "result=%d, action=%d, cause=%d\n",callback_data->result,
callback_data->action, callback_data->cause);
if (callback_data->result == MMI_TRUE)
{
/* send successfully */
}
else
{
switch(callback_data->cause)
{
case SRV_SMS_CAUSE_SEND_ABORT:
case SRV_SMS_CAUSE_NOT_READY:
case SRV_SMS_CAUSE_SEND_BUSY:
case SRV_SMS_CAUSE_MEM_FULL:
case SRV_SMS_CAUSE_MEM_INSUFFICIENT:
case SRV_SMS_CAUSE_DATA_INVALID:
case SRV_SMS_CAUSE_DATA_EXCEED:
case SRV_SMS_CAUSE_NUMBER_EMPTY:
case SRV_SMS_CAUSE_NUMBER_INVALID:
case SRV_SMS_CAUSE_SC_EMPTY:
case SRV_SMS_CAUSE_SC_INVALID:
case SRV_SMS_CAUSE_FDL_FAIL:
case SRV_SMS_CAUSE_AT_CONFLICT:
case SRV_SMS_CAUSE_OP_CONFLICT:
case SRV_SMS_CAUSE_EMAIL_NO_SPACE:
case SRV_SMS_CAUSE_UNKNOWN_ERROR:
default:
/* send failed */
break;
}
}
}
void mmi_send_chinese_sms()
{
SMS_HANDLE send_handle;
send_handle = srv_sms_get_send_handle();
if (send_handle == NULL)
{
/* can not get handle */
return;
}
if ((U16)srv_sms_is_bg_send_action_busy() == MMI_TRUE)
{
/* background sending is busy */
return;
}
/* set address number */
srv_sms_set_address(send_handle, (CHAR*)(L"18688806215"));
/* set content of DCS encoding */
srv_sms_set_content_dcs(send_handle, SRV_SMS_DCS_UCS2);
/* set content */
srv_sms_set_content(send_handle, (S8*)chinese_content_buff, 4);
/* set SIM1 */
srv_sms_set_sim_id(send_handle, SRV_SMS_SIM_1);
/* send request */
srv_sms_send_msg(send_handle, mmi_send_chinese_sms_callback, NULL);
MT2503如何使用UCS2方式发送短信
[SOLUTION]
提供sample code如下,重点要注意的是,发送的时候记得要传的UCS2编码值要用小端发送 kal_uint8 chinese_content_buff[4]={96,79,125,89};///你好的UCS2编码值,UCS2-LIT,请 记得使用小端发送,使用大端发送会导致对方收到后显示乱码
void MMI_send_chinese_SMS_callback(srv_sms_callback_struct* callback_data)
{
kal_pROMpt_trace(MOD_SMS, "result=%d, action=%d, cause=%d\n",callback_data->result,
callback_data->action, callback_data->cause);
if (callback_data->result == MMI_TRUE)
{
/* send successfully */
}
else
{
switch(callback_data->cause)
{
case SRV_SMS_CAUSE_SEND_ABORT:
case SRV_SMS_CAUSE_NOT_READY:
case SRV_SMS_CAUSE_SEND_BUSY:
case SRV_SMS_CAUSE_MEM_FULL:
case SRV_SMS_CAUSE_MEM_INSUFFICIENT:
case SRV_SMS_CAUSE_DATA_INVALID:
case SRV_SMS_CAUSE_DATA_EXCEED:
case SRV_SMS_CAUSE_NUMBER_EMPTY:
case SRV_SMS_CAUSE_NUMBER_INVALID:
case SRV_SMS_CAUSE_SC_EMPTY:
case SRV_SMS_CAUSE_SC_INVALID:
case SRV_SMS_CAUSE_FDL_FAIL:
case SRV_SMS_CAUSE_AT_CONFLICT:
case SRV_SMS_CAUSE_OP_CONFLICT:
case SRV_SMS_CAUSE_EMAIL_NO_SPACE:
case SRV_SMS_CAUSE_UNKNOWN_ERROR:
default:
/* send failed */
break;
}
}
}
void mmi_send_chinese_sms()
{
SMS_HANDLE send_handle;
send_handle = srv_sms_get_send_handle();
if (send_handle == NULL)
{
/* can not get handle */
return;
}
if ((U16)srv_sms_is_bg_send_action_busy() == MMI_TRUE)
{
/* background sending is busy */
return;
}
/* set address number */
srv_sms_set_address(send_handle, (CHAR*)(L"18688806215"));
/* set content of DCS encoding */
srv_sms_set_content_dcs(send_handle, SRV_SMS_DCS_UCS2);
/* set content */
srv_sms_set_content(send_handle, (S8*)chinese_content_buff, 4);
/* set SIM1 */
srv_sms_set_sim_id(send_handle, SRV_SMS_SIM_1);
/* send request */
srv_sms_send_msg(send_handle, mmi_send_chinese_sms_callback, NULL);
}
资料来源:MT2503 http://bbs.16rd.com/thread-453769-1-1.html