HTTP Server - Progress bar on front end

BlackSmith40
Posts: 6
Joined: Wed Jan 25, 2023 6:19 am

HTTP Server - Progress bar on front end

Postby BlackSmith40 » Thu Aug 10, 2023 5:04 am

I've established FW OTA update over ESP32 AP. I'm sending image in a single request with segmented packets(This is way faster than sending multiple requests). However, this forces me to continuously receive data in handler with 'http_req_recv'. This prevents me to take care of other http requests during ota update. My problem is I also want to report number of bytes esp32 received continuously such that I can update my progress bar on web page. I've tried to send periodic get requests but as I said, esp idf http server is busy with receiving ota image, it responds all those request right after ota image is completely received.

Another alternative is keeping track of number of bytes sent(client side implementation). I'm using fetch api and if possible this also works for me but I couldn't find reliable source for this.

I'm using IDF 5.0.1

username
Posts: 534
Joined: Thu May 03, 2018 1:18 pm

Re: HTTP Server - Progress bar on front end

Postby username » Mon Aug 14, 2023 11:50 am

The OTA i created for myself also uses a web page with a progress bar.
What i did was have the webpage itself show the progress by what it has sent so far, and not have it updated by the ESP32.

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: HTTP Server - Progress bar on front end

Postby boarchuz » Mon Aug 14, 2023 1:37 pm

Unfortunately the ESP32 httpd is not designed for multiple concurrent requests. I was surprised by how much difficulty I had trying to find an embedded C HTTP server that is!

I ultimately gave up and now simply start *two* HTTP servers on the ESP32 for this purpose. When a firmware upload is sent to the 'main' server (eg. "http://192.168.0.1/ota_upload"), it redirects the request to the 'upload' server (eg. "http://192.168.0.1:8080/ota_upload"). While this is an ugly workaround, it's quick and easy, and completely invisible to the average user so it's a neat solution from that perspective.

There's also this: https://github.com/espressif/esp-idf/pull/11190. It wasn't compatible with this use-case when I last looked into it but I can't recall why or how.

BlackSmith40
Posts: 6
Joined: Wed Jan 25, 2023 6:19 am

Re: HTTP Server - Progress bar on front end

Postby BlackSmith40 » Fri Nov 24, 2023 6:16 pm

username wrote:
Mon Aug 14, 2023 11:50 am
The OTA i created for myself also uses a web page with a progress bar.
What i did was have the webpage itself show the progress by what it has sent so far, and not have it updated by the ESP32.
How do you keep track of number of bytes sent? If I can get it, I can divide it to total file size, get ratio and update my progress bar accordingly.

Who is online

Users browsing this forum: No registered users and 100 guests