OTA ESP32 web external

This was one of the first ones I evaluated but I declined when I was first asked for my credit card when registering. Then I remembered that years ago I got a test instance on AWS for free.

I even provided my credit card details at the time. After a while I received a charge and had problems to correct and almost did not use the instance.

Yesterday, when I came across this phase in the register, I gave up.

It is not possible to be hostage to a company. OK, my credit card isn't up to par, but I don't like the idea.

And OTA is just a GET request (as you know much more than me). It can't possibly be that complicated.

We type terms related to this on google and hundreds of information come up, none of which works.

Maybe ESP-IDF and MQTT works but what about the arduino IDE? Not able?

Thanks for trying to help. Any attempt is valid.

don't use AWS, modify it to hit your file..

change the host and bin to yours..

String host = "bucket-name.s3.ap-south-1.amazonaws.com"; // Host => bucket-name.s3.region.amazonaws.com
int port = 80; // Non https. For HTTPS 443. As of today, HTTPS doesn't work.
String bin = "/sketch-name.ino.bin"; // bin file name with a slash in front.

At the exact moment I read your message I was finishing installing a zerossl SSL certificate on my website account. Then it became htttps, I used another code and pasted her SSL certificate in it but it didn't even work.

Then I had to open another account to test this good idea of ​​yours. But this code you indicated separates the HOST from the .BIN

I made some attempts putting the separate .bin but not finding the .bin

Note that if you copy and paste the complete HOST into your browser it will download the updated.bin indicating that the URL is correct.

Then I returned my new account to that first code and became Guru Mediation again.

// S3 Bucket Config
String host = "http://atualiza.infinityfreeapp.com";
int port = 80;
String bin = "http://atualiza.infinityfreeapp.com/atualiza.bin";
//String bin = "/atualiza.bin";

how boring

ERROR

Connecting to SINAL_2Ghz
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 2 - STA_START
.....[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.18.25, MASK: 255.255.255.0, GW: 192.168.18.1

Connected to SINAL_2Ghz
Connecting to: http://atualiza.infinityfreeapp.com
Fetching Bin: /htdocs/atualiza.bin
Got a non 200 status code from server. Exiting OTA Update.
contentLength : 0, isValidContentType : 0
There was no content in the response
[E][WiFiClient.cpp:485] flush(): fail on fd 54, errno: 11, "No more processes"

In file manager inside the site I have to put the .bin file inside a folder called htdocs, but using the browser it is not necessary to have this htdocs in the URL, anyway I put it inside the code in the String. The error persists, with or without htdocs.

htdocs

Serial.Println(line); see what response you did get..
could just be dns issues with new accounts??
better than Core panic..

sorry.. ~q

not sure if it helps..
but i uploaded your bin to my website..

http://www.qubits.us/nards/atualiza.bin
// S3 Bucket Config
String host = "http://www.qubits.us";
int port = 80;
String bin = "/nards/atualiza.bin";
//String bin = "/atualiza.bin";

try, try again..
~q

I really appreciate your help. But see, same error:

Connected to SINAL_2Ghz
Connecting to: http://www.qubits.us
Fetching Bin: /nards/atualiza.bin
Got a non 200 status code from server. Exiting OTA Update.
contentLength : 0, isValidContentType : 0
There was no content in the response
[E][WiFiClient.cpp:485] flush(): fail on fd 54, errno: 11, "No more processes"

OPA. but now it worked in my other code that was giving GURU MEDITATION

UAAAAAAAAAAAAAAAAA, thanks to you I managed to make my first WEB OTA. Wow, my eyes filled with tears.

Congratulations!!! :sunglasses:

my eyes filled with tears.

See, one difference is that the two dates are correct, is that it ?

[V][HTTPClient.cpp:245] beginInternal(): url: http://www.qubits.us/nards/atualiza.bin
[D][HTTPClient.cpp:293] beginInternal(): protocol: http, host: www.qubits.us port: 80 url: /nards/atualiza.bin
[D][HTTPClient.cpp:579] sendRequest(): request type: 'GET' redirCount: 0

[D][HTTPClient.cpp:1125] connect():  connected to www.qubits.us:80
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'HTTP/1.1 200 OK'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Server: openresty/1.19.9.1'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Date: Sun, 02 Apr 2023 17:06:11 GMT'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Content-Type: application/octet-stream'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Content-Length: 198944'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Connection: keep-alive'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Last-Modified: Sun, 02 Apr 2023 16:34:36 GMT'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'ETag: "30920-5f85d04a155e8"'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'X-Webcom-Cache-Status: BYPASS'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: 'Accept-Ranges: bytes'
[V][HTTPClient.cpp:1216] handleHeaderResponse(): RX: ''
[D][HTTPClient.cpp:1257] handleHeaderResponse(): code: 200
[D][HTTPClient.cpp:1260] handleHeaderResponse(): size: 198944
[D][HTTPClient.cpp:603] sendRequest(): sendRequest code=200

[D][Updater.cpp:132] begin(): OTA Partition: app1
Updating firmware...
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Update Success, Total Size: 198944
Rebooting...
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 3 - STA_STOP
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 3 - STA_STOP
ets Jun  8 2016 00:22:57

possibly, grabbing an url directly, isn't that phishing?? figured it was something in the host..
idk, i'm hosted on network solutions, for like a long time, few decades..
glad you got it going..
i'm just starting..
first, i got to stuff the firmware into a blog field in the database server, then out from there..
sounds complicated, but i bet you i have less issues than you did..
lol, i wrote my server, a little easier to debug..

i'll leave it up for a few days..

have fun.. ~q

I still have a lot to learn, I'm going to research what phishing is.

Thank you very much. I'll dig deeper to see if I can find out why it didn't work on my site. But actually that server doesn't have anything of mine, it could be anyone, as long as it works.

If you even indicate one, I'll sign up and do tests.

I'm building this..

NARDS

Giving it all away..
Working good..

really, not plants per say, that's just an example..
waiting on some more graphics..

but still adding OTA and I also want to interface to cli and keep source files in the db server too..

want to make it easy to change a down mcu..

should be able to handle quite allot of connected mcu's..

fun stuff..

good luck with your project!!

~q

Nice. You will get it.

I downloaded here now the fileZilla because I saw that on that server my free account has FTP capability.

I just easily transferred file to that htdocs folder.

I'm going to research if it's possible (and easy) to OTA the ESP32 using FTP.

Good luck there.
Health and peace.

1 Like

Now I saw that the files are protected by a password, see the image below.

Then a doubt came to me: Would it be possible to put this password in the ESP32 code?

Or else, does anyone indicate any hostinger with a free account that is just HTTP and that does not place restrictions on access to files ?

It's hard. I opened an account now at 000webhost and sent the .bin and noticed that it also has a password for access permission. I think that's why I'm not able to access the .bin through the ESP32 code.

Now I will stop, tired.

There has to be somewhere on the internet, port 80, HTTP, where I can put a .BIN and do WEB OTA successfully.

On my free hostinger (infinityfree) I installed a zeroSSL certificate. And I started using the sample code from the HTTPS_OTA-UPDATE library.

I copied the certificate into the code and did the test of downloading the update.bin file

gave error

Searching on google I saw that 1 year and 9 months ago someone did the same thing, identical, and in the help comments they said that the SSL certificate should be in a certain format

The discussion, which is brief, is this:

I put it in the suggested format and the error remains the same.

My code (and the error) are exactly the same.

Does anyone have any ideas ? I now have HTTPS and a valid and correct certificate.

My code. The certificate just below is the example code, I left it there to remember how the format was before. I changed some characters in the certificate in use, just to make it useless here in this post.

#include "WiFi.h"
#include "HttpsOTAUpdate.h"

static const char *ssid     = "zzzzzzzzzzzzzz";
static const char *password = "zzzzzzzzzzzzz"; 

static const char *url = "https://frequencia.infinityfreeapp.com/atualiza.bin";

static const char *server_certificate = R"(
-----BEGIN CERTIFICATE-----
MIIGrDCCBJSgAwIBAgIRAMBKTY/KWsrcuis+Aznnr08wDQYrgtZIhvcNAQEMBQAw
SzELMAkGA1UEBhMCQVQxEDAOBgNVBAoTB1plcm9TU0wxKjAoBgNVBAMTIVplcm9T
U0wgUlNBIERvbWFpbiBTZWN1cmUgU2l0ZSBDQTAeFw0dfgA0MDEwMDAwMDBaFw0y
MzA2MzAyMzU5NTlaMCkxJzAlBgNVBAMT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194KplmkF3rpUvbHCCtjwUAdgB6MoxU2LcttiDqOOBSHumEFnAyE4VN
O9IrwTpXo1LrUgAAAYc+FwUEAAAEAwBHMEUCIGfm6KwqONN29VIcJdsLKJx6gPPZ
Rz+Y/zN8OAnQVWtRAiEAmwxm4oc5yZdYj+9fYoSDG5T8wJXZ3w7LIuQ5ZO3iPD0w
SwYDVR0RBEQwQoIeZnJlcXVlbmNpYS5pbmZpbml0eWZyZWVhcHAuY29tgiAqLmZy
ZXF1ZW5jaWEuaW5maW5pdHlmcmVlYXBwLmNvbTANBgkqhkiG9w0BAQwFAAOCAgEA
VW/drX59MiXIMzOV4bCWqHLi708qqd0+/Z7Nxk2n1/2VxmWwYWCp5cbQ3gTHwu4K
0dN4m7Oy9sD1+kHmACRLekusSBO2dA7WHjkT3wIINQTs3CC3k/l3eyxVztC1H96i
KR12pXWiSDrYDCME9QllLzujpPYRtYSPiLS4H0DICFOmhiFJ7CDotrj0vM/Wua4e
CoHHIcNiEZIzP47fD50ll55G7zEvvqvfEy6P1RwCugYGWjovD3Toh4PtChWaa+wx
fMDjXJVPYSOlwAX2AJTc1HzrSjYsyNVR0sb6LEI+tsP4XnOti9jR+CZMWWuN/vOS
XBEieX40aJ2bgjiOo76sk8b2wxm3eH7A/lC8OeXvw7koZNi9axHe+V7cgRLdBGjY
uI7QEoPC/g+29hG9xT3R6lKFrR+CqGVwggiAf+DL/t7+UgfMp8VokGufmMtr/tBQ
a3ObUkxW7RyHOOqSXPj8lET7sS5DjitErHk2sOHWek/W5TUZQp4zgAcAYl5f6avQ
7Gybvtfxc/Lyan6smkM0CrFiKCD/Wbasdmo6dbeBwMDWAf1CziqsBXaFfQEXzUHK
9KIPDjMuAxKYBjEHTlOT34ov+FbE70WI6fF0CQPI7WkXMPCxqpRu2d0+ahunJR1g
lfnkzl711QvpsGhu31Evauqml2v3KMZouxlbeRmOegc=
-----END CERTIFICATE-----
)";


