Hi,
I have a txt file on the SD card from my arduino.
And I need to send that file through my WIFI module ... (wiflyHQ library).
What better way to send?
I try POST method ... but my response is null..
// INIT :
if (wifly.open(host, 80)) {
Serial.print(F("Connected to "));
Serial.println(host);
/* Send the request */
String httpPostCommand = "POST " + (String)url + " HTTP/1.1"; // try with 1.1 so we can skip Content-Length header
wifly.println(httpPostCommand);
wifly.print("Host: ");
wifly.println(host);
wifly.println("Content-Type: multipart/form-data, boundary=xxxBOUNDARYxxx");
wifly.print("Content-Length: ");
wifly.println(readingsFileSize + 81);
wifly.println();
wifly.println("--xxxBOUNDARYxxx");
wifly.println("content-disposition: form-data; name=\"data\"");
wifly.println();
int ch;
while ((ch = readingsFile.read()) != -1)
{
wifly.print((char)ch);
Serial.print((char)ch);
}
wifly.println("--xxxBOUNDARYxxx");
Serial.println("--xxxBOUNDARYxxx");
wifly.println();
Serial.println();
int dataIndex = 0;
char postRespBuffer[256];
while (wifly.available() > -1)
{
postRespBuffer[0]='\0';
int readedBytes = wifly.gets(postRespBuffer, sizeof(postRespBuffer) - 1,2500);
postRespBuffer[readedBytes] = '\0';
Serial.write(postRespBuffer); // @todo only for debug
// verify POST request OK: HTTP/1.***200***OK
if ((strstr(postRespBuffer, "HTTP/1") != NULL) && (strstr(postRespBuffer, "200") != NULL)){
Serial.print("Post Response OK");
return true;
// @todo read POST response OK --> VERIFY..
}
else if(postRespBuffer==""){
Serial.print(F("Post Response is NULL"));
}
else{
Serial.print(F("Invalid response from server at POST: "));
Serial.println(postRespBuffer);
return false;
}
}
this:
POST /readings.axd HTTP/1.1
Host: 192.168.28.100
Content-Type: multipart/form-data, boundary=xxxBOUNDARYxxx
Content-Length: 236
--xxxBOUNDARYxxx
content-disposition: form-data; name="data"
2013_06_12 11:49 2700CFDAD0 0
2013_06_12 11:52 0F00088CD2 1
2013_06_12 11:52 0F000C9C0E 2
2013_06_12 11:52 0F000C9C0E 3
2013_06_12 12:00 0F00088CD2 1
--xxxBOUNDARYxxx
works in windows cmd... with telnet.. but not work in arduino.. why ? sugestions...