Chinaunix首页 | 论坛 | 博客
  • 博客访问: 346734
  • 博文数量: 39
  • 博客积分: 1931
  • 博客等级: 上尉
  • 技术积分: 778
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-11 10:54
文章分类

全部博文(39)

文章存档

2011年(20)

2010年(15)

2009年(4)

我的朋友

分类: 嵌入式

2010-12-15 09:50:55

方法1、AT+CIMI
判断该SIM卡属于哪个运营商,前3为表示国家,如460表示中国,接下来的2位是运营商代码,00表示中国移动,01表示中国联通
方法2:  AT+COPS?
此命令返回的数据格式有几种,对于MTK,有
:
0       long format alphanumeric
1       short format alphanumeric
2       numeric
可以通过at+cops=3,0 或at+cops=3,01或at+cops=3,2来设置
无卡时:
at+cops                                
ERROR
at+cops?
+COPS:0
                                                                               
OK                                                                             
at+cops=?                                                                      
+COPS:                                                                         
,(0, 1, 3),(0-2)                                                               
                                                                               
OK   
有卡:
at+cops                                
ERROR                                  
at+cops?                               
+COPS: 0,0,"China Telecom"(这里为移动的卡,如为联通的卡,则为+COPS: 0,0,"China Unicom" )

OK
at+cops=?                                                                      
+COPS: (2,"China Telecom","CT-GSM","46000"),(3,"China Unicom","CU-GSM","46001"),
,(0, 1, 3),(0-2)                                                               
                                                                               
OK  



at+cops=3,2                                                                    
OK 
at+cops?                                                                       
+COPS: 0,2,"46000"         

at+cops=3,0                                                                    
OK                                                                             
at+cops?                                                                       
+COPS: 0,0,"China Telecom"  
对此,gsmd已有处理,但有个问题,要把0改为gmh->id才能阻塞读取。

另外,
有卡时
at+cpin                                                                        
ERROR                                                                          
at+cpin?                                                                       
+CPIN: READY                                                                   
                                                                               
OK                                                                             
at+cpin=?                                                                      
OK   
  
无卡时:
at+cpin                                                                     
ERROR                                                                       
at+cpin?                                                                    
ERROR                                  
at+cpin=?                              
OK                                     
at+cpin                                
ERROR

GPRS模块在上电时就会将SIM卡的数据读出保存起来,一般要隔较长的时间或者有需要时再去读取,所以当你带电拔出SIM卡后,系统还是保存着原来的SIM卡信息。所以建议先解注册(at+cfun=0)一下,再注册上然后再检查是否有SIM卡(at+cpin?)。

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