Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant read stream returned by postURI #5

Open
fojackson opened this issue Feb 18, 2012 · 4 comments
Open

cant read stream returned by postURI #5

fojackson opened this issue Feb 18, 2012 · 4 comments

Comments

@fojackson
Copy link

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:

HTTPClient hclient(serverName,(uint8_t )uint8_serverIP);
f1=hclient.postURI(urlbuf, NULL, databuf, headers );
/

char cc;
while((cc = fgetc(f1)) != EOF)
{
Serial.print(cc);
}
*/
int retcode=hclient.getLastReturnCode();

@interactive-matter
Copy link
Owner

hmm , I will look into it

@fojackson
Copy link
Author

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
Copy link
Owner

hmm, that sounds like a memory leak. Are you sure that you have released all streams after using them?

@fojackson
Copy link
Author

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants