cancel
Showing results for 
Search instead for 
Did you mean: 

When receive Post in httpd_post_begin, how to return embedeed variables without FileSystem ?

Yfour.1
Associate II

Hello everybody !

I am working on a project with a STM32F746ZET.

The embedeed system measures temperatures, currents, voltages, save it on EEPROM, and send Altert with Ethernet/Can when there is a problem.

Now we would like to add the possibility to check currents, voltages, temperatures from a server sending POST requests(client's servor send only POST, no GET).

That's why I have activated LWIP_HTTPD and LWIP_HTTPD_SUPPORT_POST.

With httpd_post_begin, httpd_post_receive_data and httpd_post_finished I receive http requests, I can detect what information cleint's servor ask, but I don't know how to return the values they asked.

I know how to send custom file because in an other project I had to do it. I had write few html files that I had to send back (404.html, servor1.html, servor2.htm adn servor3.html), then I generated the fsdata_custom.c. After that I had to call snprintf(response_uri, response_uri_len, "/servor1.html") to send back the first html webpage for example.

But in the new project, I have to send variables (currents, voltages...) so I can't use this solution.

I have read the solution to use LWIP_HTTPD_CUSTOM_FILES, but the embedded card has no SD CARD so I can't use a file.

Do you know how to send back my own response without using a file ?

I tried to write the html format directly on the snprintf but doesn't work, it's not so simple :

snprintf(response_uri, response_uri_len, "<html><body><p>Test 57</p><ul></ul></p></body></html>")

Thanks a lot if you have already done it or have any informations.

Have a good day and thanks again for the time you spent to read my problem.

Sincerly,

Y.Fourel

1 REPLY 1
Yfour.1
Associate II

Hi,

If someone has the same problem, the only solution I have found is to re_write hs->file and hs->left in http_post_rxpbuf after http_handle_post_finished called. I think it's not the best solution (it should be to be able to modify text directly in http_handle_post_finished ) but it does the job.

Thanks,

Sincerly,

YFOUREL