How to use OTA without HTTP server or Web Application
Some time ago I struggled over the unstable OTA with LN882H when using Firefox browser.
If you are interested in the whole story, you can read most of it following this post:
https://www.elektroda.com/rtvforum/topic4028087-240.html#21312889
It turned out, there was an issue with the SDKs OTA code and, since OBK uses the OTA code slightly differently, the buffer could be filled with more data than the code expected. And accessing memory outside the allocated space is usually no good idea
It took me several days to find the culprit and so I spent quite some time looking to the OTA code.
Since I also made basic tests to verify the operation, I learned it's "only" sending an HTTP POST request to the according page of the device.
And this led to the question, if you always need the (very useful) Web App, "only" to do an update?
O.k, you may ask, why not? I often use a single connection to the device with no internet, so in order to use the App, you need to "host" it locally (e.g. with a docker installation).
Since newer Browsers all support "fetch()", I could do a simple addition to the OTA page to upload the firmware.
It's not so comfortable like using drag and drop in the App, there is no check for the file provided - but in the end it provides a very simple solution.
For now I could only test on the devices I own: LN882H, BK7231N, ESP32 and W800 (I added OTA for W800 while at it
.
Test for other platforms would be great.
The actual pull request is here:
https://github.com/openshwprojects/OpenBK7231T_App/pull/1471
Seeing it in action on a W800
PS: Since W800 code seems to have a simmilar problem like the LN882H code which needed some changes, I'm quite sure, this will be also an issue with W600. But since I don't own one, I didn't made changes here.
Maybe in a seperate PR
If you are interested in the whole story, you can read most of it following this post:
https://www.elektroda.com/rtvforum/topic4028087-240.html#21312889
It turned out, there was an issue with the SDKs OTA code and, since OBK uses the OTA code slightly differently, the buffer could be filled with more data than the code expected. And accessing memory outside the allocated space is usually no good idea

It took me several days to find the culprit and so I spent quite some time looking to the OTA code.
Since I also made basic tests to verify the operation, I learned it's "only" sending an HTTP POST request to the according page of the device.
And this led to the question, if you always need the (very useful) Web App, "only" to do an update?
O.k, you may ask, why not? I often use a single connection to the device with no internet, so in order to use the App, you need to "host" it locally (e.g. with a docker installation).
Since newer Browsers all support "fetch()", I could do a simple addition to the OTA page to upload the firmware.
<p>Upload firmware file for OTA - !!!Be aware, no file check is done!!!<p>
<input id='otafile' type='file'> <input type='button' class='bred' onclick='doota();' value='DO OTA - No file check - reboot after OTA'>
<script>
function doota(){
var input = document.getElementById('otafile');
if (input.files[0]){
fetch('/api/ota', {
method: 'POST',
body: input.files[0]}
).then((resp) => {
if(resp.ok){
console.log('ota successfull; rebooting');
fetch('/index?restart=1');
}
else console.log('ota not successfull');
}
}
else alert('no file selected')
}
</script>
It's not so comfortable like using drag and drop in the App, there is no check for the file provided - but in the end it provides a very simple solution.
For now I could only test on the devices I own: LN882H, BK7231N, ESP32 and W800 (I added OTA for W800 while at it

Test for other platforms would be great.
The actual pull request is here:
https://github.com/openshwprojects/OpenBK7231T_App/pull/1471
Seeing it in action on a W800
PS: Since W800 code seems to have a simmilar problem like the LN882H code which needed some changes, I'm quite sure, this will be also an issue with W600. But since I don't own one, I didn't made changes here.
Maybe in a seperate PR
Comments
Add a commentOh nice work. Hopefully I can play with it on other platforms before going away for Christmas. I'm guessing XR809 is excluded from the above? The build doesn't generate the ota file to test anyway.... [Read more]
I can check the code, but it will be a theoretical look, for I can't test. Maybe the buffer problem again? [Read more]
oh no pressure, no one has XR809 it seems. Was just curious. :) Added after 39 [minutes]: W600 https://obrazki.elektroda.pl/1033411900_1734677973_thumb.jpg Added after 10 [minutes]: ... [Read more]
Very nice, but we need a simple filename check like: <script> function doota() { var input = document.getElementById('otafile'); if (input.files[0]) { var filename = input.files[0].name; ... [Read more]
Generally though, I did recently wonder about a small note in the web app OTA tab about OTA not being for XR809 and now TR6260. And now that would apply to this new feature. Added after 11 [minutes]:... [Read more]
This new "alternate OTA" message could be improved. Maybe something like "developer OTA - use Web App [LINK] instead if possible". [Read more]
Back to main testing. There's a problem with BK-T OTA https://obrazki.elektroda.pl/5046196200_1734683635_thumb.jpg Flashed back to Tuya factory from 0x11000-200000 after that and started again.... [Read more]
Sure, there is much room for improvement ;-) First thing will be a simple accept=".<OTA extension>" based on the platform. Regarding N/T discussion @pkaczmarek2 : Do you recall any reason for... [Read more]
(also I can redo other platforms with log view if wanted) [Read more]
Maybe my testing super hero @divadiow could test if the artifacts whith the "tuned" header work as OTA for Beken N and T as expected? [Read more]
@max4elektroda It's Beken leftover, we can change it if it helps @divadiow https://obrazki.elektroda.pl/6386424600_1734684523_bigthumb.jpg https://obrazki.elektroda.pl/6451114600_1734684584_bigthumb.jpg... [Read more]
yes did you just need to wait longer and first attempt would have flashed OK? oh! interesting. I could try with another T real device I guess, I only have one T module loose. Or maybe I blow... [Read more]
on the first attempt I clicked the button like 5 times so I expect that something has messed up in OTA partition, maybe concurrent HTTP POSTs (or what is used there) wrote file parts in random order etc... [Read more]
O.k. I see, first thing to do is some kind of feedback. You don't even see the most obvoius things sometimes ;-) [Read more]
I'd just.... hide/disable those OTA fields when OTA is active. There is no possibly scenario when they are needed when OTA is already running. So... 1. when sending your OTA, refresh whole page 2.... [Read more]
Thanks for your suggestions, I'll try later. In the meantime I wrote a simple function to check rbl updates, here for N version, if we can agree on setting product in rbl-header (just as a complete page... [Read more]
bitbang erased and reflashed a Tuya T factory. Now OTAs fine, so false alarm. https://obrazki.elektroda.pl/7134542100_1734703067_thumb.jpg That app partition error is interesting, I've never... [Read more]
Nope, this was just to alter the variables in the rbl header of Beken N/T devices. This way it's easy to distinguish between the images. Thanks for testing, looks like this doesn't break the images,... [Read more]
After thinking about this again, I would like to discuss this "request". My arguments: 1. OBK devices are "single user devices" - you will usually not see multiple users access one device. 2. OTA... [Read more]