Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4247592
  • 博文数量: 776
  • 博客积分: 13014
  • 博客等级: 上将
  • 技术积分: 10391
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-22 17:00
文章分类

全部博文(776)

文章存档

2015年(55)

2014年(43)

2013年(147)

2012年(20)

2011年(82)

2010年(429)

分类: LINUX

2010-02-22 21:26:02

一、AT+CMGL 读取所有短信

A、读取所有的信息:

第一步:at+cmgf=1 如果返回ok则继续。

说明:AT+CMGF SELECT SMS MESSAGE FORMAT

第二步:at+cmgl=”all”

成功返回OK否则ERROR

+CMGL: 1,"REC READ","+8613702936376",,"05/12/16,09:04:43+00"

test

OK

B、读取未读的信息

第一步:at+cmgf=1

如果返回ok则继续。

第二步:at+cmgl=” rec unread”

成功返回OK否则ERROR

C、读取已读的信息

第一步:at+cmgf=1

如果返回ok则继续。

第二步:at+cmgl=” rec read”

成功返回OK否则ERROR

AT+CMGL参数:

1) If text mode:

"REC UNREAD" Received unread messages (default)

"REC READ" Received read messages

"STO UNSENT" Stored unsent messages

"STO SENT" Stored sent messages

"ALL" All messages

2) If PDU mode:

0 Received unread messages (default)

1 Received read messages

2 Stored unsent messages

3 Stored sent messages

4 All messages

二、AT+CMGR Read SMS message

从X存储区读短消息:

第一步:at+cmgf=1 如果返回ok则继续。

第二步:at+cmgl=x

三、AT+CMGD Delete SMS message

删除信息:

第一步:at+cmgf=1

如果返回ok则继续。

第二步:at+cmgd= 数字号

成功返回OK否则ERROR

四、AT+CSCA SMS service centre address(设置短信中心号码)

设置短信中心号码:

第一步:at+cmgf=1

如果返回ok则继续。

第二步:at+csca=”短信中心号码 (比如+8613800546500)

成功返回OK否则ERROR

五、AT+CMGS Send SMS message (发送信息)

发送信息:

第一步:at+cmgf=1

如果返回ok则继续。

第二步:AT+CMGS=“+8613xxxxxxxxx”<回车>

>输入短消息。Crtl+Z结束并发送。

注:此只能发送英文与数字

六、查询

查询设备:

命令:AT+CGMI<回车>

返回:SIEMENS

返回:OK

命令:AT+CGMM<回车>

返回:MC35i

返回:OK

命令:AT+CMEE=1<回车>

返回:具体的错误代码

ATZ;E 回车 Echo OFF

ATZ;E1回车 Echo ON

AT+CREG?回车 回答x(X=2脱网,X=1注册,X=0状态不明)

AT+COPS?回车 表示SIM卡是否被网络接受

AT+COPS=?回车 显示所有可用的网络。

AT+CREG?回车(是否网络注册)

AT+CSQ SIGNAL QUALITY REPORT

AT+IPR=2400 回车(改变RS232口的速率至2400bps)

AT&W 回车 (保存已改参数)

输入PIN码:AT+CPIN=“xxxx”

七、网络是否注册(AT+CREG?)

命令:at+cmgf=1

返回:at+cmgf=1 返回:OK

命令:AT+CREG?

返回:AT+CREG? 返回:+CREG: 0,1

注:( 2脱网, 1注册, 0状态不明)

返回:OK

八、SIM卡是否被网络接受(AT+COPS?)

命令:at+cmgf=1

返回:at+cmgf=1

返回:OK

命令:at+cops?

返回:+COPS: 0,0,"China Mobile"

返回:OK

九、显示所有可用的网络(AT+COPS=?)

命令:at+cmgf=1

返回:at+cmgf=1

返回:OK

命令:at+cops=?

返回:+COPS: (2,"China Mobile",,"46000"),(3,"China Unicom",,"46001"),,(0-4),(0,2)

返回:OK

十、打电话

Demonstration Syntax Expect Result

Make a voice call ATD6241xxxx; OK MS makes a voice call

Hang up a call ATH OK Call dropped

问题解决

采用sim300发送短信时采用下面的格式

AT+CMGF=1 设置文本格式

AT+CMGS=”13245678912” 注意这块一定要加上双引号。否则返回ERROR

另外如果发送不出去,有可能是短信中心号码设置的不正确。


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

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

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

2.设置短消息中心
AT+CSCA=“+8613800270500”回车(具体的号码由当地的运营商决定。)// +8613010341500 -- 联通, +8613800250500 --移动

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

阅读(17925) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~