|
MTK短信开发详解(四)
3、收短信
3.1、短信接收过程
l4a_callback SMSMsg SmsPsHandler MessagesMiscell
1 l4c_sms_new_msg_text_lind
[...]
mmi_frm_sms_new_sms_ind
2 mmi_frm_sms_new_sms
mmi_frm_sms_indicate_sms
mmi_frm_sms_new_msg_ind
3 mmi_msg_handle_new_msg_ind
4 mmi_msg_new_msg_ind
mmi_msg_entry_new_msg_ind
3.2、接收过程详解:
3.2.1、收到新短信
L4层收到短信,向MMI_Task递交消息。
[l4a_callback.c]
void l4c_sms_new_msg_text_lind(...)
{
[…]
ilm_ptr->msg_id = (kal_uint16) MSG_ID_MMI_SMS_DELIVER_MSG_IND;/* Set the message id */
// MSG_ID_MMI_SMS_DELIVER_MSG_IND被注册到mmi_frm_sms_new_sms_ind函数:↘
[SMSMsg.c]
void mmi_frm_sms_set_protocol_event_handler(void)
{
SetProtocolEventHandler(mmi_frm_sms_new_sms_ind, PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND);
[…]
}
[ProtocolEvents.h]
#define PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND MSG_ID_MMI_SMS_DELIVER_MSG_IND
[…]
SEND_ILM(MOD_L4C,MOD_MMI,MMI_L4C_SAP,ilm_ptr);
}
MMI层收到新短信,更新短信计数器,转换短信数据,并压入未读短信队列。短信过滤等操作放在CHISTIncRecvdSMS()之前。
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSMsg.c]
void mmi_frm_sms_new_sms_ind(void *inMsg)
{
if( ( 1 == IsBlockAndEmergencyOnly() )
{
[…]
delete_pending_sms();
[…]
}
CHISTIncRecvdSMS();
/* convert L4 data to MMI data */
mmi_frm_sms_convert_new_sms(msgInd, data);
/* put to awaited list last entry, from now on only process new data as awaited list last entry */
mmi_frm_sms_add_new_sms(data, msgInd->no_msg_data, msgInd->msg_data);
/* process new sms data */
mmi_frm_sms_new_sms();
[…]
}
3.2.2、短信分类
新短信的信箱类型为 MMI_FRM_SMS_AWAITS,消息类型为 mmi_frm_sms_deliver_msg_struct,必须转换为 mmi_frm_sms_msgbox_struct类型,保存到全局的msgbox,并设置其信箱类型为 MMI_FRM_SMS_UNREAD,添加其索引到inbox。
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSCore.c]
void mmi_frm_sms_new_sms(void)
{
[...]
case MMI_FRM_SMS_AWAITS:
{
mmi_frm_sms_indicate_sms(index);
}
[...]
}
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSCore.c]
void mmi_frm_sms_indicate_sms(U16 index)
{
[…]
mmi_frm_sms_convert_mt_to_entry(data, entry);↘
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSUtil.c]
void mmi_frm_sms_convert_mt_to_entry(mmi_frm_sms_deliver_msg_struct *data, mmi_frm_sms_msgbox_struct *entry)
type = MMI_FRM_SMS_UNREAD;// 设置短信类型
msgbox_index = mmi_frm_sms_add_sms_to_msgbox(entry, data->index, segment);// 添加短信到inbox,关键!↘
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSUtil.c]
U16 mmi_frm_sms_add_sms_to_msgbox(mmi_frm_sms_msgbox_struct *entry, U16 index, U8 thisseg)
entryindex = mmi_frm_sms_add_sms_entry(entry, index, thisseg);↘
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSUtil.c]
U16 mmi_frm_sms_add_sms_entry(mmi_frm_sms_msgbox_struct *data, U16 L4index, U8 thissegment)
#endif /* __UNIFIED_MESSAGE_SIMBOX_SUPPORT__ */
if ((data->msgtype & MMI_FRM_SMS_INBOX) == MMI_FRM_SMS_INBOX)
{
type = MMI_FRM_SMS_INBOX;//短信分类
}
mmi_frm_sms_add_sms_to_list(entry, entryindex);↘
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSUtil.c]
void mmi_frm_sms_add_sms_to_list(mmi_frm_sms_msgbox_struct *data, U16 index)
case MMI_FRM_SMS_UNREAD:
[... 添加索引到收件箱 ...]
if (i == mmi_frm_sms_msg_check_num)
{
mmi_frm_sms_new_msg_ind(msgbox_index);
}
[…]
}
[\plutommi\mmi\MiscFramework\MiscFrameworkSrc\SMSMsg.c]
void mmi_frm_sms_new_msg_ind(U16 index)
{
[…]
if (mmi_frm_sms_interrupt_handler.msgid == PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND)
{
mmi_frm_sms_interrupt_handler.callback((void*)data, MOD_MMI, MMI_FRM_SMS_OK);//callback注册的函数为mmi_msg_handle_new_msg_ind↘
[\plutommi\mmi\messages\messagessrc\SmsPsHandler.c]
void mmi_msg_set_protocol_event_handler(void)
{
mmi_frm_sms_reg_interrupt_check(MOD_MMI, PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND, mmi_msg_handle_new_msg_ind);
[…]
}
//对比mmi_msg_set_protocol_event_handler与mmi_frm_sms_set_protocol_event_handler,这两个函数都使用了 PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND
break;
[…]
}
完整版本请见 http://www.51qianru.cn/bbs/
曙海教育
曙海嵌入式学院3G通信培训中心
(MTK培训,Android培训,iPhone培训)
电话:021-51875830
网址:http://www.51qianru.cn
讲师:李现路
版权所有-曙海教育 转发请注明出处 |
|