-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathota-http.h
47 lines (35 loc) · 860 Bytes
/
ota-http.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
41
42
43
44
45
46
47
#ifndef ota_http_H
#define ota_http_H
#include <esp_err.h>
#include <esp_log.h>
#include <mbedtls/sha256.h>
#include <mbedtls/aes.h>
#include <esp_ota_ops.h>
#include <esp_task_wdt.h>
#include <esp_partition.h>
#ifndef tcp_H
#include "esp32-tcp/tcp.h"
#include "esp32-tcp/tcp.cpp"
#endif
class OTA_HTTP
{
private:
const char tag[9] = "OTA_HTTP";
int8_t _cry = 0;
uint8_t _firstiv[16] = {0};
uint8_t _iv[16] = {0};
uint16_t _port = 80;
mbedtls_aes_context aes;
TCP_CLIENT tcp;
TCP_SERVER host;
int8_t wait(uint16_t time);
void decrypt(uint8_t *data, uint16_t size);
int16_t first_boundary(uint8_t *data);
int16_t last_boundary(uint8_t *data, uint16_t size);
void iterator(uint8_t *data, uint16_t data_size);
public:
void init(uint16_t port);
void crypto(const char *key, const char *iv);
void process();
};
#endif