-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
backup.h
40 lines (29 loc) · 1.15 KB
/
backup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/controller.h"
#include "esphome/components/web_server_base/web_server_base.h"
#include <vector>
extern const uint8_t ESPHOME_BACKUP_DATA[] PROGMEM;
extern const size_t ESPHOME_BACKUP_SIZE;
namespace esphome {
namespace backup {
class Backup : public Component, public AsyncWebHandler {
public:
explicit Backup(web_server_base::WebServerBase *base) : base_(base) {}
void setup() override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::WIFI - 1.0f; }
void set_username(const char *username) { this->username_ = username; }
void set_password(const char *password) { this->password_ = password; }
bool using_auth() { return this->username_ != nullptr && this->password_ != nullptr; }
bool canHandle(AsyncWebServerRequest *request) override;
void handleRequest(AsyncWebServerRequest *request) override;
protected:
web_server_base::WebServerBase *base_;
const uint8_t *data_{nullptr};
size_t size_{0};
const char *username_{nullptr};
const char *password_{nullptr};
};
} // namespace backup
} // namespace esphome