ESP2866 problem with long http

Hi,
I’d like to use the ESP8266 to controle my Kodi Mediacenter but Kodi sends an error because the http address is broken.
Getting weatherinformations from
GET /data/2.5/weather?id="12345 HTTP/1.0\r\nHost: api.openweathermap.org\r\n\r\n
is no problem.

GET /jsonrpc?request={“jsonrpc”:“2.0”,“method”:“Player.Open”,“params”:{“item”:{“file”:“smb://CLOUDSERVER/Mediaserver/Musik/CDs/Daft Punk/Random Access Memories/13 Contact.mp3” } }, “id”: 1} HTTP/1.0\r\nHost: 192.168.0.20\r\n\r\n
dosen’t work. when i read the buffer after writing the command i get one of these outputs:

GET /jsonrpc?request={"jsonrpc":"2.0","method":"Player.Open","20


END OK

IPD,184:HTTP/1.1 200 OK
ontent-Length: 76
ontent-Type: application/json
ate: Thu, 27 Aug 2015 02:57:08 GMT
"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
K

K
nlink

_______________________________________________________________

GET /jsonrpc?request={"jsonrpc":"2.0","method":"Player.Open","20


RROR
nlink

_______________________________________________________________

GET /jsonrpc?request={"jsonrpc":"2.0","method":"Player.Open","20ies/13 Contact.mp3" } }, "id": 1} HTTP/1.0


RROR
nlink

Here is my code:

  String kodiIp = "192.168.0.20";
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += kodiIp;
  cmd += "\",80";
  Serial3.println(cmd);
  if(Serial3.find("Error")) return;
  cmd = "GET /jsonrpc?request={\"jsonrpc\":\"2.0\",\"method\":\"Player.Open\",\"params\":{\"item\":{\"file\":\"smb://CLOUDSERVER/Mediaserver/Musik/CDs/Daft Punk/Random Access Memories/13 Contact.mp3\" } }, \"id\": 1}";
  cmd += " HTTP/1.0\r\nHost: ";
  cmd += kodiIp;
  cmd += "\r\n\r\n";
  Serial3.print("AT+CIPSEND=");
  Serial3.println(cmd.length());
  if(Serial3.find(">")){
  }else{
    Serial3.println("AT+CIPCLOSE");
    return;
  }
  Serial3.print(cmd);

Has anybody an idea where to find the problem?

edit: hm… 76 bytes semes to be the maximum. every GET message gets cut down to 76 chars. same problem if i write it over serial in smaller parts.

I know next to nothing about wifi coding but I happened to be watching a video on this site and at about 1 min 58 seconds into the video the author discusses a point that may be your problem. - Scotty

thanks :slight_smile: that semes to be the problem… (arduinos serial buffer is to small)
but i can’t solve the problem like in the video.

cmd = "GET /part1/part2 HTTP/1.0\r\nHost: 192.168.0.20\r\n\r\n";
Serial3.print("AT+CIPSEND=");
Serial3.println(cmd.length());

if(Serial3.find(">")){
}else{
    Serial3.println("AT+CIPCLOSE");
    return;
}


cmd = "GET /part1/";
Serial3.print(cmd);
delay(2000);

cmd = "part2 HTTP/1.0\r\nHost: 192.168.0.20\r\n\r\n";
Serial3.print(cmd);

for example resets the esp8266.
if i empty the buffer doing
for(int i = 0; i<64; i++)if(charAvailable())Serial3.read();
it does, too.

cmd = "GET /part1/";
Serial3.print("AT+CIPSEND=");
Serial3.println(cmd.length());

if(Serial3.find(">")){
}else{
    Serial3.println("AT+CIPCLOSE");
    return;
}
Serial3.print(cmd);

cmd = "part2 HTTP/1.0\r\nHost: 192.168.0.20\r\n\r\n";
Serial3.print("AT+CIPSEND=");
Serial3.println(cmd.length());

if(Serial3.find(">")){
}else{
    Serial3.println("AT+CIPCLOSE");
    return;
}
Serial3.print(cmd);

dosen’t work as well

See what happens if u add this line to your code.

#define SERIAL_RX_BUFFER_SIZE 256
#define SERIAL_TX_BUFFER_SIZE 256

It should work if placed before or after calling any libraries, but be sure to test both options.

Alternatively you can edit the line in HardwareSerial.h

Edit: Just realized u are transmitting, but same applies, just change RX to TX.

ah, thanks! changing the define in hardwareserial.h helped to increase the buffer. now the whole command can be send at once :slight_smile:

when there are seperate buffers for tx and rx, why do i read the command written to tx from the rx buffer?

Initially I advised to only change only the RX buffer because when the ESP8266 communicates it sends a "large" message, so u need a bigger buffer to receive messages from the ESP8266.

But then I realized you were having trouble transmitting a large message, hence I added the change to the TX buffer as well.

understood that.
my question is why i read stuff from my rx buffer with serial.read() when i've write it to the tx buffer with serial.print()? thaught they are seperate