【问题标题】:How to create a server with sim800l module?如何使用 sim800l 模块创建服务器?
【发布时间】:2017-10-19 18:15:30
【问题描述】:

我已经购买了 sim800l 模块并设法作为客户端连接到互联网,但现在我想知道是否可以使用此模块创建 GSM 服务器,我已经看到了示例,但使用了 arduino 库,是针对sim900模块的,但是我还没有找到一些AT命令可以达到同样的效果,我给你留了部分使用到现在的源代码。

  void iniciar(){
       comandoAT("AT","OK",3000); // Comprueba que el modulo SIM800L esta arrancado
       Serial.println("Conectando a la red...");
       delay(3000);
       while(!comandoAT("AT+CREG?","+CREG: 0,1",1000)); //Espera hasta estar conectado a la red movil
       Serial.println("Conectado a la red.");
       comandoAT("AT+CGATT=1", "OK", 1000); //Iniciamos la conexión GPRS
       comandoAT("AT+CSTT=\"internet.comcel.com.co\",\"comcel\",\"comcel\"", "OK", 3000); //Definimos el APN, usuario y clave a utilizar
       comandoAT("AT+CIICR", "OK", 3000); //Activamos el perfil de datos inalámbrico
       comandoAT("AT+CIFSR", "", 3000); //Obtenemos nuestra IP
  }

  void peticion(){
      char aux_str[50];
      char direccion[] = "GET /asciilogo.txt HTTP/1.1\r\nHost: arduino.cc\r\nConnection: close\r\n\r\n";
      if(comandoAT("AT+CREG?","+CREG: 0,1",1000)){ //Comprueba la conexion a la red
          comandoAT("AT+CIPSTART=\"TCP\",\"arduino.cc\",\"80\"","CONNECT OK",5000); //Inicia una conexión TCP
          // Envíamos datos a través del TCP
          sprintf(aux_str, "AT+CIPSEND=%d", strlen(direccion));
          if (comandoAT(aux_str,">",10000))
          {
            comandoAT(direccion, "OK", 10000);
          }
      }else{
          Serial.print("Reiniciando...");
          iniciar();
      }
  }

对不起英语。

【问题讨论】:

    标签: server arduino gsm


    【解决方案1】:

    sim800l 模块是一个网络接口,在本例中是一个 GSM/GPRS 网络。

    理论上,如果您将 Adrunio 设置为服务器,那么它可以使用任何接口来发送和接收来自客户端的消息,前提是您的网络提供商支持对该接口的 HTTP 请求。

    但是,许多移动网络提供商可能不允许传入的 HTTP 请求,即使他们在其网络中分配给您的调制解调器的内部 IP 地址与您从互联网可能会随着时间而变化,这很容易成为您的解决方案的问题。

    【讨论】:

      猜你喜欢
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 2018-05-31
      • 1970-01-01
      • 2012-03-30
      • 2015-02-05
      • 2016-11-16
      相关资源
      最近更新 更多