金笛工业手机论坛  

返回   金笛工业手机论坛 > 开发者乐园 > 短信开发资料

短信开发资料 短信开发技巧,代码分析

回复
 
LinkBack 主题工具 显示模式
旧 2009-10-15   #1 (permalink)
高级会员
 
注册日期: 2009-07-09
住址: 北京海淀
帖子: 192
lihb 正向着好的方向发展
默认 AT指令(打电话与发短信)

因为我做的这个模块只用打电话与发短信的功能 而且鉴于网上许多命令写的特别难理解。所以花了一些时间把常用的AT指令整理出来 以下命令全部在TC35i上测试成功.

一.打电话
ATD 拨号命令。这个命令用来设置通话、数据或传真呼叫。
例 ATD13844019770;
ATH 挂机命令。
ATA 接电话。

二.短信息
1.设置短消息模式
AT+CMGF=?
(0)=PDU (1)=TEXT
PDU模式可以传送文字 TEXT模式只可以传送数字和字母

2.设置短消息中心
AT+CSCA=“+8613800270500”回车(具体的号码由当地的运营商决定。)

3.接收短消息
AT+CMGR=X回车 (从X存储区读短消息)
例如:
at+cmgr=1
+CMGR: "REC READ","06014",,"06/12/12,10:11:21+32"
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D39002C4EE5514D624B67388AB505C673A902062104E0D5FC589817684635F5931
AT+CMGL=1
+CMGL: 2,1,,28
0891683108501705F0040D91683177471549F0000040016251920200098A640F269BC5DA41
+CMGL: 3,1,,28
0891683108501705F0040D91683177471549F0000040016251928300098A640F0683C1DA41
ok
1) text 模式(AT+CMGF=1采用文本格式发送)
“REC UNREAD” 未读信息 (默认)
“REC READ” 已读信息
“STO UNSENT” 未发送信息
“STO SENT” 已发送信息
“ALL” 所有信息
2) PDU 模式(AT+CMGF=0采用PDU格式发送)
0 未读信息 (默认)
1 已读信息
2 未发送信息
3 已发送信息
4 全部信息

单条读取短信
AT+CMGR=8
返回:+CMGR: 1,,28
0891683108501705F0040D91683177471549F0000040017290146500098A640F0683C5DA41
AT+CMGD=X回车 (从X存储区删除短消息)

4.发送短消息
AT+CMGF=1回车(采用文本格式发送,如用PDU格式,则AT+CMGF=0)
AT+CMGS=“+8613xxxxxxxxx”回车
>输入短消息。Crtl+Z结束并发送。
发送:0891683108701305F011000B813179133208F10000AA2632184CF682D95
E30DC2B36D3D170A0243106933D97A0243106933D97A02451068B19834926081A
不计最初9个短消息信元字节,本短信息有52字节(104个字符)。
AT+CMGS仅说明了 SMSC信息内容的长度,在收到手机回答的>符号手才发送PDU数据串,
并以(CTRL^Z)结束。

编辑短信到存储器
AT+CMGW=

从存储器中发短信
AT+CMSS=?

读取手机短信容量状况,"ME"74为手机中74条 "SM" 为SIM卡
AT+CPMS?
返回:+CPMS: "ME",74,100,"SM",0,50,"SM",0,50
联通
AT+CPMS?
+CPMS: "ME",74,100,"SM",18,40,"SM",18,40

测试数据
采用超级终端9600bps 模块TC35i
^SYSSTART
at+cmgf=1]
ERROR
at+cmgf=1
OK
at+cmgr=1
+CMGR: "REC READ","+8613689801521",,"06/11/29,09:51:35+32"
59294F7F8BF4002A795D798F002C572896EA4E2D002A75285FC3753B00390039673590C191D19999
8BB8613F002C4E0A5E1D5C314F1A542C5230002E6211628A82B1753B6EE196625B50002C7EC84E8E
4E0A5E1D8BF4003A8BB84E2A613F5427002E62118BF4003A62118981770B77ED4FE176844EBA6574
4E2A51AC5B6390FD6E296696002E

