Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino GSM屏蔽网络客户端302_Arduino_Webclient_Gsm_Gprs - Fatal编程技术网

Arduino GSM屏蔽网络客户端302

Arduino GSM屏蔽网络客户端302,arduino,webclient,gsm,gprs,Arduino,Webclient,Gsm,Gprs,我把arduino mega和arduino GSM屏蔽与Fyve(沃达丰)Sim卡放在一起。长期而言,我想添加一个GPS,通过GSM模块将位置数据发送到data.sparkfun.com。为了让代码运行,我从arduino的GsmWebClient示例开始。 问题是,我经常得到“HTTP/1.1 302 Found-Error”。所以很明显我被重定向了。我觉得必须有一个非常简单的解决方案,但我想不出来。基本上阅读整个互联网。我真的不知道是怎么回事,现在觉得自己很愚蠢 如果我将APN更改为web

我把arduino mega和arduino GSM屏蔽与Fyve(沃达丰)Sim卡放在一起。长期而言,我想添加一个GPS,通过GSM模块将位置数据发送到data.sparkfun.com。为了让代码运行,我从arduino的GsmWebClient示例开始。 问题是,我经常得到“HTTP/1.1 302 Found-Error”。所以很明显我被重定向了。我觉得必须有一个非常简单的解决方案,但我想不出来。基本上阅读整个互联网。我真的不知道是怎么回事,现在觉得自己很愚蠢

如果我将APN更改为web.vodafone.de GSM和GPRS连接,但客户端没有

下面是序列号的代码和响应:

// libraries
#include <GSM.h>


// PIN Number
#define PINNUMBER "****"

// APN data
#define GPRS_APN       "event.vodafone.de" // replace your GPRS APN
#define GPRS_LOGIN     ""    // replace with your GPRS login
#define GPRS_PASSWORD  "" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;

// URL, path & port (for example: arduino.cc)
char server[] = "arduino.cc";
char path[] = "/asciilogo.txt";
int port = 80; // port 80 is the default for HTTP

void setup() {
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Starting Arduino web client.");
  // connection state
  boolean notConnected = true;

  // After starting the modem with GSM.begin()
  // attach the shield to the GPRS network with the APN, login and password
  while (notConnected) {
    Serial.println("connecting gsm");
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
          Serial.println("gsm connected");
          delay(1000);
          Serial.println("connecting gprs");
          if (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY) {
              Serial.println("gprs connected");
              notConnected = false;
        }
        else {
             Serial.println("gprs Not connected");
             delay(1000);
    }
      }
     else {
      Serial.println("gsm Not connected");
      delay(1000);
    }
  }

  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, port)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /asciilogo.txt HTTP/1.1");
    client.print("Host: ");
    client.println("www.arduino.cc");
    client.println("Connection: close");
    client.println();


  }
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.available() && !client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    for (;;)
      ;
  }
}
//库
#包括
//密码
#定义PINNUMBER“***”
//APN数据
#定义GPRS_APN“event.vodafone.de”//替换您的GPRS APN
#定义GPRS\u登录“”//替换为您的GPRS登录
#定义GPRS_密码“”//替换为您的GPRS密码
//初始化库实例
GSM客户;
GPRS;
GSM-gsmAccess;
//URL、路径和端口(例如:arduino.cc)
char服务器[]=“arduino.cc”;
字符路径[]=“/asciilogo.txt”;
int端口=80;//端口80是HTTP的默认端口
无效设置(){
//初始化串行通信并等待端口打开:
Serial.begin(9600);
而(!串行){
;//等待串行端口连接。仅本机USB端口需要
}
println(“启动Arduino web客户端”);
//连接状态
布尔notConnected=true;
//使用GSM.begin()启动调制解调器后
//使用APN、登录名和密码将屏蔽连接到GPRS网络
while(未连接){
Serial.println(“连接gsm”);
如果(gsmAccess.begin(PINNUMBER)=GSM\u READY){
串行打印LN(“gsm连接”);
延迟(1000);
Serial.println(“连接gprs”);
如果(gprs.attachGPRS(gprs\u APN、gprs\u登录、gprs\u密码)=gprs\u就绪){
Serial.println(“gprs连接”);
notConnected=false;
}
否则{
Serial.println(“gprs未连接”);
延迟(1000);
}
}
否则{
Serial.println(“gsm未连接”);
延迟(1000);
}
}
Serial.println(“连接…”);
//如果您获得连接,请通过串行方式报告:
if(客户端连接(服务器、端口)){
Serial.println(“已连接”);
//发出HTTP请求:
println(“GET/asciilogo.txt HTTP/1.1”);
client.print(“主机:”);
client.println(“www.arduino.cc”);
client.println(“连接:关闭”);
client.println();
}
}
void循环(){
//如果有可用的传入字节
//从服务器读取并打印它们:
if(client.available()){
char c=client.read();
连续打印(c);
}
//如果服务器已断开连接,请停止客户端:
如果(!client.available()&&!client.connected()){
Serial.println();
Serial.println(“断开”);
client.stop();
//永远不做任何事:
对于(;;)
;
}
}
正在启动Arduino web客户端

连接gsm

gsm连接

连接gprs

gprs连接

连接

连接的

找到HTTP/1.1 302

日期:2017年2月23日星期四18:13:45 GMT

服务器:Apache

连接:关闭

地点:

内容长度:0

更改:用户代理

缓存控制:无转换

内容类型:文本/纯文本;字符集=ISO-8859-1

断开

好了,给你。我希望有人能帮我,那东西快把我逼疯了


关于Arne

我感觉沃达丰会检查http数据包头,如果他们认为有可疑的东西,就会重定向它们。也许您可以尝试向http头添加信息,比如用户代理

    // if you get a connection, report back via serial:
    if (client.connect(server, port)) {
            Serial.println("connected");
            // Make a HTTP request:
            client.println("GET /asciilogo.txt HTTP/1.1");
            client.print("Host: ");
            client.println("www.arduino.cc");
            client.println("User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
            client.println("Connection: close");
            client.println();
    }


伙计们,我解决了这个奇迹。听起来很愚蠢:SIM卡上选择的互联网没有收费标准。我从我的主管那里得到了它,并且确信它已经启用了。事实并非如此。在那件事上失败了