STM32F407 LWIP returning data to client
I previously posted here when I was having issues with my STM32F407 board that I have configured as a HTTP server.
https://community.st.com/t5/stm32-mcus-products/where-to-find-lwip-incoming-payload-data-for-webserver/m-p/640137
This is a follow-up post with more questions. The server is apparently working more or less the way it should. Wireshark shows the following data. The first 3 lines are when I connect to the server. The next 8 lines are when I click a button on my page. It appears that the button sequence all is working properly as the server ACks, client ACKs, and back and forth until the transaction is complete. The really strange thing is, the last 8 lines are repeated 9 more times before transmissions stop. Transmissions should stop after the first full handshaking sequence completes. Any idea why it repeats an additional 9 times?
Source Destination Protocol Length Info
172.16.1.115 172.16.1.125 TCP 66 65055 → 80 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM
172.16.1.125 172.16.1.115 TCP 60 80 → 65055 [SYN, ACK] Seq=0 Ack=1 Win=2144 Len=0 MSS=536
172.16.1.115 172.16.1.125 TCP 54 65055 → 80 [ACK] Seq=1 Ack=1 Win=65392 Len=0
172.16.1.115 172.16.1.125 HTTP 381 GET /button_request?data=test2%2Cbutton_2%2COFF HTTP/1.1
172.16.1.125 172.16.1.115 TCP 60 80 → 65055 [FIN, ACK] Seq=1 Ack=328 Win=1817 Len=0
172.16.1.115 172.16.1.125 TCP 54 65055 → 80 [ACK] Seq=328 Ack=2 Win=65392 Len=0
172.16.1.115 172.16.1.125 TCP 54 65055 → 80 [FIN, ACK] Seq=328 Ack=2 Win=65392 Len=0
172.16.1.125 172.16.1.115 TCP 60 80 → 65055 [ACK] Seq=2 Ack=329 Win=1816 Len=0
172.16.1.115 172.16.1.125 TCP 66 65056 → 80 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM
172.16.1.125 172.16.1.115 TCP 60 80 → 65056 [SYN, ACK] Seq=0 Ack=1 Win=2144 Len=0 MSS=536
172.16.1.115 172.16.1.125 TCP 54 65056 → 80 [ACK] Seq=1 Ack=1 Win=65392 Len=0
I am able to intercept the button messages, and turn on/off the corresponding LEDs on the board. This is done by copying the button ID to a global variable in http_parse_request function (in httpd.c). In my main.c module I read the button info from the global variable as part of the while(1) loop and control the LEDs.
What I can't figure out is how to return data to the client. I want to return text such as "LED is on" and display it on the web page. Also, prior to returning the data, I will check the actual GPIO pin level to confirm that the LED is actually on.
Where would I insert the message to return it to the client? From reading, I understand I need to issue a http_write() to enqueue the data. After that, the message should be automatically be sent to the client. At least that is the way I understand it. Or is that not correct? Do I somehow need to append my message to the incoming button message?
The http_parse_request function is 174 lines long and somewhat confusing. Running the debugger and setting a breakpoint at this line: "return http_find_file(hs, uri, is_09);", I see that uri conains my button click information.
I have very little knowledge of how LWIP works. And even less knowledge of how it works with STM32 parts. From what I have read, ST is no longer updating the LWIP stack that works with the STM32F4 parts. They are pushing the STM32F7 as the solution for LWIP. But reading a lot of posts and questions online, LWIP doesn't really work with the STM32F7 parts. For a very simple application, the F7 parts are overkill. I just want to turn a LED on and return a "LED is on" message to the client.
