File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 55- Add Github action to check version
66- Add version.json file
77- Add device value in platform
8-
98- Add auto OTA update check on start
Original file line number Diff line number Diff line change 22#include < ESP8266WiFi.h>
33#include < Updater.h>
44#include < ESP8266HTTPClient.h>
5+ #include < WiFiClientSecureBearSSL.h>
56#else
67#include < WiFi.h>
78#include < Update.h>
1617#include " utils/log.h"
1718
1819const std::string AUTOUPDATE_URL = " https://raw.githubusercontent.com/matteocrippa/leafminer/main/version.json" ;
19- const char TAG_AUTOUPDATE[] = " autoupdate " ;
20+ const char TAG_AUTOUPDATE[] = " AutoUpdate " ;
2021
2122#if defined(ESP8266_D)
2223std::string DEVICE = " esp8266" ;
@@ -42,11 +43,19 @@ void autoupdate()
4243 while (WiFi.waitForConnectResult () != WL_CONNECTED)
4344 {
4445 WiFi.begin (configuration.wifi_ssid .c_str (), configuration.wifi_password .c_str ());
45- delay (800 );
46+ delay (500 );
4647 }
4748
4849 HTTPClient http;
50+ #if defined(ESP8266)
51+ std::unique_ptr<BearSSL::WiFiClientSecure> client (new BearSSL::WiFiClientSecure);
52+ client->setInsecure ();
53+ http.begin (*client, AUTOUPDATE_URL.c_str ());
54+ #else
4955 http.begin (AUTOUPDATE_URL.c_str ());
56+ #endif
57+ http.setFollowRedirects (HTTPC_FORCE_FOLLOW_REDIRECTS);
58+
5059 int httpCode = http.GET ();
5160 if (httpCode == HTTP_CODE_OK)
5261 {
@@ -110,7 +119,11 @@ void autoupdate()
110119
111120 l_debug (TAG_AUTOUPDATE, " Downloading: %s" , downloadUrl.c_str ());
112121
122+ #if defined(ESP8266)
123+ http.begin (*client, downloadUrl.c_str ());
124+ #else
113125 http.begin (downloadUrl.c_str ());
126+ #endif
114127 http.setFollowRedirects (HTTPC_FORCE_FOLLOW_REDIRECTS);
115128
116129 int httpCode = http.GET ();
You can’t perform that action at this time.
0 commit comments