2024-03-19 02:42 AM
Hi,
Im currently trying to set up a project where Freertos controls a webserver via lwip.
I tried following these tutorials/guides and managed to be able to ping the board but not get it to host the webserver.
https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master
Both of these are not for the STM32F429ZITx board So I copied what I thought I needed.
Right now I have it set up like this:
for the code:
The default task calls http_server_netconn_init that cretes a thread. Then this thread is the same as in this tutorial:
https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master
I also coppied the exact same files over for the fsdata.
Im connected via a static ip and when I type the IP in the browser or any link to a page it refuses the connection. I also used Advanced IP scanner to check If it was hosting something, but there was nothing.
Does anyone know what I could have forgotten or doing wrong?
Kind Regards,
William
Solved! Go to Solution.
2024-03-27 01:38 AM - edited 2024-03-27 02:58 AM
So I got it to work, here are my findings for anyone who has the same problem.
- You don't need to activate HTTPD in your ioc file for this to work.
- On this github page: https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master
There are two ways: just a static page with fsdate or dynamicly generate the page.
Staticly I didn't get it to work but its probably possible, dynamicly however works fine.
- It possible that you can't transfer the entire website in one netconn write, I have done it with multiple netconn writes.
There are probably better ways of doing it. But this works.
static const char head[] =
"<!DOCTYPE html>"
"<html lang=\"en\">"
"<head>"
"<meta charset=\"UTF-8\">"
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
//"<meta http-equiv=\"refresh\" content=\"5\">"
"<title>IRIS</title>";
//rest of page ...
netconn_write(conn, head, strlen((char*)head), NETCONN_COPY);
//netconn_writes for rest of page
2024-03-19 06:51 AM
Ask the author of that github project to kindly help?
Instrument the http server code with debug prints to understand why it refuses connection?
2024-03-19 07:06 AM
@WilliamVR wrote:it refuses the connection.
What do you mean, "refuses" ?
Do you get an HTTP 4xx failure status?
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors
2024-03-19 07:28 AM
I'll if I can get in touch.
Thats what im currently trying. But im new to freertos so its not exactly printing eveything just yet :).
2024-03-19 07:34 AM
Well Chrome is being a bit vague, I get this:
so there is probably an error somewhere with the TCP transmission.
2024-03-19 07:38 AM
I think ERR_CONNECTION_REFUSED is probably at the TCP layer - so it's not even getting to your webserver?
2024-03-19 07:44 AM
Yes,
Its in Dutch but I translated:
this is with me trying:
I have aslo tried just the IP adres or the 404 from the github code.
I can ping my controller tho, so it doesn't crash.
2024-03-19 08:00 AM
Ping is UDP - so could well get through when TCP is refused ...
2024-03-27 01:38 AM - edited 2024-03-27 02:58 AM
So I got it to work, here are my findings for anyone who has the same problem.
- You don't need to activate HTTPD in your ioc file for this to work.
- On this github page: https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master
There are two ways: just a static page with fsdate or dynamicly generate the page.
Staticly I didn't get it to work but its probably possible, dynamicly however works fine.
- It possible that you can't transfer the entire website in one netconn write, I have done it with multiple netconn writes.
There are probably better ways of doing it. But this works.
static const char head[] =
"<!DOCTYPE html>"
"<html lang=\"en\">"
"<head>"
"<meta charset=\"UTF-8\">"
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
//"<meta http-equiv=\"refresh\" content=\"5\">"
"<title>IRIS</title>";
//rest of page ...
netconn_write(conn, head, strlen((char*)head), NETCONN_COPY);
//netconn_writes for rest of page
2024-03-27 02:55 AM
Thanks for updating.
@WilliamVR wrote:But this works.
You screenshot has cut off some of the code!
Please don't post code as screenshots - use this button: