You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if I uncomment the section that reads the servers response, it crashes the Arduino Mega 2560. I'd really like to be able to read the page returned by the server.
my code:
I call the subroutine below with a line like this:
postmsg("reason=1", "/Machine/ToggleStoppedReason"); //1st parameter is form data, 2nd is path on server
Activity
interactive-matter commentedon Feb 19, 2012
hmm , I will look into it
fojackson commentedon Feb 20, 2012
oops, if forgot to mention that it will work for a very limited number of pages (3 to 6 or so) then the Arduino appears to reset.
interactive-matter commentedon Feb 20, 2012
hmm, that sounds like a memory leak. Are you sure that you have released all streams after using them?
fojackson commentedon Feb 21, 2012
Yes, see the code below:
I call the subroutine below with a line like this:
postmsg("reason=1", "/Machine/ToggleStoppedReason"); //1st parameter is form data, 2nd is path on server
void postmsg(char * message, char * path)
{
FILE *f1;
String tsData="deviceId=";
tsData+=macID;
tsData+="&";
tsData+=message;
tsData.toCharArray(databuf,sizeof(databuf));
http_client_parameter headers[] = {
{ "Content-Type","application/x-www-form-urlencoded" }
,{ NULL,NULL }
};
HTTPClient hclient(serverName,(uint8_t )uint8_serverIP);
//hclient.debug(-1);
f1=hclient.postURI(path, NULL, databuf, headers );
/(note: this line begins a commented section, the section I can't get to work)
char cc;
while((cc = fgetc(f1)) != EOF)
{
Serial.print(cc);
}
*/
int retcode=hclient.getLastReturnCode();
hclient.closeStream(f1);
}