极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12976|回复: 7

求助 sim900

[复制链接]
发表于 2014-12-26 17:06:16 | 显示全部楼层 |阅读模式
我是个新人,想学习sim900的使用。入手了一个sim900扩展模块,板子是拿到了但头脑一片空白。不知道从哪里开始。求大神给点基础的资料帮助入门,不胜感激!
回复

使用道具 举报

发表于 2014-12-26 20:12:30 | 显示全部楼层
找卖家要吧  hw相关的东西......
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-12-29 11:42:18 | 显示全部楼层
zoologist 发表于 2014-12-26 20:12
找卖家要吧  hw相关的东西......

找过了,没有!我晕掉了,自己又不懂
回复 支持 反对

使用道具 举报

发表于 2014-12-29 15:04:00 | 显示全部楼层
卖家没有了?那就根据图片找taobao同款的吧
回复 支持 反对

使用道具 举报

发表于 2014-12-29 16:46:32 | 显示全部楼层
亲可以在我百度云里面下载  http://pan.baidu.com/s/1jGqWDXc   希望可以帮到你
回复 支持 反对

使用道具 举报

发表于 2014-12-29 19:23:51 | 显示全部楼层
leshuijun 发表于 2014-12-29 16:46
亲可以在我百度云里面下载  http://pan.baidu.com/s/1jGqWDXc   希望可以帮到你

