2017-02-23 3 views
3

J'ai mis un méga arduino et le bouclier GSM Arduino avec un FYVE (vodafone) - Sim ensemble. Long terme Je veux ajouter un GPS pour envoyer des données de position via le module GSM à data.sparkfun.com. Pour démarrer mon code, j'ai commencé avec l'exemple GsmWebClient d'arduino. Le problème est, que je reçois constamment le "HTTP/1.1 302 Trouvé - Erreur". Donc, apparemment, je suis redirigé. J'ai l'impression qu'il doit y avoir une solution assez facile, mais je n'arrive pas à la comprendre. Fondamentalement lu à travers l'Internet entier. Je ne sais vraiment pas ce qui se passe et je me sens plutôt stupide maintenant.Arduino GSM Shield WebClient 302

Si je change l'APN à web.vodafone.de GSM et GPRS se connecter, mais ne marche pas client.

vient ici le code et la réponse de la série:

// 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 (;;) 
     ; 
    } 
} 

Démarrage client Web Arduino.

connexion GSM

GSM connecté

gprs connexion

gprs connecté

connexion ...

connecté

HTTP/1.1 302 Found

Date: Thu, 23 février 2017 18:13:45 GMT

serveur: Apache

Connection: close

Lieu: https://web.vodafone.de/sbb/redirectToLandingPage?lyt=vodafone&SESSION_TARGET_URL=http%3A%2F%2Fwww.arduino.cc%2Fasciilogo.txt

Content-Length: 0

Variez: User-Agent

Cache-Control: no-transform

Type de contenu: texte/brut; charset = ISO-8859-1

déconnexion.

Eh bien, là vous l'avez. J'espère que quelqu'un peut m'aider ici, ce truc me rend fou.

Cordialement Arne

Répondre

1

Je viens de me sentir que Vodafone vérifie les en-têtes http-paquets et s'il y a quelque chose qu'ils pensent suspect, ils les rediriger. Peut-être pourriez-vous essayer d'ajouter des informations à http-header, comme user-agent?

// 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(); 
    } 

Example and info about http-headers

Discussion about Vodafone proxy detection and redirection

0

gars Eh bien, je résolu le miracle.Aussi stupide que cela puisse paraître: il n'y avait pas de tarif pour internet choisi sur la carte SIM. Je l'ai eu de mon superviseur et j'étais sûr qu'il était déjà activé. Ce n'était pas. Échoué calme dur sur celui-là.