OK
at+cmgs=13894894592
> hjdskdhfjk
+CMGS: 181

OK
atd13234372829;
NO CARRIER
at+cmgs=13234372829
> ni ha fdhjkafhkhk
+CMGS: 1

OK
atd13234372829;
NO CARRIER
atd13234372829;
NO CARRIER
4td13704360707;
AT+CMGF?
+CMGF: 1

OK
AT+CMGR=1
+CMGR: "REC READ","06013",,"06/11/28,12:10:39+32"
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C
8BF75C3D5FEB5B5850A88BDD8D39002C4EE5514D624B673A88AB505C673A902062104E0D5FC58981
7684635F5931

OK
AT+CMGF=0
OK
AT+CMGL=4
+CMGL: 1,1,,102
0891683108401345F42405A16010F3000860118221019323565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 2,1,,102
0891683108401345F42405A16010F0000860118241400023565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 3,1,,150
0891683108401345F40406A13521850008601192117265238662E800310032003500390030003600
38003000304E0B8F7D67084EAE4E4B4E0A30014E0A6D776EE930016C424F5B591A999694C358F0FF
0C8BA94F607684624B673A66F452A8542CFF0162E80031003200350039003000360038003100387C
BE5F698DA34E8B7B494F60542CFF018BE200300031003000360037003800360038003800300030
+CMGL: 4,1,,102
0891683108401345F42405A16010F1000860119211946523565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 5,1,,102
0891683108401345F42405A16010F1000860119251302123565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 6,1,,96
0891683108401345F42405A17004F300086011925152612350611F8C2260A853C252A06211516C53
F853D177ED4FE18D608BDD8D396D3B52A8002C8D60900176848BDD8D395DF25B5851654E8660A85E
10623700218BE660C554A88BE200310030003000380036002E

OK
AT+CMGF?
+CMGF: 0

OK
AT+CMGF?
+CMGF: 0

OK
0000?
ATS0=2
OK
0020?
ATS0=2
OK
2
OK

NO CARRIER
at+cnmi=2,1,,1
OK
at+cpas
+CPAS: 0

OK
atd13844874139;
NO DIALTONE
at+csq
+CSQ: 22,99

OK
at+cmgf
ERROR
at+cmgf?
+CMGF: 0

OK
at+cmgl=1
+CMGL: 1,1,,102
0891683108401345F40405A16010F4000860212101111223565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 2,1,,102
0891683108401345F40405A16010F1000860212121143323565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 3,1,,102
0891683108401345F40405A16010F1000860213190537523565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 4,1,,102
0891683108401345F40405A16010F0000860214121641423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A9020

OK
at+cmgr=8
+CMGR: 0,,0

OK
at^scni
^SCNI: 1
^SCNI: 2
^SCNI: 3
^SCNI: 4
^SCNI: 5
^SCNI: 6
^SCNI: 7
OK
at+cmgf=1
OK
at+cmfr
ERROR
at+cmgl
+CMGL: 5,"REC UNREAD","06010",,"06/12/16,13:49:48+32"
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C
8BF75C3D5FEB5B5850A88BDD8D39002C4EE5514D624B673A88AB505C673A902062104E0D5FC58981
7684635F5931
+CMGL: 6,"REC UNREAD","+8613844019770",,"06/12/16,14:06:54+32"
62C95F0053E36C34

OK
at+cmgl=4
ERROR
at+cmgl=1
ERROR
at+cmgl=4
ERROR
at+cmgf=0
OK
at+cmgl=4
+CMGL: 1,1,,102
0891683108401345F40405A16010F4000860212101111223565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 2,1,,102
0891683108401345F40405A16010F1000860212121143323565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 3,1,,102
0891683108401345F40405A16010F1000860213190537523565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 4,1,,102
0891683108401345F40405A16010F0000860214121641423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 5,1,,102
0891683108401345F40405A16010F0000860216131948423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 6,1,,28
0891683108401345F5040D91683148049177F00008602161416045230862C95F0053E36C34

