例子1(手机换为中文系统,则发过来的短信为PDU模式,DCS2编码)原文:61.53.182.153
+CMTI: "SM", 24
at+cmgr=24
+CMGR: 0,,46 //0表示未读过,46个字节是从短信中心号码到末尾的字节数)
0891683108100005F0040D91683125818344F6 0008 402122115414 23 1A 00360031002E0035003300
2E003100380032002E003100350033
OK
+CMTI: "SM", 23
at+cmgr=23
+CMGR: 1,,46 //1表示已读过
0891683108100005F0040D91683119905081F0 0008 402132415590 23 1A 00360031002E0035003000
2E003100380033002E003100310034
OK
分析:
字节序号 数据 解释
1 08 从91开始,到F0结束共八个字节
2 91 地址类型(加'+'),意味着国际格式的电话号码
3,4,5,6,7,8,9 683108100005F0 短信中心号码,雅虎通发来的是683108501905F0(1380 0591 500)
10 04 FirstOctet:TP-MMS=1:No more messages are waiting for the MS in this SC
11 0D Address-Length:目的号码长度,只记地址域中的半字节个数,不含91和填充位
12 91 地址类型(加'+'):The international format shall be accepted also
when the message is destined to a recipient in the same country as the MSC or as the SGSN.
13,14,15,16,17,18,19 683125818344F6 目的号码
20 00 PID=00
21 08 TP-DCS,08表示编码方式为:UCS2,无类别,动感地带全英文信息则=00
22,23,24,25,26,27 402122115414 TP-SCTS,年月日时分秒(字节内高低半字节交换)
28 23 时区
29 1A TP-UDL DCS2编码时计八位组的个数
30 TP-UD,短信息内容
//61.50.183.114,13个字符,转成ASCII码,长度就是1A,再变成DCS2编码,
//通过串口发过来的字节数还要乘以2,共收到52个字节。
---------------------------------------------------------------------------------------------------
另外,分析雅虎通发过来的短信
1 08
2 91
3,4,5,6,7,8,9 683108501905F0 短信中心号码(广州)
10 24 FirstOctet(以下至TP-SCTS之前最大12个字节,地址类型除外)
注:应为04,For simplified SMS, the PDU does not contain any
Status report, also the bit no. 5 of the first octet(TP-SRI) is given 0.
11 12 Address-Length:目的号码长度,18个字节长,只记地址域中的半字节个数,不含地址类型
12 A1 地址类型(无前缀):Prefix or escape digits shall not be included.
13,14,15,16,17,18,19,20,21 731280168311776870 目的号码 37210 86 13811778607
22 15 TP-PID
23 08 TP-DCS:UCS2(16bit)
24,25,26,27,28,29,30 50205251914323 TP-SCTS:年月日时分秒时区
31 1A TP-UDL
32 TP-UD:
00360031002E003100340039002E003100310037002E00350036 61.149.137.56
------------------------------------------------------------------------------------------------
例子2(手机换为英文系统,则发过来的短信也为PDU模式,7bit编码)原文:61.50.183.114
t+cmgr=1
+CMGR: 1,,32
0891683108100005F0040D91683119905081F0 0000 402122617150 230D B698AB0673C57039572C4603
OK