After OTA update, how to redirect browser?

meisner
Posts: 5
Joined: Thu Jun 15, 2023 11:30 am

After OTA update, how to redirect browser?

Postby meisner » Thu Nov 09, 2023 5:32 pm

I am working with ESP-IDF 5.1.1, although that's probably not relevant.

Right now I have a project [1] that is providing a function to update the firmware via the web server. I know this is not secure and not recommended, but it is also not relevant to my question.

My question; once the firmware update is complete, an esp_restart() is issued to start the new version. Before this happens, I provide a web page that simply states the update was complete and the device will reboot. I want to display this, providing a 15 sec timeout and then redirect to the root of the http server. I have tried so many different ideas but cannot get anything working and I couldn't find an example online.

The first thing I tried was to add the following in the URI handler:

Code: Select all

httpd_resp_set_hdr(req, "Refresh", "content=\"15;url=/\"\r\n");
before calling:

Code: Select all

httpd_resp_sendstr(req, "Firmware update complete, rebooting now!\n");
But this claims:
[19670.15h.36m.01s.574] W (126643) httpd_uri: httpd_uri: Method '1' not allowed for URI '/update'
[19670.15h.36m.01s.574] W (126643) httpd_txrx: httpd_resp_send_err: 405 Method Not Allowed - Specified method is invalid for this resource
...which I get since I didn't add a uri handler method for POST for the root.

What I am trying to do is to reload the root web page after the firmware update and the reboot complete (roughly 10 - 12 seconds).

The module I am working within is app/src/web.cpp in my repo. Near line 277.

[1] https://github.com/smeisner/smart-thermostat

accacca
Posts: 34
Joined: Mon Aug 06, 2018 4:59 pm

Re: After OTA update, how to redirect browser?

Postby accacca » Thu Nov 09, 2023 6:11 pm

I would do the opposite using the OTA component.
Put the new firmware "anywhere" that can be reached by your ESP32.
To update press a button on your thermostat and activate automatic update ESP32 goes to "knock" where you put the new firmware download and update with the new firmware. You make the new version easily available to anyone using your product.
I don't remember the details (I'll review if needed) there is a way to check the firmware version as well.
You periodically send the request to the site where you maintain the firmware version if a new version is available you can alert that there is a new version available.

meisner
Posts: 5
Joined: Thu Jun 15, 2023 11:30 am

Re: After OTA update, how to redirect browser?

Postby meisner » Thu Nov 09, 2023 6:55 pm

accacca wrote:
Thu Nov 09, 2023 6:11 pm
I would do the opposite using the OTA component.
Put the new firmware "anywhere" that can be reached by your ESP32.
To update press a button on your thermostat and activate automatic update ESP32 goes to "knock" where you put the new firmware download and update with the new firmware. You make the new version easily available to anyone using your product.
I don't remember the details (I'll review if needed) there is a way to check the firmware version as well.
You periodically send the request to the site where you maintain the firmware version if a new version is available you can alert that there is a new version available.
That won't work for my use case. I need to upload firmware the way I've got it already set up. This is why I said right up front, I know this is not the recommended way of doing this.

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 174 guests