OK
at+cmgl=4
+CMGL: 1,1,,102
0891683108401345F40405A16010F4000860212101111223565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 2,1,,102
0891683108401345F40405A16010F1000860212121143323565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 3,1,,102
0891683108401345F40405A16010F1000860213190537523565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A9020
+CMGL: 4,1,,102
0891683108401345F40405A16010F0000860214121641423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 5,1,,102
0891683108401345F40405A16010F0000860216131948423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 6,1,,28
0891683108401345F5040D91683148049177F00008602161416045230862C95F0053E36C34

OK
at+cmgl=1
+CMGL: 1,1,,102
0891683108401345F40405A16010F4000860212101111223565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 2,1,,102
0891683108401345F40405A16010F1000860212121143323565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 3,1,,102
0891683108401345F40405A16010F1000860213190537523565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 4,1,,102
0891683108401345F40405A16010F0000860214121641423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A9020
+CMGL: 5,1,,102
0891683108401345F40405A16010F0000860216131948423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 6,1,,28
0891683108401345F5040D91683148049177F00008602161416045230862C95F0053E36C34

OK
at+cmgl=2
OK
at+cmgl=3
OK
at+cmgl=5
ERROR
at+cmgl=1
+CMGL: 1,1,,102
0891683108401345F40405A16010F4000860212101111223565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 2,1,,102
0891683108401345F40405A16010F1000860212121143323565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 3,1,,102
0891683108401345F40405A16010F1000860213190537523565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 4,1,,102
0891683108401345F40405A16010F0000860214121641423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 5,1,,102
0891683108401345F40405A16010F0000860216131948423565C0A656C76845BA26237002C60A876
8498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C8BF75C3D5FEB5B5850A88BDD8D3900
2C4EE5514D624B673A88AB505C673A902062104E0D5FC589817684635F5931
+CMGL: 6,1,,28
0891683108401345F5040D91683148049177F00008602161416045230862C95F0053E36C34

OK
atd13844019770;
NO CARRIER
ath
OK
ath
OK
ath
OK
at+clip=?
+CLIP: (0,1)

OK
0teo4?
at+cmgf=0
OK
at+csms
ERROR
at+csms=0
+CSMS: 1,1,1
OK
at+cmgs="13844019770"
ERROR
at+cmgs=13844019770
ERROR
at+cmgs
ERROR
at+cmgs="+8613844019770"
ERROR
at+cmgs="+8613844019770"
ERROR
ath
OK
atd13844019770;
NO CARRIER
ath
OK
at+cmgf=1
OK
at+cmgs="13844019770"
starli ok?
+CMGS: 36

OK
at+cmgs="13844019770"
> 你好
+CMGS: 37

OK
at+cmti
ERROR
at+cmti:"sm",2
ERROR
at+cmgr=2
+CMGR: "REC READ","06011",,"06/12/12,12:41:33+32"
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C
8BF75C3D5FEB5B5850A88BDD8D39002C4EE5514D624B673A88AB505C673A902062104E0D5FC58981
7684635F5931

OK
at+cmgr=3
+CMGR: "REC READ","06011",,"06/12/13,09:35:57+32"
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003
7684635F5931

OK
at+cmgr=4
+CMGR: "REC READ","06010",,"06/12/14,12:46:41+32"
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C
8BF75C3D5FEB5B5850A88BDD8D39002C4EE5514D624B673A88AB505C673A902062104E0D5FC58981
7684635F5931

OK
at+cmgr=1
+CMGR: "REC READ","06014",,"06/12/12,10:11:21+32"
5C0A656C76845BA26237002C60A8768498845B588BDD8D395DF27ECF4E0D8DB3003200305143002C
8BF75C3D5FEB5B5850A88BDD8D39002C4EE5514D624B673A88AB505C673A902062104E0D5FC58981
7684635F5931

OK
2
OK

NO CARRIER
2
OK
lihb 当前离线   回复时引用此帖
回复

书签


当前查看此主题的会员: 1 (0 位会员和 1 位游客)
 
主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用



所有时间均为北京时间。现在的时间是 07:23


Powered by vBulletin® 版本 3.8.3
版权所有 ©2000 - 2024,Jelsoft Enterprises Ltd.