-->
Page 1 of 1

TCP CLIENT : Server GET URL Problem

PostPosted: Thu Oct 08, 2015 5:17 pm
by LimeHaze
Hello,

I came across a problem when i try to send data using more than one "/" on my GET command url link.
I am sending serial data to the esp8266 via an Arduino.

EX:

Not working:
Code: Select allString GET = "GET  /~test/update.php?a=";


Working:
Code: Select allString GET = "GET /update?key=[MY_API_KEY]&field1="


Send data fonction:
Code: Select allvoid sendData(int d) {
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  delay(2000);
  if(Serial.find("Error")){
    return;
  }
  cmd = GET;
  cmd += String(d);
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  if(Serial.find(">")){
    Serial.print(cmd);
  }else{
    Serial.println("AT+CIPCLOSE");
  }
}


Anyone know how to fix this?

LimeHaze

Re: TCP CLIENT : Server GET URL Problem

PostPosted: Fri Oct 09, 2015 2:59 am
by Barnabybear
Hi, this part of a string below has 2 / and works ok . "POST /update HTTP/1.1\n".
Code: Select all void loop() {
    if (client.connect(server,80)) {  // connects to thingspeak & sends the value of (pir)
        String postStr = apiKey;
               postStr +="&field1=";
               postStr += String(pir);
               postStr += "\r\n\r\n";
         client.print("POST /update HTTP/1.1\n");
         client.print("Host: api.thingspeak.com\n");
         client.print("Connection: close\n");
         client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
         client.print("Content-Type: application/x-www-form-urlencoded\n");
         client.print("Content-Length: ");
         client.print(postStr.length());
         client.print("\n\n");
         client.print(postStr);
      }

I'm not sure that the "/" is the problem.
Can you post what it is your trying to do & with what exactly goes wrong.

Re: TCP CLIENT : Server GET URL Problem

PostPosted: Fri Oct 09, 2015 8:54 am
by martinayotte
LimeHaze wrote:Not working:
Code: Select allString GET = "GET  /~test/update.php?a=";



In the string above, there is an extra space, maybe it is the cause of the problem ...

Re: TCP CLIENT : Server GET URL Problem

PostPosted: Fri Oct 09, 2015 10:25 pm
by forlotto
Ahhh between GET and / indeed good eye wouldn't hurt to give it a run the one that works does not have the extra space as well very possible.