forked from xiaozhi/xiaozhi-esp32
Add activation version 2
This commit is contained in:
12
main/ota.h
12
main/ota.h
@@ -5,6 +5,9 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include <esp_err.h>
|
||||
#include "board.h"
|
||||
|
||||
class Ota {
|
||||
public:
|
||||
Ota();
|
||||
@@ -13,6 +16,8 @@ public:
|
||||
void SetCheckVersionUrl(std::string check_version_url);
|
||||
void SetHeader(const std::string& key, const std::string& value);
|
||||
bool CheckVersion();
|
||||
esp_err_t Activate();
|
||||
bool HasActivationChallenge() { return has_activation_challenge_; }
|
||||
bool HasNewVersion() { return has_new_version_; }
|
||||
bool HasMqttConfig() { return has_mqtt_config_; }
|
||||
bool HasActivationCode() { return has_activation_code_; }
|
||||
@@ -33,15 +38,22 @@ private:
|
||||
bool has_mqtt_config_ = false;
|
||||
bool has_server_time_ = false;
|
||||
bool has_activation_code_ = false;
|
||||
bool has_serial_number_ = false;
|
||||
bool has_activation_challenge_ = false;
|
||||
std::string current_version_;
|
||||
std::string firmware_version_;
|
||||
std::string firmware_url_;
|
||||
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_;
|
||||
std::vector<int> ParseVersion(const std::string& version);
|
||||
bool IsNewVersionAvailable(const std::string& currentVersion, const std::string& newVersion);
|
||||
std::string GetActivationPayload();
|
||||
Http* SetupHttp();
|
||||
};
|
||||
|
||||
#endif // _OTA_H
|
||||
|
||||
Reference in New Issue
Block a user