Arduino GSM Shield WebClient 302
我把arduino mega和Arduino GSM Shield与Fyve(vodafone) - Sim结合在一起。长期来说,我想添加一个GPS,通过GSM模块发送位置数据到data.sparkfun.com。为了让我的代码正常运行,我开始使用来自arduino的GsmWebClient示例。 问题是,我经常得到“HTTP/1.1 302 Found - Error”。所以显然我会重定向。有这样的感觉,必须有一个非常简单的解决方案,但我无法弄清楚。基本上通读整个互联网。我真的不知道现在是否正在发生,感觉非常愚蠢。Arduino GSM Shield WebClient 302
如果我将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 (;;)
;
}
}
开始Arduino的Web客户端。
连接GSM
GSM连接
连接GPRS
GPRS连接
连接...
连接
HTTP/1.1 302实测值
日期:周四,2017年2月23日十八时13分45秒GMT
服务器:Apache
连接:关闭
的Content-Length:0
不同点:用户代理
缓存控制: no-transform
Content-Type:text/plain; charset = ISO-8859-1
断开连接。
那么,你有它。我希望有人能帮助我,这东西让我疯狂。
问候阿恩
我只是有感情,沃达丰检查HTTP数据包报头,如果有,他们认为可疑的东西,它们会重定向他们。也许你可以尝试添加信息到http-header,像用户代理?
// 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卡上没有选择互联网的资费。我从我的主管那里得到了它,并且确定它已经启用了。事实并非如此。在那个上失败了。