Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle preflight requests #1927

Closed

Conversation

WoHinDu
Copy link

@WoHinDu WoHinDu commented Feb 15, 2018

Currently, I'm writing a little web programme to make the batch updating from multiple tasmota devices easier.

My preferred method to update the devices is to send the firmware directly to the device via a POST request. That is basically the same what the original built-in updater is doing. The problem is that a browser sends before the actual POST request a so-called preflight request (an OPTIONS request). The browser asks the web server whether the request is allowed or not. Currently, the preflight requests are not handled by tasmota and therefore the response is an error 404.

This pull request implements the correct handling of preflight requests for the firmware update page.

@ascillato
Copy link
Contributor

Hi

There is already a Web based application for uploading firmware to several sonoff at the same time.

https://github.com/reloxx13/SonWEB

@WoHinDu
Copy link
Author

WoHinDu commented Feb 16, 2018

Hi,

I know SonWeb. That's great work. The problem is that the Tasmota devices need either direct access to the internet or you need to set up a web server on your local machine. My devices are not allowed to connect directly to the internet due to security concerns. Setting up a web server is not trivial and for a lot of people too much effort for just updating a few devices. Of course, that is not a problem of SonWeb but in general of the update mechanism.

In my opinion, the easiest way to send the firmware directly to the devices is to handle the preflight requests. That are just a few lines of code and I can't think of any problems.

@ascillato
Copy link
Contributor

Hi, I understand. So, just few lines on webserver.ino and https://github.com/WoHinDu/Tasmota-Firmware-Updater can be used, right?

That is a nice python solution. I can think that this approach is also very useful for an android app to update Tasmota Firmwares directly.

Like your approach as another update option. 👍

Hope to be included in Tasmota.

BTW, Installing SonWEB on windows is just unziping the provided ready to use SonWEB-XAMP-Portable-2018-01-20.zip on c:\XAMPP and run once setup_xampp.bat and then run xampp-control.exe
Then on a web browser just type localhost as address and you have it.

@ascillato
Copy link
Contributor

Hi @WoHinDu,

I have tested your code, works very good. Also I tested that did not interfere with SonWEB, neither with local web update.

So, hope that @arendst include this feature on Tasmota.

Thanks

@arendst
Copy link
Owner

arendst commented Feb 16, 2018

Will be in next pre-release

arendst added a commit that referenced this pull request Feb 16, 2018
5.12.0b
 * Add Webserver upload preflight request support (#1927)
 * Add
Home Assistant clear other device (#1931)
@WoHinDu
Copy link
Author

WoHinDu commented Feb 16, 2018

@ascillato @arendst Thanks a lot for reviewing this code so fast!

@arendst arendst closed this Feb 16, 2018
@reloxx13 reloxx13 mentioned this pull request Feb 23, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
5.12.0b
 * Add Webserver upload preflight request support (arendst#1927)
 * Add
Home Assistant clear other device (arendst#1931)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants