我把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
斷開連接。
那麼,你有它。我希望有人能幫助我,這東西讓我瘋狂。
問候阿恩