generated from JohnMidity/ArduinoModules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathota.cpp
38 lines (35 loc) · 1.33 KB
/
ota.cpp
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
#include <ArduinoOTA.h>
#include "OTA.h"
OTA::OTA()
{
ArduinoOTA.onStart([]()
{ Serial.println("Start"); });
ArduinoOTA.onEnd([]()
{ Serial.println("\nEnd"); });
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
{ Serial.printf("Progress: %u%%\r", (progress / (total / 100))); });
ArduinoOTA.onError([](ota_error_t error)
{
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR)
Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR)
Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR)
Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR)
Serial.println("Receive Failed");
else if (error == OTA_END_ERROR)
Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void OTA::moduleLoop()
{
if (WiFi.isConnected())
{
ArduinoOTA.handle();
}
}