400 Bad Request on CIPSEND long string
Posted: Thu Oct 01, 2015 3:30 pm
Hi guys,
I created a homepage that receiving data from Arduino but when i send long strings, the method that send the message fail.
The library used is
https://github.com/itead/ITEADLIB_Arduino_WeeESP8266
Code:
The string:
/Arduino/Setup?SetupData={$Identificacao$:$A109Z$,$DataInstalacao$:$01/01/2015$,$Modelo$:$Arduino Uno$}
Is working fine...i change the character "$" to double quotes on website and the data are successfully saved on database.
The Log:
When i use a small string like this:
It works.
Thanks by help
I created a homepage that receiving data from Arduino but when i send long strings, the method that send the message fail.
The library used is
https://github.com/itead/ITEADLIB_Arduino_WeeESP8266
Code:
Code: Select all
#include <SoftwareSerial.h>
#include "ESP8266.h"
SoftwareSerial serialESP(2,3);
ESP8266 wifi(serialESP);
#define SSID [ssid]
#define PASSWORD [password]
#define HOST_NAME "rafaelr-001-site1.mywindowshosting.com"
#define HOST_PORT (80)
void setup() {
Serial.begin(9600);
serialESP.begin(9600);
Serial.println(F("#########################################"));
Serial.println(F("Setup initialized..."));
Serial.println(F("Client mode initialized..."));
if(wifi.setOprToStation())
{
Serial.println(F(" Client mode OK!"));
delay(5000);
}else
{
Serial.println(F(" Client mode ERROR!"));
}
Serial.println(F("Network connection initialized..."));
if(wifi.joinAP(SSID, PASSWORD))
{
Serial.println(F(" Wifi connection OK!"));
delay(5000);
}else
{
Serial.println(F(" Wifi connection ERROR!"));
}
Serial.println(F("Resetting the module..."));
if(wifi.restart())
{
Serial.println(F(" Reset OK!"));
delay(5000);
}else
{
Serial.println(F(" Reset ERROR!"));
}
Serial.println(F("Single connection initialized..."));
if(wifi.disableMUX())
{
Serial.println(F(" Single connection OK!!"));
delay(5000);
}else
{
Serial.println(F(" Single connection ERROR!"));
}
Serial.println(F("End of Setup!"));
Serial.println(F("#########################################\r\n\r\n"));
}
void loop() {
sendData();
while(1);
}
/*
* Nome: enviaDados
* Descrição: Envia dados dos sensores para o Host.
*/
void sendData()
{
Serial.println(F("Http message initialized..."));
if(wifi.createTCP(HOST_NAME, HOST_PORT))
{
Serial.println(F(" Connected to Host!"));
delay(5000);
char *msg = "GET /Arduino/Setup?SetupData={$Identificacao$:$A109Z$,$DataInstalacao$:$01/01/2015$,$Modelo$:$Arduino Uno$}HTTP/1.1\r\nHost: rafaelr-001-site1.mywindowshosting.com\r\n\r\n";
uint8_t buffer[256] = {0};
wifi.send((const uint8_t*)msg, strlen(msg));
uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
if (len > 0)
{
Serial.print("Received:[");
for(uint32_t i = 0; i < len; i++) {
Serial.print((char)buffer[i]);
}
Serial.print("]\r\n");
}
delay(5000);
Serial.println(F("Close connection to Host initialized..."));
if (wifi.releaseTCP())
{
Serial.println(F(" Disconnected!"));
delay(5000);
}else
{
Serial.println(F(" Error Disconnect!"));
delay(5000);
}
}else
{
Serial.println(F(" ERROR Connection with the Host!"));
}
}
The string:
/Arduino/Setup?SetupData={$Identificacao$:$A109Z$,$DataInstalacao$:$01/01/2015$,$Modelo$:$Arduino Uno$}
Is working fine...i change the character "$" to double quotes on website and the data are successfully saved on database.
The Log:
#########################################
Setup initialized...
Client mode initialized...
Client mode OK!
Network connection initialized...
Wifi connection OK!
Resetting the module...
Reset OK!
Single connection initialized...
Single connection OK!!
End of Setup!
#########################################
Http message initialized...
Connected to Host!
Received:[HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 01 Oct 2015 20:17:42 GMT
Connection: close
Content-Length: 311
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/]
Close connection to Host initialized...
Error Disconnect!
When i use a small string like this:
"GET /Home/RecebeDados?entrada=Arduino3 HTTP/1.1\r\nHost: rafaelr-001-site1.mywindowshosting.com\r\n\r\n";
It works.
Thanks by help