SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
ota.cpp
Go to the documentation of this file.
1#include "ota.h"
2
3#include <Arduino.h>
4#include <ArduinoOTA.h>
5
6#include "sensesp.h"
7
8namespace sensesp {
9
10void OTA::start() {
11 ArduinoOTA.setPassword(password_);
12 ArduinoOTA.onStart([]() { debugW("Starting OTA"); });
13 ArduinoOTA.onEnd([]() { debugW("OTA End"); });
14 ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
15 debugI("OTA Progress: %u%%\r", (progress / (total / 100)));
16 });
17 ArduinoOTA.onError([](ota_error_t error) {
18 debugE("OTA Error[%u]: ", error);
19 if (error == OTA_AUTH_ERROR) {
20 debugE("OTA Auth Failed");
21 } else if (error == OTA_BEGIN_ERROR) {
22 debugE("OTA Begin Failed");
23 } else if (error == OTA_CONNECT_ERROR) {
24 debugE("OTA Connect Failed");
25 } else if (error == OTA_RECEIVE_ERROR) {
26 debugE("OTA Receive Failed");
27 } else if (error == OTA_END_ERROR) {
28 debugE("OTA End Failed");
29 }
30 });
31 ArduinoOTA.begin();
32 ReactESP::app->onRepeat(20, OTA::handle_ota);
33}
34
35void OTA::handle_ota() { ArduinoOTA.handle(); }
36
37} // namespace sensesp
Construct a new transform based on a single function.
virtual void start() override
Definition ota.cpp:10
#define debugI(fmt,...)
Definition local_debug.h:48
#define debugE(fmt,...)
Definition local_debug.h:50
#define debugW(fmt,...)
Definition local_debug.h:49