Skip to content

Commit f890220

Browse files
committed
remove unused ota class members
1 parent ce1211c commit f890220

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

main/ota.cc

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@
2323

2424

2525
Ota::Ota() {
26-
{
27-
Settings settings("wifi", false);
28-
check_version_url_ = settings.GetString("ota_url");
29-
if (check_version_url_.empty()) {
30-
check_version_url_ = CONFIG_OTA_URL;
31-
}
32-
}
33-
3426
#ifdef ESP_EFUSE_BLOCK_USR_DATA
3527
// Read Serial Number from efuse user_data
3628
uint8_t serial_number[33] = {0};
@@ -48,19 +40,20 @@ Ota::Ota() {
4840
Ota::~Ota() {
4941
}
5042

51-
void Ota::SetHeader(const std::string& key, const std::string& value) {
52-
headers_[key] = value;
43+
std::string Ota::GetCheckVersionUrl() {
44+
Settings settings("wifi", false);
45+
std::string url = settings.GetString("ota_url");
46+
if (url.empty()) {
47+
url = CONFIG_OTA_URL;
48+
}
49+
return url;
5350
}
5451

5552
Http* Ota::SetupHttp() {
5653
auto& board = Board::GetInstance();
5754
auto app_desc = esp_app_get_description();
5855

5956
auto http = board.CreateHttp();
60-
for (const auto& header : headers_) {
61-
http->SetHeader(header.first, header.second);
62-
}
63-
6457
http->SetHeader("Activation-Version", has_serial_number_ ? "2" : "1");
6558
http->SetHeader("Device-Id", SystemInfo::GetMacAddress().c_str());
6659
http->SetHeader("Client-Id", board.GetUuid());
@@ -79,7 +72,8 @@ bool Ota::CheckVersion() {
7972
current_version_ = app_desc->version;
8073
ESP_LOGI(TAG, "Current version: %s", current_version_.c_str());
8174

82-
if (check_version_url_.length() < 10) {
75+
std::string url = GetCheckVersionUrl();
76+
if (url.length() < 10) {
8377
ESP_LOGE(TAG, "Check version URL is not properly set");
8478
return false;
8579
}
@@ -90,7 +84,7 @@ bool Ota::CheckVersion() {
9084
std::string method = data.length() > 0 ? "POST" : "GET";
9185
http->SetContent(std::move(data));
9286

93-
if (!http->Open(method, check_version_url_)) {
87+
if (!http->Open(method, url)) {
9488
ESP_LOGE(TAG, "Failed to open HTTP connection");
9589
return false;
9690
}
@@ -431,7 +425,7 @@ esp_err_t Ota::Activate() {
431425
return ESP_FAIL;
432426
}
433427

434-
std::string url = check_version_url_;
428+
std::string url = GetCheckVersionUrl();
435429
if (url.back() != '/') {
436430
url += "/activate";
437431
} else {

main/ota.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <functional>
55
#include <string>
6-
#include <map>
76

87
#include <esp_err.h>
98
#include "board.h"
@@ -13,7 +12,6 @@ class Ota {
1312
Ota();
1413
~Ota();
1514

16-
void SetHeader(const std::string& key, const std::string& value);
1715
bool CheckVersion();
1816
esp_err_t Activate();
1917
bool HasActivationChallenge() { return has_activation_challenge_; }
@@ -29,10 +27,9 @@ class Ota {
2927
const std::string& GetCurrentVersion() const { return current_version_; }
3028
const std::string& GetActivationMessage() const { return activation_message_; }
3129
const std::string& GetActivationCode() const { return activation_code_; }
32-
const std::string& GetCheckVersionUrl() const { return check_version_url_; }
30+
std::string GetCheckVersionUrl();
3331

3432
private:
35-
std::string check_version_url_;
3633
std::string activation_message_;
3734
std::string activation_code_;
3835
bool has_new_version_ = false;
@@ -48,7 +45,6 @@ class Ota {
4845
std::string activation_challenge_;
4946
std::string serial_number_;
5047
int activation_timeout_ms_ = 30000;
51-
std::map<std::string, std::string> headers_;
5248

5349
void Upgrade(const std::string& firmware_url);
5450
std::function<void(int progress, size_t speed)> upgrade_callback_;

0 commit comments

Comments
 (0)