Skip to content

Commit

Permalink
ESP266httpUpdate: remove dead API and fix doc (#8063)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-v committed Jun 23, 2021
1 parent d283541 commit 32fad07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 167 deletions.
11 changes: 9 additions & 2 deletions doc/ota_updates/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ Simple updater downloads the file every time the function is called.

.. code:: cpp
ESPhttpUpdate.update("192.168.0.2", 80, "/arduino.bin");
WiFiClient client;
ESPhttpUpdate.update(client, "192.168.0.2", 80, "/arduino.bin");
Advanced updater
^^^^^^^^^^^^^^^^
Expand All @@ -541,7 +542,8 @@ The server-side script can respond as follows: - response code 200, and send the

.. code:: cpp
t_httpUpdate_return ret = ESPhttpUpdate.update("192.168.0.2", 80, "/esp/update/arduino.php", "optional current version string here");
WiFiClient client;
t_httpUpdate_return ret = ESPhttpUpdate.update(client, "192.168.0.2", 80, "/esp/update/arduino.php", "optional current version string here");
switch(ret) {
case HTTP_UPDATE_FAILED:
Serial.println("[update] Update failed.");
Expand All @@ -554,6 +556,11 @@ The server-side script can respond as follows: - response code 200, and send the
break;
}
TLS updater
^^^^^^^^^^^

Please read and try the examples provided with the library.

Server request handling
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
126 changes: 0 additions & 126 deletions libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,146 +63,20 @@ void ESP8266HTTPUpdate::setAuthorization(const String &auth)
_auth = auth;
}

#if HTTPUPDATE_1_2_COMPATIBLE
HTTPUpdateResult ESP8266HTTPUpdate::update(const String& url, const String& currentVersion,
const String& httpsFingerprint, bool reboot)
{
rebootOnUpdate(reboot);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return update(url, currentVersion, httpsFingerprint);
#pragma GCC diagnostic pop
}

HTTPUpdateResult ESP8266HTTPUpdate::update(const String& url, const String& currentVersion)
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(url);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, false);
}

HTTPUpdateResult ESP8266HTTPUpdate::update(const String& url, const String& currentVersion,
const String& httpsFingerprint)
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(url, httpsFingerprint);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, false);
}

HTTPUpdateResult ESP8266HTTPUpdate::update(const String& url, const String& currentVersion,
const uint8_t httpsFingerprint[20])
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(url, httpsFingerprint);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, false);
}
#endif

HTTPUpdateResult ESP8266HTTPUpdate::update(WiFiClient& client, const String& url, const String& currentVersion)
{
HTTPClient http;
http.begin(client, url);
return handleUpdate(http, currentVersion, false);
}

#if HTTPUPDATE_1_2_COMPATIBLE
HTTPUpdateResult ESP8266HTTPUpdate::updateSpiffs(const String& url, const String& currentVersion, const String& httpsFingerprint)
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(url, httpsFingerprint);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, true);
}

HTTPUpdateResult ESP8266HTTPUpdate::updateSpiffs(const String& url, const String& currentVersion, const uint8_t httpsFingerprint[20])
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(url, httpsFingerprint);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, true);
}

HTTPUpdateResult ESP8266HTTPUpdate::updateSpiffs(const String& url, const String& currentVersion)
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(url);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, true);
}
#endif

HTTPUpdateResult ESP8266HTTPUpdate::updateFS(WiFiClient& client, const String& url, const String& currentVersion)
{
HTTPClient http;
http.begin(client, url);
return handleUpdate(http, currentVersion, true);
}

#if HTTPUPDATE_1_2_COMPATIBLE
HTTPUpdateResult ESP8266HTTPUpdate::update(const String& host, uint16_t port, const String& uri, const String& currentVersion,
bool https, const String& httpsFingerprint, bool reboot)
{
(void)https;
rebootOnUpdate(reboot);
if (httpsFingerprint.length() == 0) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return update(host, port, uri, currentVersion);
} else {
return update(host, port, uri, currentVersion, httpsFingerprint);
#pragma GCC diagnostic pop
}
}

HTTPUpdateResult ESP8266HTTPUpdate::update(const String& host, uint16_t port, const String& uri,
const String& currentVersion)
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(host, port, uri);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, false);
}

