mt2503 在MMI版本实现AT+CPBF
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
目前只有在Modem版本上,才能支持AT+CPBF功能;在MMI版本上不支持CPBF;为了在MMI版本实现AT+CPBF:MMI并没有支持CPBF的相关接口;由于MMI版本,L4C也没有记录电话本的数据,所以需要通过MMI来获取数据;所以,借用CPBR的接口,从MMI读数据,然后在L4C分析比较数据;符合条件的就通过UART上报。
[SOLUTION]
下面的代码在09B0952上验证通过。
修改了三个函数,请注意对比区分添加修改的代码;
rmmi_cpbf_hdlr
l4cphb_read_response_handler
rmmi_phb_entry_rsp_fmttr
1,voidrmmi_cpbf_hdlr(rmmi_string_struct*source_string_ptr)
{
kal_boolret_val=KAL_FALSE;
kal_uint8const*rsp_str=NULL;
kal_uint16string_length=0;
//#ifdefined(__PHB_SORT_ENABLE__)
kal_uint8result;
kal_uint8length;
kal_uint8text[32];
l4_name_structname;
//#endif
kal_uint8buffer[RMMI_SHORT_RSP_LEN];
kal_uint8alpha_length;
kal_uint8num_length;
rmmi_context_struct*rmmi_ptr=RMMI_PTR;
kal_uint16index;
kal_uint8i;
kal_trace(TRACE_FUNC,FUNC_RMMI_CPBF_HDLR_ENTRY);
if(L4C_PTR->phb_ready_flag==KAL_FALSE)
{
rmmi_ptr->cmee_err=OPERATION_NOT_ALLOWED_ERR;
}
else
{
switch(source_string_ptr->cmd_mode)
{
caseRMMI_TEST_MODE:
{
if(rmmi_is_valid_phb_storage(rmmi_ptr->phb_storage_type)==KAL_TRUE)
{
rmmi_get_phb_length(&alpha_length,&num_length);
kal_sprintf((kal_char*)buffer,"+CPBF:%d,%d",num_length,alpha_length);
ret_val=KAL_TRUE;
rsp_str=&buffer[0];
string_length=strlen((char*)rsp_str);
}
break;
}
caseRMMI_SET_OR_EXECUTE_MODE:
{
#ifdefined(__PHB_SORT_ENABLE__)
result=rmmi_string_validator(
source_string_ptr,
rmmi_ptr->s_reg.s3,/*separator*/
30,
(kal_uint8*)text);
if(result==RMMI_VALIDATOR_ERROR)
{
break;
}
if((rmmi_ptr->char_set==RMMI_CHSET_UCS2)||(rmmi_ptr->char_set==RMMI_CHSET_HEX))
{
//wedon'tsupport+CPBFforUCS2.
rmmi_ptr->cmee_err=RMMI_ERR_OPERATION_NOT_SUPPORTED;
break;
/*converttoucs2valueandstoreinalpha_id
isUCS2format=check_ucs2_value((kal_uint8*)text,(kal_uint8*)name.name);
if(isUCS2format==KAL_FALSE)break;
name.name_length=strlen((char*)text)/2;
name.name_dcs=PHB_UCS2;*/
}
else
{
length=strlen((char*)text);
name.name_length=length;
kal_mem_cpy((kal_uint8*)name.name,(kal_uint8*)text,length);
name.name_dcs=PHB_ASCII;
}
ret_val=l4c_phb_get_entry_by_prefix_text_req(
source_string_ptr->src_id,
PHB_PHONEBOOK,
15,
(l4_name_struct*)&name);
if(ret_val==KAL_TRUE)
{
return;
}
else
{
rmmi_ptr->cmee_err=RMMI_ERR_COMMAND_CONFLICT;
}
#else/*__PHB_SORT_ENABLE__*/
/*mtk01616_081106:searchfunctionneeDTUrnoncompileoption__PHB_SORT_ENABLE__tosupport*/
//rmmi_ptr->cmee_err=RMMI_ERR_OPERATION_NOT_SUPPORTED;
index=source_string_ptr->index;
result=rmmi_string_validator(
source_string_ptr,
rmmi_ptr->s_reg.s3,/*separator*/
30,
(kal_uint8*)text);
source_string_ptr->index=index;
if(result==RMMI_VALIDATOR_ERROR)
{
break;
}
if((rmmi_ptr->char_set==RMMI_CHSET_UCS2)||(rmmi_ptr->char_set==RMMI_CHSET_HEX))
{
//wedon'tsupport+CPBFforUCS2.
rmmi_ptr->cmee_err=RMMI_ERR_OPERATION_NOT_SUPPORTED;
break;
/*converttoucs2valueandstoreinalpha_id
isUCS2format=check_ucs2_value((kal_uint8*)text,(kal_uint8*)name.name);
if(isUCS2format==KAL_FALSE)break;
name.name_length=strlen((char*)text)/2;
name.name_dcs=PHB_UCS2;*/
}
else
{
length=strlen((char*)text);
/*name.name_length=length;
kal_mem_cpy((kal_uint8*)name.name,(kal_uint8*)text,length);
name.name_dcs=PHB_ASCII;
*/
//convertlowercaselettertouppercaseletter.
for(i=0;i<length;i++)
{
if((text>=0x61&&text<=0x7A)||/*Latinbasic*/
(text>=0xE0&&text<=0xF6)||(text>=0xF8&&text<=0xFE))/*Latin-1*/
{
text=text-0X20;
}
}
strncpy((char*)rmmi_ptr->cpbf_findtext,(char*)text,length);
}
//getinfothroughcpbr
{
kal_uint16total,used;
if(!l4c_phb_get_storage_info(source_string_ptr->src_id,rmmi_ptr->phb_storage_type,&used,&total))
{
rmmi_ptr->cmee_err=RMMI_ERR_UNKNOWN;
mEMSet(rmmi_ptr->cpbf_findtext,0,sizeof(rmmi_ptr->cpbf_findtext)-1);
}
else
{
kal_uint8*string;
string=get_ctrl_buffer(40);//kal_uint8cpbf_findtext[30];
kal_wsprintf((WCHAR*)string,"at+cpbr=1,%d",total);
ucs2_to_ascii((kal_wchar*)string,(kal_uint8*)source_string_ptr->string_ptr);
free_ctrl_buffer(string);
source_string_ptr->cmd_index=53;//cpbr
rmmi_cpbr_hdlr(source_string_ptr);
}
}
#endif/*__PHB_SORT_ENABLE__*/
break;
}
default:
{
/*unrecognizedformatofATcommandline*/
break;
}
}/*endoftheswitch*/
}
//#endif
rmmi_final_rsp_generator(source_string_ptr->src_id,ret_val,(kal_uint8*)rsp_str,string_length);
return;
}
2,voidl4cphb_read_response_handler(
kal_uint8src_id,
l4c_phb_entry_struct*list,
kal_uint16no_data,
l4c_result_struct*result,
kal_uint8phb_result)
{
kal_uint8type;
kal_uint8storage;
kal_uint16phb_current_action;
rmmi_context_struct*rmmi_ptr=RMMI_PTR;
l4c_context_struct*l4c_ptr=L4C_PTR;
kal_uint8length;
kal_uint8text[32];
kal_uint8i;
phb_current_action=l4c_ptr->phb_current_action;
rmmi_ptr->current_src=src_id;
if(rmmi_ptr->rmmi_atd_mem!=RMMI_MEM_DIAL_NONE)
{
//handleATDmemory
l4c_set_user_action(L4C_PHB,L4C_NO_USER,L4C_NO_ACTION);
if(phb_result!=PHB_ERRNO_READ_EMPTY)
{
l4c_phb_atd_mem_dial(list[0].tel.number,list[0].tel.type);//MAUI_01614617
}
else
{
rmmi_ptr->rmmi_atd_mem=RMMI_MEM_DIAL_NONE;
rmmi_result_code_fmttr(RMMI_RCODE_ERROR,RMMI_ERR_UNKNOWN);
}
return;
}
if(phb_current_action==CNUM_EXE)
{
l4c_phb_get_msisdn_rrsp(no_data,list);
}
elseif(phb_result!=PHB_ERRNO_READ_EMPTY)
{
length=strlen((char*)rmmi_ptr->cpbf_findtext);
if(length>0)
{
strncpy((char*)text,(char*)list->alpha_id.name,length);
//convertlowercaselettertouppercaseletter.
for(i=0;i<length;i++)
{
if((text>=0x61&&text<=0x7A)||/*Latinbasic*/
(text>=0xE0&&text<=0xF6)||(text>=0xF8&&text<=0xFE))/*Latin-1*/
{
text=text-0x20;
}
}
if(!strncmp(text,rmmi_ptr->cpbf_findtext,length))
{
l4c_phb_get_entry_rrsp(no_data,list);
}
}
else
{
l4c_phb_get_entry_rrsp(no_data,list);
}
}
l4c_set_user_action(L4C_PHB,L4C_NO_USER,L4C_NO_ACTION);
if((phb_current_action==CPBR_RANGE_EXE||phb_current_action==CNUM_EXE)
&&result->flag!=L4C_ERROR)
{
/*JudgeifwefinishreadPHBentriesofthespecifiedrange*/
rmmi_ptr->cpbr_range[0]++;
if(rmmi_ptr->cpbr_range[0]<=rmmi_ptr->cpbr_range[1])
{
storage=l4c_current_mod_id==MOD_L4C?PHB_STORAGE_SIMHB_STORAGE_SIM2;
if(phb_current_action==CPBR_RANGE_EXE)
{
if((rmmi_ptr->phb_storage_type==RMMI_PHB_SM)||(rmmi_ptr->phb_storage_type==RMMI_PHB_ME))
{
type=PHB_PHONEBOOK;
}
elseif(rmmi_ptr->phb_storage_type==RMMI_PHB_FD)
{
type=PHB_FDN;
}
elseif(rmmi_ptr->phb_storage_type==RMMI_PHB_ON)
{
type=PHB_MSISDN;
}
else
return;
if(rmmi_ptr->phb_storage_type==RMMI_PHB_ME)
{
storage=PHB_STORAGE_NVRAM;
}
l4c_phb_get_entry_by_range_req(src_id,type,storage,0xffff,rmmi_ptr->cpbr_range[0],1);
}
else
{
l4c_phb_get_entry_by_index_req(src_id,PHB_MSISDN,storage,0xffff,rmmi_ptr->cpbr_range[0],1);
}
return;
}
}
/*Endoftheread*/
memset(rmmi_ptr->cpbf_findtext,0,sizeof(rmmi_ptr->cpbf_findtext)-1);
l4c_phb_general_rrsp(*result);
}
3,voidrmmi_phb_entry_rsp_fmttr(l4c_phb_entry_struct*entry)
{
kal_uint16string_length;
kal_uint8buffer[/*MAX_DATA_QUEUE_LENGTH*/MAX_UART_LENGTH*3];
kal_uint8cmd[5];
kal_uint8rsp_string[4*MAX_PS_NAME_SIZE];
rmmi_context_struct*rmmi_ptr=RMMI_PTR;
kal_uint8length;
kal_trace(TRACE_FUNC,FUNC_RMMI_PHB_ENTRY_RSP_FMTTR_ENTRY);
kal_mem_set(cmd,0,5);
kal_mem_set(rsp_string,0,sizeof(kal_uint8)*4*MAX_PS_NAME_SIZE);
length=strlen((char*)rmmi_ptr->cpbf_findtext);
if(length>0)
{
kal_sprintf((char*)cmd,"CPBF");
}
else
{
switch(L4C_PTR->phb_current_action)
{
caseCPBF_EXE:
kal_sprintf((char*)cmd,"CPBF");
break;
caseCPBR_RANGE_EXE:
caseCPBR_EXE:
kal_sprintf((char*)cmd,"CPBR");
break;
}
}
rmmi_ptr->arg_list[0]=(void*)cmd;
rmmi_ptr->arg_list[1]=(void*)&entry->record_index;
rmmi_ptr->arg_list[2]=(void*)entry->tel.number;
rmmi_ptr->arg_list[3]=(void*)&entry->tel.type;
l4c_phb_format_alpha_id(&entry->alpha_id,rsp_string);
rmmi_ptr->arg_list[4]=(void*)rsp_string;
string_length=rmmi_fast_string_print(buffer,(kal_uint8*)"+%s:%u,\"%s\",%d,\"%s\"",rmmi_ptr->arg_list,5);
rmmi_write_to_uart((kal_uint8*)buffer,string_length,KAL_TRUE);
return;
}
目前只有在Modem版本上,才能支持AT+CPBF功能;在MMI版本上不支持CPBF;为了在MMI版本实现AT+CPBF:MMI并没有支持CPBF的相关接口;由于MMI版本,L4C也没有记录电话本的数据,所以需要通过MMI来获取数据;所以,借用CPBR的接口,从MMI读数据,然后在L4C分析比较数据;符合条件的就通过UART上报。
[SOLUTION]
下面的代码在09B0952上验证通过。
修改了三个函数,请注意对比区分添加修改的代码;
rmmi_cpbf_hdlr
l4cphb_read_response_handler
rmmi_phb_entry_rsp_fmttr
1,voidrmmi_cpbf_hdlr(rmmi_string_struct*source_string_ptr)
{
kal_boolret_val=KAL_FALSE;
kal_uint8const*rsp_str=NULL;
kal_uint16string_length=0;
//#ifdefined(__PHB_SORT_ENABLE__)
kal_uint8result;
kal_uint8length;
kal_uint8text[32];
l4_name_structname;
//#endif
kal_uint8buffer[RMMI_SHORT_RSP_LEN];
kal_uint8alpha_length;
kal_uint8num_length;
rmmi_context_struct*rmmi_ptr=RMMI_PTR;
kal_uint16index;
kal_uint8i;
kal_trace(TRACE_FUNC,FUNC_RMMI_CPBF_HDLR_ENTRY);
if(L4C_PTR->phb_ready_flag==KAL_FALSE)
{
rmmi_ptr->cmee_err=OPERATION_NOT_ALLOWED_ERR;
}
else
{
switch(source_string_ptr->cmd_mode)
{
caseRMMI_TEST_MODE:
{
if(rmmi_is_valid_phb_storage(rmmi_ptr->phb_storage_type)==KAL_TRUE)
{
rmmi_get_phb_length(&alpha_length,&num_length);
kal_sprintf((kal_char*)buffer,"+CPBF:%d,%d",num_length,alpha_length);
ret_val=KAL_TRUE;
rsp_str=&buffer[0];
string_length=strlen((char*)rsp_str);
}
break;
}
caseRMMI_SET_OR_EXECUTE_MODE:
{
#ifdefined(__PHB_SORT_ENABLE__)
result=rmmi_string_validator(
source_string_ptr,
rmmi_ptr->s_reg.s3,/*separator*/
30,
(kal_uint8*)text);
if(result==RMMI_VALIDATOR_ERROR)
{
break;
}
if((rmmi_ptr->char_set==RMMI_CHSET_UCS2)||(rmmi_ptr->char_set==RMMI_CHSET_HEX))
{
//wedon'tsupport+CPBFforUCS2.
rmmi_ptr->cmee_err=RMMI_ERR_OPERATION_NOT_SUPPORTED;
break;
/*converttoucs2valueandstoreinalpha_id
isUCS2format=check_ucs2_value((kal_uint8*)text,(kal_uint8*)name.name);
if(isUCS2format==KAL_FALSE)break;
name.name_length=strlen((char*)text)/2;
name.name_dcs=PHB_UCS2;*/
}
else
{
length=strlen((char*)text);
name.name_length=length;
kal_mem_cpy((kal_uint8*)name.name,(kal_uint8*)text,length);
name.name_dcs=PHB_ASCII;
}
ret_val=l4c_phb_get_entry_by_prefix_text_req(
source_string_ptr->src_id,
PHB_PHONEBOOK,
15,
(l4_name_struct*)&name);
if(ret_val==KAL_TRUE)
{
return;
}
else
{
rmmi_ptr->cmee_err=RMMI_ERR_COMMAND_CONFLICT;
}
#else/*__PHB_SORT_ENABLE__*/
/*mtk01616_081106:searchfunctionneeDTUrnoncompileoption__PHB_SORT_ENABLE__tosupport*/
//rmmi_ptr->cmee_err=RMMI_ERR_OPERATION_NOT_SUPPORTED;
index=source_string_ptr->index;
result=rmmi_string_validator(
source_string_ptr,
rmmi_ptr->s_reg.s3,/*separator*/
30,
(kal_uint8*)text);
source_string_ptr->index=index;
if(result==RMMI_VALIDATOR_ERROR)
{
break;
}
if((rmmi_ptr->char_set==RMMI_CHSET_UCS2)||(rmmi_ptr->char_set==RMMI_CHSET_HEX))
{
//wedon'tsupport+CPBFforUCS2.
rmmi_ptr->cmee_err=RMMI_ERR_OPERATION_NOT_SUPPORTED;
break;
/*converttoucs2valueandstoreinalpha_id
isUCS2format=check_ucs2_value((kal_uint8*)text,(kal_uint8*)name.name);
if(isUCS2format==KAL_FALSE)break;
name.name_length=strlen((char*)text)/2;
name.name_dcs=PHB_UCS2;*/
}
else
{
length=strlen((char*)text);
/*name.name_length=length;
kal_mem_cpy((kal_uint8*)name.name,(kal_uint8*)text,length);
name.name_dcs=PHB_ASCII;
*/
//convertlowercaselettertouppercaseletter.
for(i=0;i<length;i++)
{
if((text>=0x61&&text<=0x7A)||/*Latinbasic*/
(text>=0xE0&&text<=0xF6)||(text>=0xF8&&text<=0xFE))/*Latin-1*/
{
text=text-0X20;
}
}
strncpy((char*)rmmi_ptr->cpbf_findtext,(char*)text,length);
}
//getinfothroughcpbr
{
kal_uint16total,used;
if(!l4c_phb_get_storage_info(source_string_ptr->src_id,rmmi_ptr->phb_storage_type,&used,&total))
{
rmmi_ptr->cmee_err=RMMI_ERR_UNKNOWN;
mEMSet(rmmi_ptr->cpbf_findtext,0,sizeof(rmmi_ptr->cpbf_findtext)-1);
}
else
{
kal_uint8*string;
string=get_ctrl_buffer(40);//kal_uint8cpbf_findtext[30];
kal_wsprintf((WCHAR*)string,"at+cpbr=1,%d",total);
ucs2_to_ascii((kal_wchar*)string,(kal_uint8*)source_string_ptr->string_ptr);
free_ctrl_buffer(string);
source_string_ptr->cmd_index=53;//cpbr
rmmi_cpbr_hdlr(source_string_ptr);
}
}
#endif/*__PHB_SORT_ENABLE__*/
break;
}
default:
{
/*unrecognizedformatofATcommandline*/
break;
}
}/*endoftheswitch*/
}
//#endif
rmmi_final_rsp_generator(source_string_ptr->src_id,ret_val,(kal_uint8*)rsp_str,string_length);
return;
}
2,voidl4cphb_read_response_handler(
kal_uint8src_id,
l4c_phb_entry_struct*list,
kal_uint16no_data,
l4c_result_struct*result,
kal_uint8phb_result)
{
kal_uint8type;
kal_uint8storage;
kal_uint16phb_current_action;
rmmi_context_struct*rmmi_ptr=RMMI_PTR;
l4c_context_struct*l4c_ptr=L4C_PTR;
kal_uint8length;
kal_uint8text[32];
kal_uint8i;
phb_current_action=l4c_ptr->phb_current_action;
rmmi_ptr->current_src=src_id;
if(rmmi_ptr->rmmi_atd_mem!=RMMI_MEM_DIAL_NONE)
{
//handleATDmemory
l4c_set_user_action(L4C_PHB,L4C_NO_USER,L4C_NO_ACTION);
if(phb_result!=PHB_ERRNO_READ_EMPTY)
{
l4c_phb_atd_mem_dial(list[0].tel.number,list[0].tel.type);//MAUI_01614617
}
else
{
rmmi_ptr->rmmi_atd_mem=RMMI_MEM_DIAL_NONE;
rmmi_result_code_fmttr(RMMI_RCODE_ERROR,RMMI_ERR_UNKNOWN);
}
return;
}
if(phb_current_action==CNUM_EXE)
{
l4c_phb_get_msisdn_rrsp(no_data,list);
}
elseif(phb_result!=PHB_ERRNO_READ_EMPTY)
{
length=strlen((char*)rmmi_ptr->cpbf_findtext);
if(length>0)
{
strncpy((char*)text,(char*)list->alpha_id.name,length);
//convertlowercaselettertouppercaseletter.
for(i=0;i<length;i++)
{
if((text>=0x61&&text<=0x7A)||/*Latinbasic*/
(text>=0xE0&&text<=0xF6)||(text>=0xF8&&text<=0xFE))/*Latin-1*/
{
text=text-0x20;
}
}
if(!strncmp(text,rmmi_ptr->cpbf_findtext,length))
{
l4c_phb_get_entry_rrsp(no_data,list);
}
}
else
{
l4c_phb_get_entry_rrsp(no_data,list);
}
}
l4c_set_user_action(L4C_PHB,L4C_NO_USER,L4C_NO_ACTION);
if((phb_current_action==CPBR_RANGE_EXE||phb_current_action==CNUM_EXE)
&&result->flag!=L4C_ERROR)
{
/*JudgeifwefinishreadPHBentriesofthespecifiedrange*/
rmmi_ptr->cpbr_range[0]++;
if(rmmi_ptr->cpbr_range[0]<=rmmi_ptr->cpbr_range[1])
{
storage=l4c_current_mod_id==MOD_L4C?PHB_STORAGE_SIMHB_STORAGE_SIM2;
if(phb_current_action==CPBR_RANGE_EXE)
{
if((rmmi_ptr->phb_storage_type==RMMI_PHB_SM)||(rmmi_ptr->phb_storage_type==RMMI_PHB_ME))
{
type=PHB_PHONEBOOK;
}
elseif(rmmi_ptr->phb_storage_type==RMMI_PHB_FD)
{
type=PHB_FDN;
}
elseif(rmmi_ptr->phb_storage_type==RMMI_PHB_ON)
{
type=PHB_MSISDN;
}
else
return;
if(rmmi_ptr->phb_storage_type==RMMI_PHB_ME)
{
storage=PHB_STORAGE_NVRAM;
}
l4c_phb_get_entry_by_range_req(src_id,type,storage,0xffff,rmmi_ptr->cpbr_range[0],1);
}
else
{
l4c_phb_get_entry_by_index_req(src_id,PHB_MSISDN,storage,0xffff,rmmi_ptr->cpbr_range[0],1);
}
return;
}
}
/*Endoftheread*/
memset(rmmi_ptr->cpbf_findtext,0,sizeof(rmmi_ptr->cpbf_findtext)-1);
l4c_phb_general_rrsp(*result);
}
3,voidrmmi_phb_entry_rsp_fmttr(l4c_phb_entry_struct*entry)
{
kal_uint16string_length;
kal_uint8buffer[/*MAX_DATA_QUEUE_LENGTH*/MAX_UART_LENGTH*3];
kal_uint8cmd[5];
kal_uint8rsp_string[4*MAX_PS_NAME_SIZE];
rmmi_context_struct*rmmi_ptr=RMMI_PTR;
kal_uint8length;
kal_trace(TRACE_FUNC,FUNC_RMMI_PHB_ENTRY_RSP_FMTTR_ENTRY);
kal_mem_set(cmd,0,5);
kal_mem_set(rsp_string,0,sizeof(kal_uint8)*4*MAX_PS_NAME_SIZE);
length=strlen((char*)rmmi_ptr->cpbf_findtext);
if(length>0)
{
kal_sprintf((char*)cmd,"CPBF");
}
else
{
switch(L4C_PTR->phb_current_action)
{
caseCPBF_EXE:
kal_sprintf((char*)cmd,"CPBF");
break;
caseCPBR_RANGE_EXE:
caseCPBR_EXE:
kal_sprintf((char*)cmd,"CPBR");
break;
}
}
rmmi_ptr->arg_list[0]=(void*)cmd;
rmmi_ptr->arg_list[1]=(void*)&entry->record_index;
rmmi_ptr->arg_list[2]=(void*)entry->tel.number;
rmmi_ptr->arg_list[3]=(void*)&entry->tel.type;
l4c_phb_format_alpha_id(&entry->alpha_id,rsp_string);
rmmi_ptr->arg_list[4]=(void*)rsp_string;
string_length=rmmi_fast_string_print(buffer,(kal_uint8*)"+%s:%u,\"%s\",%d,\"%s\"",rmmi_ptr->arg_list,5);
rmmi_write_to_uart((kal_uint8*)buffer,string_length,KAL_TRUE);
return;
}
路过。