Skip to content

cant read stream returned by postURI  #5

Open

Description

@fojackson

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

Activity

  1. interactive-matter commented on Feb 19, 2012

    @interactive-matter
    Owner

    hmm , I will look into it

  2. fojackson commented on Feb 20, 2012

    @fojackson
    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.

  3. interactive-matter commented on Feb 20, 2012

    @interactive-matter
    Owner

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

  4. fojackson commented on Feb 21, 2012

    @fojackson
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions