Skip to content

Commit

Permalink
arduino-esp32 core 2.x => 3.x migration (fixes #146)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed May 28, 2024
1 parent c8573d1 commit 23489ca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
18 changes: 13 additions & 5 deletions src/esp32FOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,25 @@

#include "esp32FOTA.hpp"

#include "mbedtls/pk.h"
#include "mbedtls/md.h"
#include "mbedtls/md_internal.h"
// arduino-esp32 core 2.x => 3.x migration
#if __has_include("md_wrap.h")
#include "md_wrap.h"
#else
#include "mbedtls/pk.h"
#include "mbedtls/md.h"
#include "mbedtls/md_internal.h"
#endif
// arduino-esp32 core 2.x => 3.x migration
#if !defined SPI_FLASH_SEC_SIZE
#include "spi_flash_mmap.h"
#endif

#include "esp_ota_ops.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"



static int64_t getHTTPStream( esp32FOTA* fota, int partition );
static int64_t getFileStream( esp32FOTA* fota, int partition );
static int64_t getSerialStream( esp32FOTA* fota, int partition );
Expand Down
18 changes: 13 additions & 5 deletions src/esp32FOTA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ extern "C" {
}

#include <map>
#include <WiFiClientSecure.h>
#include <WiFi.h>

// arduino-esp32 core 2.x => 3.x migration
#if __has_include(<NetworkClientSecure.h>)
#include <NetworkClientSecure.h>
#define ClientSecure NetworkClientSecure
#else
#include <WiFiClientSecure.h>
#define ClientSecure WiFiClientSecure
#endif

#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <FS.h>
Expand Down Expand Up @@ -86,8 +96,6 @@ extern "C" {
#endif




#if __has_include(<flashz.hpp>)
#pragma message "Using FlashZ as Update agent"
#include <flashz.hpp>
Expand Down Expand Up @@ -325,7 +333,7 @@ class esp32FOTA
FOTAConfig_t getConfig() { return _cfg; };
FOTAStreamType_t getStreamType() { return _stream_type; }
HTTPClient* getHTTPCLient() { return &_http; }
WiFiClientSecure* getWiFiClient() { return &_client; }
ClientSecure* getWiFiClient() { return &_client; }
fs::File* getFotaFilePtr() { return &_file; }
Stream* getFotaStreamPtr() { return _stream; }
fs::FS* getFotaFS() { return _fs; }
Expand All @@ -341,7 +349,7 @@ class esp32FOTA
private:

HTTPClient _http;
WiFiClientSecure _client;
ClientSecure _client;
Stream *_stream;
fs::File _file;

Expand Down

0 comments on commit 23489ca

Please sign in to comment.