8 Replies Latest reply on Apr 8, 2015 11:02 AM by ouzenkov

    Dynamic content - Receiving data through POST

    gbrivet

      Hi There,

       

      I am having a bit of a problem which I am pretty sure is my fault :-)

       

      I am trying to implement FW upgrade in my application, much like the OTA application, but using standard HTTP server. I am trying to send data chunk via POST method.

      I eventually end up in my dynamic content handler. The wiced_http_message_body_t * http_data shows:

      ttp_data->message_data_length = 0x00000000

      http_data->total_message_data_remaining = 0x00000400

      http_data->chunked_transfer = 0x00000000

       

      I then  simply allocate a buffer of size equal to http_data->total_message_data_remaining, read data by doing:

      if (wiced_tcp_stream_read(stream, pBuf, http_data->total_message_data_remaining, 2000) != WICED_SUCCESS) {

           printf("wiced_tcp_stream_read() failed\n");

      }


      free the buffer and returns.

       

      Client get the OK and sends second data chunk but my device is actually stuck after returning from my handler and this until watchdog resets.

       

      I am pretty sure that I am not doing something right, or probably forgetting to do something. Is wiced_tcp_stream_read() the correct way to get data from a POST ? Is there anything else I need to do after calling wiced_tcp_stream_read() ? I have tried to look at the OTA server sources but it is much different and did not find what I was looking for.

       

      Oh, and yes I am not HTTP protocol expert ;-)

       

      Thanks much.