forked from xiaozhi/xiaozhi-esp32
remove unused ota class members
This commit is contained in:
28
main/ota.cc
28
main/ota.cc
@@ -23,14 +23,6 @@
|
||||
|
||||
|
||||
Ota::Ota() {
|
||||
{
|
||||
Settings settings("wifi", false);
|
||||
check_version_url_ = settings.GetString("ota_url");
|
||||
if (check_version_url_.empty()) {
|
||||
check_version_url_ = CONFIG_OTA_URL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ESP_EFUSE_BLOCK_USR_DATA
|
||||
// Read Serial Number from efuse user_data
|
||||
uint8_t serial_number[33] = {0};
|
||||
@@ -48,8 +40,13 @@ Ota::Ota() {
|
||||
Ota::~Ota() {
|
||||
}
|
||||
|
||||
void Ota::SetHeader(const std::string& key, const std::string& value) {
|
||||
headers_[key] = value;
|
||||
std::string Ota::GetCheckVersionUrl() {
|
||||
Settings settings("wifi", false);
|
||||
std::string url = settings.GetString("ota_url");
|
||||
if (url.empty()) {
|
||||
url = CONFIG_OTA_URL;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
Http* Ota::SetupHttp() {
|
||||
@@ -57,10 +54,6 @@ Http* Ota::SetupHttp() {
|
||||
auto app_desc = esp_app_get_description();
|
||||
|
||||
auto http = board.CreateHttp();
|
||||
for (const auto& header : headers_) {
|
||||
http->SetHeader(header.first, header.second);
|
||||
}
|
||||
|
||||
http->SetHeader("Activation-Version", has_serial_number_ ? "2" : "1");
|
||||
http->SetHeader("Device-Id", SystemInfo::GetMacAddress().c_str());
|
||||
http->SetHeader("Client-Id", board.GetUuid());
|
||||
@@ -79,7 +72,8 @@ bool Ota::CheckVersion() {
|
||||
current_version_ = app_desc->version;
|
||||
ESP_LOGI(TAG, "Current version: %s", current_version_.c_str());
|
||||
|
||||
if (check_version_url_.length() < 10) {
|
||||
std::string url = GetCheckVersionUrl();
|
||||
if (url.length() < 10) {
|
||||
ESP_LOGE(TAG, "Check version URL is not properly set");
|
||||
return false;
|
||||
}
|
||||
@@ -90,7 +84,7 @@ bool Ota::CheckVersion() {
|
||||
std::string method = data.length() > 0 ? "POST" : "GET";
|
||||
http->SetContent(std::move(data));
|
||||
|
||||
if (!http->Open(method, check_version_url_)) {
|
||||
if (!http->Open(method, url)) {
|
||||
ESP_LOGE(TAG, "Failed to open HTTP connection");
|
||||
return false;
|
||||
}
|
||||
@@ -431,7 +425,7 @@ esp_err_t Ota::Activate() {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
std::string url = check_version_url_;
|
||||
std::string url = GetCheckVersionUrl();
|
||||
if (url.back() != '/') {
|
||||
url += "/activate";
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include <esp_err.h>
|
||||
#include "board.h"
|
||||
@@ -13,7 +12,6 @@ public:
|
||||
Ota();
|
||||
~Ota();
|
||||
|
||||
void SetHeader(const std::string& key, const std::string& value);
|
||||
bool CheckVersion();
|
||||
esp_err_t Activate();
|
||||
bool HasActivationChallenge() { return has_activation_challenge_; }
|
||||
@@ -29,10 +27,9 @@ public:
|
||||
const std::string& GetCurrentVersion() const { return current_version_; }
|
||||
const std::string& GetActivationMessage() const { return activation_message_; }
|
||||
const std::string& GetActivationCode() const { return activation_code_; }
|
||||
const std::string& GetCheckVersionUrl() const { return check_version_url_; }
|
||||
std::string GetCheckVersionUrl();
|
||||
|
||||
private:
|
||||
std::string check_version_url_;
|
||||
std::string activation_message_;
|
||||
std::string activation_code_;
|
||||
bool has_new_version_ = false;
|
||||
@@ -48,7 +45,6 @@ private:
|
||||
std::string activation_challenge_;
|
||||
std::string serial_number_;
|
||||
int activation_timeout_ms_ = 30000;
|
||||
std::map<std::string, std::string> headers_;
|
||||
|
||||
void Upgrade(const std::string& firmware_url);
|
||||
std::function<void(int progress, size_t speed)> upgrade_callback_;
|
||||
|
||||
Reference in New Issue
Block a user