⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdmasms.cpp

📁 针对CDMA2000层3信令的SMS的unicode ,解析出文本格式的SMS的源码,在c++builder环境下开发
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}


//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/

void  TForm1::User_RC_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
       char Response_code=0;
	Response_code= pMsg->l3_data[charAddr];
	out_sms.Res_code=Response_code;
	return;		
}

//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/
void  TForm1::UserData_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
        char msg_encoding;
        char massage_type;
        char num_fields;
        char currBit = 0;
        int i;

        msg_encoding = pMsg->l3_data[charAddr]>>3;
        currBit = currBit+5;
        if(msg_encoding == 1)
        {
                currBit = currBit+8;
                //msg_type取值
        }

        uint32 copyLength = 8;
        //BCopy((byte*)(pMsg->l3_data),(uint32)(charAddr*8+currBit),(byte*)&num_fields,0,copyLength);
        BitCopyFromBitStream((byte*)(pMsg->l3_data),(uint32)(charAddr*8+currBit),(byte)num_fields,copyLength);
        currBit = currBit+copyLength;

        out_sms.dataLen = num_fields;
        //SMS 内容解码
        /* ascii解码*/
        if(msg_encoding == SEVEN_BIT_ASCII)
        {
                out_sms.encodType = 0;
                byte* ptr_ascii_string;
                uint32 byteCount = num_fields+1;
                ptr_ascii_string = new  byte[byteCount];

                for(i=0;i<num_fields;i++)
                {
                        BitCopyFromBitStream((byte*)(pMsg->l3_data),(uint32)(charAddr*8+currBit),ptr_ascii_string[i],7);
                        currBit = currBit+7;
                }
                strcpy((char *)(&out_sms.data), ptr_ascii_string);
                delete  ptr_ascii_string;
        }
        /*Unicode 解码*/
        if(msg_encoding == UNICODE_ENCOD)
        {
                out_sms.encodType = 1;
                byte* ptr_unicode_string;   //要解码的数据流
                uint32 byteCount = (num_fields*16)/8+1;
                ptr_unicode_string = new  byte[byteCount];

                /*for(i=0;i<num_fields*2;i++)
                {
                        BitCopyFromBitStream((byte*)(pMsg->l3_data),(uint32)(charAddr*8+currBit),ptr_unicode_string[i],8);
                        currBit = currBit+8;
                } */
                
                BCopy((byte*)(pMsg->l3_data),(uint32)(charAddr*8+currBit),ptr_unicode_string,0,num_fields*16);
                String_uni2qw_convert((void*)ptr_unicode_string, num_fields*2);
                strcpy((char *)(&out_sms.data), ptr_unicode_string);
                delete   ptr_unicode_string;
        }

        return;
}

//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/
void  TForm1::Timer_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
        char year;
        char month;
        char day;
        char hour;
        char minute;
        char second;
        char currCharAdd =  charAddr;
        out_sms.timerLen = 6;

        year = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        month = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        day = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        hour = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        minute = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        second = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        out_sms.timer.year = ((year&0xf0)>>4)*10+(year&0x0f);
        out_sms.timer.month = ((month&0xf0)>>4)*10+(month&0x0f);
        out_sms.timer.day = ((day&0xf0)>>4)*10+(day&0x0f);
        out_sms.timer.hour = ((hour&0xf0)>>4)*10+(hour&0x0f);
        out_sms.timer.minute = ((minute&0xf0)>>4)*10+(minute&0x0f);
        out_sms.timer.second = ((second&0xf0)>>4)*10+(second&0x0f);
        return;
}


//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/
void  TForm1::Val_per_A_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
        char year;
        char month;
        char day;
        char hour;
        char minute;
        char second;
        char currCharAdd =  charAddr;
        out_sms.Val_per_A_len= 6;

        year = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        month = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        day = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        hour = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        minute = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        second = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        out_sms.Val_per_A.year = ((year&0xf0)>>4)*10+(year&0x0f);
        out_sms.Val_per_A.month = ((month&0xf0)>>4)*10+(month&0x0f);
        out_sms.Val_per_A.day = ((day&0xf0)>>4)*10+(day&0x0f);
        out_sms.Val_per_A.hour = ((hour&0xf0)>>4)*10+(hour&0x0f);
        out_sms.Val_per_A.minute = ((minute&0xf0)>>4)*10+(minute&0x0f);
        out_sms.Val_per_A.second = ((second&0xf0)>>4)*10+(second&0x0f);
        return;
}



//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/
void  TForm1::Val_per_R_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
       char Val_per_R=0;
	Val_per_R= pMsg->l3_data[charAddr];
	out_sms.Val_per_R=Val_per_R;
	out_sms.Have_Val_per_R=1;
	return;		

}


//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/
void  TForm1::Def_del__time_A_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
        char year;
        char month;
        char day;
        char hour;
        char minute;
        char second;
        char currCharAdd =  charAddr;
        out_sms.Def_del_time_A_len= 6;

        year = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        month = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        day = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        hour = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        minute = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        second = pMsg->l3_data[currCharAdd];
        currCharAdd++;

        out_sms.Def_del_time_A.year = ((year&0xf0)>>4)*10+(year&0x0f);
        out_sms.Def_del_time_A.month = ((month&0xf0)>>4)*10+(month&0x0f);
        out_sms.Def_del_time_A.day = ((day&0xf0)>>4)*10+(day&0x0f);
        out_sms.Def_del_time_A.hour = ((hour&0xf0)>>4)*10+(hour&0x0f);
        out_sms.Def_del_time_A.minute = ((minute&0xf0)>>4)*10+(minute&0x0f);
        out_sms.Def_del_time_A.second = ((second&0xf0)>>4)*10+(second&0x0f);
        return;
}



//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/
void  TForm1::Def_del__time_R_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
       char Def_del__time_R=0;
	Def_del__time_R= pMsg->l3_data[charAddr];
	out_sms.Val_per_R=Def_del__time_R;
	out_sms.Have_Val_per_R=1;
	return;
}

//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/

void  TForm1::Priority_Indicator_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
	 out_sms.Priority_Indicator=(pMsg->l3_data[charAddr]>>6)&0x3;
	 out_sms.Have_Priority_Indicator=1;
	 return;
}

//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/

void  TForm1::Privacy_Indicator_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
	 out_sms.Privacy_Indicator=(pMsg->l3_data[charAddr]>>6)&0x3;
	 out_sms.Have_Privacy_Indicator=1;
	 return;
}

//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/

void  TForm1::Reply_Option_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
	 out_sms.Reply_Option	= pMsg->l3_data[charAddr];
	 out_sms.Have_Reply_Option=1;
	 return;
}

//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构
      功能:解析出SMS
*********************************************************/
void  TForm1::Num_Of_Msgs_CDMASMSDec(L3_SMSDef* pMsg,int charAddr,int length,SMSElementDef& out_sms)
{
        char num;
	 num=pMsg->l3_data[charAddr];
	 out_sms.Num_Of_Msgs=(num>>4&0xf)*10+(num&0xf);
	 out_sms.Have_Num_Of_Msgs=1;
	 return;  
}

//---------------------------------------------------------------------------
/*********************************************************
函数说明:
      输入参数:pMsg:层三DBM消息
                charAddr :UserData起始位置对应l3_data[]的下标(参数开始位置,不包括ID和长度)
                length:参数长度
      输出参数:output_sms结构

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -