SSLClient icon indicating copy to clipboard operation
SSLClient copied to clipboard

OTA integration

Open woodlist opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. I did a try to use the SSLClient with OTA instrument, available here: https://github.com/chrisjoyce911/esp32FOTA, but it was wholly based on Wifi and WifiSecure libs that is not the way of communication I need in.

Describe the solution you'd like It would be perfect to get the OTA possibility added like introduced above library does, but having the end user free on physical communication device choice. I was unable to get worked the TinyGSM, SSLClient and esp32FOTA together, when the tandem of first two performed very well in another project.

woodlist avatar Apr 21 '21 18:04 woodlist

@woodlist you could use the "core included" library HTTPUpdate which need to instantiated by passing the reference to the used client.

cotestatnt avatar Apr 22 '21 05:04 cotestatnt

Please, help. Let we say, in OTA library is written WiFiClientSecure clientForOta; How do it should be reformatted, having omitted the WiFiClientSecure, if I have the beneath client declared in main.ino? TinyGsmClient baseclient(modem); SSLClient client(baseclient, TAs, (size_t)TAs_NUM, rand_pin);

woodlist avatar Apr 22 '21 14:04 woodlist

i looking inside the library, it's using setCACert() which is a WiFiClientSecure member( so no forced cast :/ ) , i see two ways to go: 1- shadow WifiClientSecure class with a child and orverride using SSLClient-TinyGSM client hide inside, this way no work inside the library is needed. 2- fork the library and make the changes to use client interface direct. I'm going try to use the second approach, it's do't look hard, but it's going to take a time(principally because i had never set up a htpps OTA server properly), if i have success i will post in here

HebertWP avatar Apr 23 '21 02:04 HebertWP

i looking inside the library, it's using setCACert() which is a WiFiClientSecure member( so no forced cast :/ ) , i see two ways to go: 1- shadow WifiClientSecure class with a child and orverride using SSLClient-TinyGSM client hide inside, this way no work inside the library is needed. 2- fork the library and make the changes to use client interface direct. I'm going try to use the second approach, it's do't look hard, but it's going to take a time(principally because i had never set up a htpps OTA server properly), if i have success i will post in here

I did a try to move all the OTA content from library to main code, for direct usage of defined by SSLClient client, but was unable to do advanced coding and make error free compilation

woodlist avatar Apr 23 '21 04:04 woodlist

i have find that espressif it's self have build a library caled Updade.h, this library just take a stream object(Arduino framework) that have the firmaware in a binary format and write it in ship , to have write a very simple test.

#include <Arduino.h>
#include <FS.h>
#include <Update.h>
#include <SD.h>

void setup()
{
    Serial.begin(115200);
    SD.begin();
    Serial.printf("Updating...\r\n");
    if (SD.exists("/newFirmWare.bin"))
    {
        File file = SD.open("/newFirmWare.bin", FILE_READ);
        if (!Update.begin(file.size()))
        {
            Serial.printf("Updade is to big");
            delay(1000);
            ESP.restart();
        }
        Update.writeStream(file);
        while (!Update.end() && !Update.hasError())
            ;
        file.close();
        if (Update.hasError())
        {
            Update.printError(Serial);
            delay(1000);
            ESP.restart();
        };
        Serial.printf("Update done\r\n");
        delay(1000);
        ESP.restart();
    }
}

void loop()
{
}

the library have a example to https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/examples/SD_Update/SD_Update.ino So i wrote simple python prog to take my binary file break it in parts and send over mqqt protocol in RAW, but i'm having some problem with package lost . In the library the are two more examples, AWS_S3_OTA_Update and HTTPS_OTA_Update, the fits one use wificlient direct. Yet working, but it's look promising

HebertWP avatar Apr 24 '21 09:04 HebertWP