抱歉,没有找到与“pan.baidu.com/s/1jGqWD”相关的网页
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-12-30 14:05:01 | 显示全部楼层
测试程序写进去了没反应。请问下,对sim卡又什么要求?什么卡都行吗?我新办了张4G的卡,不知道行不行?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-2-25 11:34:59 | 显示全部楼层
leshuijun 发表于 2014-12-29 16:46
亲可以在我百度云里面下载  http://pan.baidu.com/s/1jGqWDXc   希望可以帮到你

  1. /* GSM Shield example

  2. created 2011
  3. by Boris Landoni

  4. This example code is in the public domain.


  5. http://www.open-electronics.org
  6. http://www.futurashop.it
  7. */

  8. #include <SoftwareSerial.h>
  9. #include <GSM_Shield.h>

  10. //**************************************************************************
  11. char number[]="+39123456789";  //Destination number
  12. char text[]="hello world";  //SMS to send
  13. byte type_sms=SMS_UNREAD;      //Type of SMS
  14. byte del_sms=0;                //0: No deleting sms - 1: Deleting SMS
  15. //**************************************************************************

  16. GSM gsm;
  17. char sms_rx[122]; //Received text SMS
  18. //int inByte=0;    //Number of byte received on serial port
  19. char number_incoming[20];
  20. int call;
  21. int error;


  22. void setup()
  23. {
  24.   Serial.begin(9600);
  25.   Serial.println("system startup");
  26.   gsm.TurnOn(9600);          //module power on
  27.   gsm.InitParam(PARAM_SET_1);//configure the module  
  28.   gsm.Echo(0);               //enable AT echo

  29. }


  30. void loop()
  31. {
  32.   char inSerial[5];   
  33.   int i=0;
  34.   delay(2000);
  35.   
  36.     Check_Call(); //Check if there is an incoming call
  37.     Check_SMS();  //Check if there is SMS
  38.     //Check data serial com
  39.    
  40.     if (Serial.available() > 0)
  41.     {            
  42.        while (Serial.available() > 0) {
  43.          inSerial[i]=(Serial.read()); //read data  
  44.          i++;      
  45.        }
  46.        inSerial[i]='\0';
  47.       Check_Protocol(inSerial);
  48.     }
  49.       
  50. }  

  51. void Check_Protocol(String inStr)
  52. {   
  53.        Serial.print("Command: ");
  54.        Serial.println(inStr);
  55.       
  56.   Serial.println("Check_Protocol");
  57.   
  58.     switch (inStr[0])
  59.       {
  60.        case 'a' :  //Answer        
  61.            if (gsm.CallStatus()==CALL_INCOM_VOICE){
  62.              gsm.PickUp();
  63.              Serial.println("Answer");
  64.            }
  65.            else
  66.            {
  67.              Serial.println("No incoming call");
  68.            }
  69.          break;
  70.       
  71.    
  72.        case 'c': // C  //Call
  73.          if (inStr.length()<2)  //To call variable 'number'    comand   c
  74.          {
  75.            Serial.print("Calling ");
  76.            Serial.println(number);         
  77.            gsm.Call(number);
  78.          }
  79.          if (inStr.length()==2)  //To call number in phone book position   comand   cx where x is the SIM position
  80.          {
  81.              error=gsm.GetPhoneNumber(inStr[1],number);
  82.              if (error!=0)
  83.              {
  84.                Serial.print("Calling ");
  85.                Serial.println(number);
  86.                gsm.Call(number);
  87.              }
  88.              else
  89.              {
  90.                Serial.print("No number in pos ");
  91.                Serial.println(inStr[1]);
  92.              }
  93.          }
  94.          break;
  95.          
  96.        case 'h': //H //HangUp if there is an incoming call
  97.          if (gsm.CallStatus()!=CALL_NONE)         
  98.          {
  99.            Serial.println("Hang");
  100.            gsm.HangUp();              
  101.          }
  102.          else
  103.          {
  104.            Serial.println("No incoming call");
  105.          }   
  106.          break;
  107.          
  108.          
  109.        case 's': //S //Send SMS
  110.          Serial.print("Send SMS to ");
  111.          Serial.println(number);
  112.          error=gsm.SendSMS(number,text);  
  113.          if (error==0)  //Check status
  114.          {
  115.              Serial.println("SMS ERROR \n");
  116.          }
  117.          else
  118.          {
  119.              Serial.println("SMS OK \n");            
  120.          }
  121.          break;
  122.               
  123.        case 'p':  //Read-Write Phone Book
  124.          if (inStr.length()==3)
  125.          {
  126.            
  127.            switch (inStr[1])
  128.            {
  129.              case 'd':  //Delete number in specified position  pd2
  130.                error=gsm.DelPhoneNumber(inStr[2]);
  131.                if (error!=0)
  132.                {
  133.                  Serial.print("Phone number position ");
  134.                  Serial.print(inStr[2]);
  135.                  Serial.println(" deleted");
  136.                }
  137.                break;
  138.                
  139.                
  140.                
  141.              case 'g':  //Read from Phone Book position      pg2
  142.                error=gsm.GetPhoneNumber(inStr[2],number);
  143.                if (error!=0)  //Find number in specified position
  144.                {
  145.                  Serial.print("Phone Book position ");
  146.                  Serial.print(inStr[2]);
  147.                  Serial.print(": ");
  148.                  Serial.println(number);
  149.                }
  150.                else  //Not find number in specified position
  151.                {
  152.                  Serial.print("No Phone number in position ");
  153.                  Serial.println(inStr[2]);
  154.                }
  155.                break;
  156.              case 'w':  //Write from Phone Book Position    pw2
  157.                error=gsm.WritePhoneNumber(inStr[2],number);
  158.                if (error!=0)
  159.                {
  160.                  Serial.print("Number ");
  161.                  Serial.print(number);
  162.                  Serial.print(" writed in Phone Book position ");
  163.                  Serial.println(inStr[2]);
  164.                }
  165.                else Serial.println("Writing error");
  166.                break;
  167.                
  168.                
  169.                
  170.            }
  171.            
  172.          }
  173.          break;
  174.          
  175.        }
  176.    
  177.     delay(1500);
  178.    
  179.     return;
  180. }


  181. void Check_Call()  //Check status call if this is available
  182. {     
  183.      call=gsm.CallStatus();
  184.      switch (call)
  185.      {   
  186.        case CALL_NONE:
  187.          Serial.println("no call");
  188.          break;
  189.        case CALL_INCOM_VOICE:
  190.          gsm.CallStatusWithAuth(number_incoming,0,0);        
  191.          Serial.print("incoming voice call from ");     
  192.          Serial.println(number_incoming);
  193.          break;
  194.        case CALL_ACTIVE_VOICE:
  195.          Serial.println("active voice call");   
  196.          break;
  197.        case CALL_NO_RESPONSE:
  198.          Serial.println("no response");
  199.          break;
  200.      }
  201.      return;
  202. }


  203. void Check_SMS()  //Check if there is an sms 'type_sms'
  204. {
  205.      char pos_sms_rx;  //Received SMS position     
  206.      pos_sms_rx=gsm.IsSMSPresent(type_sms);
  207.      if (pos_sms_rx!=0)
  208.      {
  209.        //Read text/number/position of sms
  210.        gsm.GetSMS(pos_sms_rx,number_incoming,sms_rx,120);
  211.        Serial.print("Received SMS from ");
  212.        Serial.print(number_incoming);
  213.        Serial.print("(sim position: ");
  214.        Serial.print(word(pos_sms_rx));
  215.        Serial.println(")");
  216.        Serial.println(sms_rx);
  217.        if (del_sms==1)  //If 'del_sms' is 1, i delete sms
  218.        {
  219.          error=gsm.DeleteSMS(pos_sms_rx);
  220.          if (error==1)Serial.println("SMS deleted");      
  221.          else Serial.println("SMS not deleted");
  222.        }
  223.      }
  224.      return;
  225. }






  226.   
复制代码
上面是范例程序,我没看明白,求大神加点注释,谢谢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-10 14:49 , Processed in 0.043114 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表