forked from arduino-libraries/ArduinoIoTCloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOTAUnoR4.h
57 lines (41 loc) · 1.53 KB
/
OTAUnoR4.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
48
49
50
51
52
53
54
55
56
57
/*
This file is part of the ArduinoIoTCloud library.
Copyright (c) 2024 Arduino SA
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "ota/interface/OTAInterface.h"
#include "OTAUpdate.h"
#include "r_flash_lp.h"
class UNOR4OTACloudProcess: public OTACloudProcessInterface {
public:
UNOR4OTACloudProcess(MessageStream *ms);
bool isOtaCapable() override;
protected:
virtual OTACloudProcessInterface::State resume(Message* msg=nullptr) override;
// we are overriding the method of startOTA in order to download ota file on ESP32
virtual OTACloudProcessInterface::State startOTA() override;
// we start the download and decompress process
virtual OTACloudProcessInterface::State fetch() override;
// whene the download is correctly finished we set the mcu to use the newly downloaded binary
virtual OTACloudProcessInterface::State flashOTA() override;
// we reboot the device
virtual OTACloudProcessInterface::State reboot() override;
virtual void reset() override;
constexpr void* appStartAddress();
uint32_t appSize();
bool appFlashOpen();
bool appFlashClose();
public:
// used to access to flash memory for sha256 calculation
flash_lp_instance_ctrl_t ctrl;
flash_cfg_t cfg;
OTAUpdate ota;
static const char UPDATE_FILE_NAME[];
struct Context {
uint32_t downloadSize;
uint32_t lastReportTime;
} *context;
};