2024-12-17 02:55 AM - last edited on 2024-12-17 03:11 AM by Andrew Neil
Hello there, I'm writing a STM32 update firmware function (using lwIP ) that accepts a HTTP Post Request to send a new .bin file.
After selecting a .bin file to transfer from the PC to the MCU. I use the following line to capture the request:
netbuf_data(inbuf, (void**) &buf, &buflen);
Here is the buf content:
POST /index.html HTTP/1.1
Host: 192.168.2.158
Connection: keep-alive
Content-Length: 176815
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryGhYpLxBOxGv1PE1D
Accept: */*
Origin: http://192.168.2.158
Referer: http://192.168.2.158/index.html
Accept-Encoding: gzip, deflate
Accept-Language: vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,zh-TW;q=0.4,zh;q=0.3
You can see Content-Length is 176815 while buflen gets a value of 614.
I have some questions and would appreciate any suggestions from you:
1. Please help me point out any mistakes, if there are any.
2. Why is there a difference between Content-Length and buflen?
3. How can I receive the content of a .bin file to store it in flash? Any examples or suggestions would be greatly appreciated. Many thanks.