/*
static const char *server_certificate = "-----BEGIN CERTIFICATE-----\n" \
     "MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/\n" \
     "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" \
     "DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow\n" \
     "SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT\n" \
     "GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC\n" \
     "AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF\n" \
     "q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8\n" \
     "SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0\n" \
     "Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA\n" \
     "a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj\n" \
     "/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T\n" \
     "AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG\n" \
     "CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv\n" \
     "bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k\n" \
     "c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw\n" \
     "VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC\n" \
     "ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz\n" \
     "MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu\n" \
     "Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF\n" \
     "AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo\n" \
     "uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/\n" \
     "wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu\n" \
     "X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG\n" \
     "PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6\n" \
     "KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==\n" \
     "-----END CERTIFICATE-----";
*/

static HttpsOTAStatus_t otastatus;

void HttpEvent(HttpEvent_t *event)
{
    switch(event->event_id) {
        case HTTP_EVENT_ERROR:
            Serial.println("Http Event Error");
            break;
        case HTTP_EVENT_ON_CONNECTED:
            Serial.println("Http Event On Connected");
            break;
        case HTTP_EVENT_HEADER_SENT:
            Serial.println("Http Event Header Sent");
            break;
        case HTTP_EVENT_ON_HEADER:
            Serial.printf("Http Event On Header, key=%s, value=%s\n", event->header_key, event->header_value);
            break;
        case HTTP_EVENT_ON_DATA:
            break;
        case HTTP_EVENT_ON_FINISH:
            Serial.println("Http Event On Finish");
            break;
        case HTTP_EVENT_DISCONNECTED:
            Serial.println("Http Event Disconnected");
            break;
    }
}

void setup(){

    Serial.begin(115200);
    Serial.print("Attempting to connect to SSID: ");
    WiFi.begin(ssid, password);

    // attempt to connect to Wifi network:
    while (WiFi.status() != WL_CONNECTED) {
        Serial.print(".");
        delay(1000);
    }

    Serial.print("Connected to ");
    Serial.println(ssid);
    
    HttpsOTA.onHttpEvent(HttpEvent);
    Serial.println("Starting OTA");
    HttpsOTA.begin(url, server_certificate); 

    Serial.println("Please Wait it takes some time ...");
}

void loop(){
    otastatus = HttpsOTA.status();
    if(otastatus == HTTPS_OTA_SUCCESS) { 
        Serial.println("Firmware written successfully. To reboot device, call API ESP.restart() or PUSH restart button on device");
    } else if(otastatus == HTTPS_OTA_FAIL) { 
        Serial.println("Firmware Upgrade Fail");
    }
    delay(1000);
}

That R right after const char server certificate. Is it right ?