Arduino Ethercard ENC28J60 Posting data not working

810 Views Asked by At

I've been trying to post data to my Apache web server at home with no luck. I can see that the server receives the request in the log file but headers are all messed up and the server cannot process the request.

Arduino code used to send the data are as follows:

char website[] PROGMEM = "10.0.0.200";
ether.hisip[0] = 10;
ether.hisip[1] = 0;
ether.hisip[2] = 0;
ether.hisip[3] = 200;

byte sd = stash.create();
    stash.print("?Controller=");
    stash.println(String(Controller));
    stash.print("&Sensor=");
    stash.println(String(Door1SensorId));
    stash.save();

Stash::prepare(PSTR("POST http://$F/addDoorData.php HTTP/1.1" "\r\n"
                      "Host: $F" "\r\n"
                      "Content-Type: application/x-www-form-urlencoded"  "\r\n"
                       "Content-Length: $D" "\r\n"
                       "\r\n"
                       "$H"),
                 website, website, stash.size(), sd);
 
ether.tcpSend();

The result that I receive on the server looks as follows: POST http://\x95\x1f\x93\xcf\x93\xdf\x93\xeb\x01@\x91q\x05P\xe0)/0\xe0B\...." 400 572 "-" "-" request failed: error reading the headers.

If anyone can help it would be greatly appreciated.

0

There are 0 best solutions below