-
Notifications
You must be signed in to change notification settings - Fork 629
Experimental support of HTTPUpdate for OTA #1751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
562784d
4af49b8
cd90b4f
e1d2cd7
d1d1f29
4bef90d
ccf633a
d3cae74
e747e48
27bc003
4f64b40
ce1eec8
dc27119
c8d81f6
d10bdba
f7e2b9f
5806152
e6036d4
d8aeb5a
00436b9
8608449
2506e95
bdc1f5d
0c13f51
6f21b97
f3ffa4d
763b66a
39a02d0
1342a80
3128dba
3889381
0537b5b
83063bf
d4b59c1
94b2a33
d9a3d71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| #include <Arduino.h> | ||
| #include <ArduinoJson.h> | ||
| #include <functional> | ||
| #include <memory> | ||
| #include <core_version.h> | ||
|
|
||
| extern "C" { | ||
|
|
@@ -168,7 +169,30 @@ void i2c_read_buffer(uint8_t address, uint8_t * buffer, size_t len); | |
| // ----------------------------------------------------------------------------- | ||
| // OTA | ||
| // ----------------------------------------------------------------------------- | ||
| #include "ESPAsyncTCP.h" | ||
|
|
||
| #include <ArduinoOTA.h> | ||
|
|
||
| #if OTA_CLIENT == OTA_CLIENT_ASYNCTCP | ||
| #include <ESPAsyncTCP.h> | ||
| #endif | ||
|
|
||
| #if OTA_CLIENT == OTA_CLIENT_HTTPUPDATE | ||
| #include <ESP8266HTTPClient.h> | ||
| #include <ESP8266httpUpdate.h> | ||
| #endif | ||
|
|
||
| #if SECURE_CLIENT != SECURE_CLIENT_NONE | ||
|
|
||
| #include <WiFiClientSecure.h> | ||
|
|
||
| #if OTA_SECURE_CLIENT_INCLUDE_CA | ||
| #include "static/ota_secure_client_ca.h" | ||
| #else | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I wanted to add something here using .cpp files and weaken the progmem char symbol, but that did not quite work. This probably can even be just a check for include_ca flag, progmem'ed array will be discarded anyways as unused variable. |
||
| #include "static/digicert_evroot_pem.h" | ||
| #define _ota_client_http_update_ca _ssl_digicert_ev_root_ca | ||
| #endif | ||
|
|
||
| #endif // SECURE_CLIENT_SUPPORT | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| // RFM69 | ||
|
|
@@ -285,3 +309,14 @@ bool wifiConnected(); | |
| // ----------------------------------------------------------------------------- | ||
| #include "rtcmem.h" | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| // std::make_unique backport for C++11 | ||
| // ----------------------------------------------------------------------------- | ||
| #if 201103L >= __cplusplus | ||
| namespace std { | ||
| template<typename T, typename... Args> | ||
| std::unique_ptr<T> make_unique(Args&&... args) { | ||
| return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); | ||
| } | ||
| } | ||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // ----------------------------------------------------------------------------- | ||
| // Parse char string as URL | ||
| // | ||
| // Adapted from HTTPClient::beginInternal() | ||
| // https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | ||
| // | ||
| // ----------------------------------------------------------------------------- | ||
|
|
||
| #pragma once | ||
|
|
||
| struct URL { | ||
| String value; | ||
| String protocol; | ||
| String host; | ||
| String path; | ||
| uint16_t port; | ||
|
|
||
| URL(const char* url) { init(url); } | ||
| URL(const String& url) { init(url); } | ||
|
|
||
| void init(String url); | ||
| }; | ||
|
|
||
| void URL::init(String url) { | ||
|
|
||
| this->value = url; | ||
|
|
||
| // cut the protocol part | ||
| int index = url.indexOf("://"); | ||
| if (index > 0) { | ||
| this->protocol = url.substring(0, index); | ||
| url.remove(0, (index + 3)); | ||
| } | ||
|
|
||
| if (this->protocol == "http") { | ||
| this->port = 80; | ||
| } else if (this->protocol == "https") { | ||
| this->port = 443; | ||
| } | ||
|
|
||
| // cut the host part | ||
| String _host; | ||
|
|
||
| index = url.indexOf('/'); | ||
| if (index >= 0) { | ||
| _host = url.substring(0, index); | ||
| } else { | ||
| _host = url; | ||
| } | ||
|
|
||
| // store the remaining part as path | ||
| if (index >= 0) { | ||
| url.remove(0, index); | ||
| this->path = url; | ||
| } else { | ||
| this->path = "/"; | ||
| } | ||
|
|
||
| // separate host from port, when present | ||
| index = _host.indexOf(':'); | ||
| if (index >= 0) { | ||
| this->port = _host.substring(index + 1).toInt(); | ||
| this->host = _host.substring(0, index); | ||
| } else { | ||
| this->host = _host; | ||
| } | ||
|
|
||
| } |
Uh oh!
There was an error while loading. Please reload this page.