-->
Page 4 of 4

Re: ESP reliability and firmware update

PostPosted: Thu May 26, 2016 2:07 pm
by martinayotte
If it is the read() that choke, maybe you can do chunk read using this code :
Code: Select all    int size;
    while ((size = client.available()) > 0) {
      uint8_t* msg = (uint8_t*)malloc(size);
      size = client.read(msg, size);
      Serial.write(msg, size);
      free(msg);
    }

Re: ESP reliability and firmware update

PostPosted: Fri May 27, 2016 12:01 am
by mixxx2005
Can you shortly explain what this part of code do?
Specifically what malloc do?

P.S I am logging temperature successful for 8 h now ;)

Re: ESP reliability and firmware update

PostPosted: Fri May 27, 2016 7:03 am
by martinayotte
The above code simply print the whole response from the client, what ever the size of it, either few bytes or several kilobytes, by reading it chunk by chunk while it been received. The malloc() allocates temporary memory buffer to the size of the chunk and free it as soon it has been outputted to the Serial before processing next chunk.