mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-23 08:45:22 +03:00
Add WiFiClient parameter to HTTPClient (#4980)
Make HTTPClient take a WiFiClient parameter, allowing you to pass in a simple HTTP WiFiClient or a BearSSL or axTLS WiFiClientSecure with any desired verification options. Deprecate the older, TLSTraits methods. Add basic HttpsClient example. Add optional LED feedback to the Update class
This commit is contained in:
committed by
Earle F. Philhower, III
parent
9bc8ea1b58
commit
13f374666d
@ -26,6 +26,8 @@
|
||||
#ifndef ESP8266HTTPUPDATE_H_
|
||||
#define ESP8266HTTPUPDATE_H_
|
||||
|
||||
#define HTTPUPDATE_1_2_COMPATIBLE
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
@ -72,32 +74,48 @@ public:
|
||||
_rebootOnUpdate = reboot;
|
||||
}
|
||||
|
||||
void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH)
|
||||
{
|
||||
_ledPin = ledPin;
|
||||
_ledOn = ledOn;
|
||||
}
|
||||
|
||||
#ifdef 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 = "");
|
||||
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);
|
||||
const String& httpsFingerprint) __attribute__((deprecated));
|
||||
t_httpUpdate_return update(const String& url, const String& currentVersion,
|
||||
const uint8_t httpsFingerprint[20]); // BearSSL
|
||||
const uint8_t httpsFingerprint[20]) __attribute__((deprecated)); // BearSSL
|
||||
#endif
|
||||
t_httpUpdate_return update(WiFiClient& client, const String& url, const String& currentVersion = "");
|
||||
|
||||
#ifdef 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 = "");
|
||||
t_httpUpdate_return update(const String& host, uint16_t port, const String& url,
|
||||
const String& currentVersion, const String& httpsFingerprint);
|
||||
t_httpUpdate_return update(const String& host, uint16_t port, const String& url,
|
||||
const String& currentVersion, const uint8_t httpsFingerprint[20]); // BearSSL
|
||||
|
||||
#ifdef 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 = "");
|
||||
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion, const String& httpsFingerprint);
|
||||
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion, const uint8_t httpsFingerprint[20]); // BearSSL
|
||||
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 updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion = "");
|
||||
|
||||
|
||||
int getLastError(void);
|
||||
@ -111,6 +129,9 @@ protected:
|
||||
bool _rebootOnUpdate = true;
|
||||
private:
|
||||
int _httpClientTimeout;
|
||||
|
||||
int _ledPin;
|
||||
uint8_t _ledOn;
|
||||
};
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
|
||||
|
Reference in New Issue
Block a user