|
例如短信息中心号码为移动上海 +8613800210500F 对方手机号码为 +8618802136442 要发送的信息为“中” 算法步骤: 一、地址部分,用字符串 addr 表示 1、将短信息中心号码去掉+号,看看长度是否为偶数,如果不是,最后添加F 2、将奇数位和偶数位交换。 3、将短信息中心号码前面加上字符91,91是国际化的意思 4、算出 addr 长度,结果除2,格式化成2位的16进制字符串,16 / 2 = 8 => "08" 二、手机号码部分,用字符串 phone 1、将手机号码去掉+号,看看长度是否为偶数,如果不是,最后添加F 2、将手机号码奇数位和偶数位交换。 三、短信息部分,用字符串 msg 表示 1、转字符串转换为Unicode代码,例如“中”的unicode代码为 4E2D, function TfrmMain.str_Gb2UniCode( text: string ): String; 即 msg = "中" 2、将 msg 长度除2,保留两位16进制数,即 4E2D = 4 / 2 => "02",再加上 msg 四、组合 1、手机号码前加上字符串 11000D91,这是一些PDU代码,写死就行了,感兴趣可以参考相关PDU格式说明 2、手机号码后加上 000800 和刚才的短信息内容,000800也写死就可以了 3、phone 长度除以2,格式化成2位的十进制数 五、所以要发送的内容为 即AT+CMGS=17<回车>0891683108200105F011000D91688108126344F2000800024E2D^Z换行回车 2... 注意到Ctrl-Z是用来表示终结发送到移动设备的文本输入。 使用Visual Basic来发送SMS文本到Nokia电话: ' Set up the communications port ' Set for 9600 baud, no parity, 8 data, and 1 stop bit. ' Tell the control to read entire buffer when Input is used ' Open the port ' Send an 'AT' command to the phone ' Set up the phone for a text message ' Prep for SMS, give destination type and destination address. ' Now send the text to the phone and terminate with (Ctrl-Z) ' Close the port 在终端,看起来就象下面: AT OK 在超级终端演示如下 组成分析:0891683108200105F0(0891+信息中心)+11000D91+688108126344F2(手机号)+000800+024E2D 附信息内容: Text MAX abcdefghijklmnopqrstuvwxwzabcdefghijklmnopqrstuvwxwzabcdefghijklmnopqrstuvwxwzabcdefghijklmnopqrstuvwxwzabcdefghijklmnopqrstuvwxwzabcdefghijklmno PDU General 0891683108200105F011000D91688108126344F2000800024E2D MAX 0891683108200105F011000D91688108126344F2000800824E004E014E024E034E044E054E064E074E084E094E0A4E0B4E0C4E0D4E0E4E0F4E104E114E124E134E144E154E164E174E184E194E1A4E1B4E1C4E1D4E1E4E1F4E204E214E224E234E244E254E264E274E284E294E2A4E2B4E2C4E2D4E2E4E2F4E304E314E324E334E344E354E364E374E384E394E3A4E3B4E3C4E3D4E3E4E3F4E40 |
14
Nov 2011
Nov 2011
Category: Others, Test
Tags: PDU信息 构成算法 CMGS CMGW
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