HTTPUpdateResult ESP8266HTTPUpdate::update(const String& host, uint16_t port, const String& url,
const String& currentVersion, const String& httpsFingerprint)
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(host, port, url, httpsFingerprint);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, false);
}

HTTPUpdateResult ESP8266HTTPUpdate::update(const String& host, uint16_t port, const String& url,
const String& currentVersion, const uint8_t httpsFingerprint[20])
{
HTTPClient http;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
http.begin(host, port, url, httpsFingerprint);
#pragma GCC diagnostic pop
return handleUpdate(http, currentVersion, false);
}
#endif

HTTPUpdateResult ESP8266HTTPUpdate::update(WiFiClient& client, const String& host, uint16_t port, const String& uri,
const String& currentVersion)
{
Expand Down
39 changes: 0 additions & 39 deletions libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
#include <WiFiUdp.h>
#include <ESP8266HTTPClient.h>

#ifndef HTTPUPDATE_1_2_COMPATIBLE
#define HTTPUPDATE_1_2_COMPATIBLE HTTPCLIENT_1_1_COMPATIBLE
#endif

#ifdef DEBUG_ESP_HTTP_UPDATE
#ifdef DEBUG_ESP_PORT
#define DEBUG_HTTP_UPDATE(fmt, ...) DEBUG_ESP_PORT.printf_P( (PGM_P)PSTR(fmt), ## __VA_ARGS__ )
Expand Down Expand Up @@ -115,45 +111,10 @@ class ESP8266HTTPUpdate
void setAuthorization(const String& user, const String& password);
void setAuthorization(const String& auth);

#if HTTPUPDATE_1_2_COMPATIBLE
// This function is deprecated, use rebootOnUpdate and the next one instead
t_httpUpdate_return update(const String& url, const String& currentVersion,
const String& httpsFingerprint, bool reboot) __attribute__((deprecated));
t_httpUpdate_return update(const String& url, const String& currentVersion = "") __attribute__((deprecated));
t_httpUpdate_return update(const String& url, const String& currentVersion,
const String& httpsFingerprint) __attribute__((deprecated));
t_httpUpdate_return update(const String& url, const String& currentVersion,
const uint8_t httpsFingerprint[20]) __attribute__((deprecated)); // BearSSL
#endif
t_httpUpdate_return update(WiFiClient& client, const String& url, const String& currentVersion = "");

#if HTTPUPDATE_1_2_COMPATIBLE
// This function is deprecated, use one of the overloads below along with rebootOnUpdate
t_httpUpdate_return update(const String& host, uint16_t port, const String& uri, const String& currentVersion,
bool https, const String& httpsFingerprint, bool reboot) __attribute__((deprecated));

t_httpUpdate_return update(const String& host, uint16_t port, const String& uri = "/",
const String& currentVersion = "") __attribute__((deprecated));
t_httpUpdate_return update(const String& host, uint16_t port, const String& url,
const String& currentVersion, const String& httpsFingerprint) __attribute__((deprecated));
t_httpUpdate_return update(const String& host, uint16_t port, const String& url,
const String& currentVersion, const uint8_t httpsFingerprint[20]) __attribute__((deprecated)); // BearSSL
#endif
t_httpUpdate_return update(WiFiClient& client, const String& host, uint16_t port, const String& uri = "/",
const String& currentVersion = "");

#if HTTPUPDATE_1_2_COMPATIBLE
// This function is deprecated, use rebootOnUpdate and the next one instead
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion,
const String& httpsFingerprint, bool reboot) __attribute__((deprecated));
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion = "") __attribute__((deprecated));
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion, const String& httpsFingerprint) __attribute__((deprecated));
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion, const uint8_t httpsFingerprint[20]) __attribute__((deprecated)); // BearSSL
#endif
t_httpUpdate_return updateFS(WiFiClient& client, const String& url, const String& currentVersion = "");
t_httpUpdate_return updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion = "") __attribute__((deprecated)) {
return updateFS(client, url, currentVersion);
};

// Notification callbacks
void onStart(HTTPUpdateStartCB cbOnStart) { _cbStart = cbOnStart; }
Expand Down

0 comments on commit 32fad07

Please sign in to comment.