Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1050634
  • 博文数量: 166
  • 博客积分: 10217
  • 博客等级: 上将
  • 技术积分: 2133
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-09 19:45
文章分类

全部博文(166)

文章存档

2012年(3)

2011年(7)

2010年(18)

2009年(59)

2008年(79)

我的朋友

分类: LINUX

2008-06-20 16:56:53

方法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?)。

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