-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOTA.ino
35 lines (28 loc) · 955 Bytes
/
OTA.ino
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
inline void setupOTA() {
logLine("Setting up OTA updates...");
ArduinoOTA.onStart([]() {
running = false;
logLine("Starting OTA...");
});
ArduinoOTA.onEnd([]() {
logLine("OTA update finished!");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
logf("OTA progress: %u%%r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
running = true;
logf("-- OTA ERROR: [%u]", error);
if (error == OTA_AUTH_ERROR)
logLine("Authentication error");
else if (error == OTA_BEGIN_ERROR)
logLine("OTA begin error");
else if (error == OTA_CONNECT_ERROR)
logLine("Connect error");
else if (error == OTA_RECEIVE_ERROR)
logLine("Receive error");
else if (error == OTA_END_ERROR)
logLine("OTA end error");
});
ArduinoOTA.begin();
}