-
Notifications
You must be signed in to change notification settings - Fork 1
/
UploadFirmwareService.h
38 lines (31 loc) · 982 Bytes
/
UploadFirmwareService.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
#ifndef UploadFirmwareService_h
#define UploadFirmwareService_h
#include <Arduino.h>
#ifdef ESP32
#include <Update.h>
#include <WiFi.h>
#include <AsyncTCP.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>
#include <SecurityManager.h>
#include <RestartService.h>
#define UPLOAD_FIRMWARE_PATH "/rest/uploadFirmware"
class UploadFirmwareService {
public:
UploadFirmwareService(AsyncWebServer* server, SecurityManager* securityManager);
private:
SecurityManager* _securityManager;
void handleUpload(AsyncWebServerRequest* request,
const String& filename,
size_t index,
uint8_t* data,
size_t len,
bool final);
void uploadComplete(AsyncWebServerRequest* request);
void handleError(AsyncWebServerRequest* request, int code);
static void handleEarlyDisconnect();
};
#endif // end UploadFirmwareService_h