If the code hasn't been touched in this long, its probably release-worthy.
This commit is contained in:
34
src/platform/arduino/OTA.cpp
Normal file
34
src/platform/arduino/OTA.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "OTA.h"
|
||||
#include "../../Static.h"
|
||||
|
||||
ArduinoOTAUpdater::ArduinoOTAUpdater() : BufferedInputSource("ArduinoOTA") {
|
||||
ArduinoOTA.onStart(&ArduinoOTAUpdater::s_onStart);
|
||||
ArduinoOTA.onProgress(&ArduinoOTAUpdater::s_onProgress);
|
||||
}
|
||||
|
||||
void ArduinoOTAUpdater::loop() {
|
||||
if (m_online) {
|
||||
ArduinoOTA.handle();
|
||||
}
|
||||
BufferedInputSource::loop();
|
||||
}
|
||||
|
||||
void ArduinoOTAUpdater::handleEvent(const InputEvent& evt) {
|
||||
if (evt.intent == InputEvent::NetworkStatus && evt.asInt()) {
|
||||
Log.notice("Booting OTA");
|
||||
m_online = true;
|
||||
ArduinoOTA.begin();
|
||||
}
|
||||
}
|
||||
void ArduinoOTAUpdater::s_onStart() {
|
||||
Log.notice("OTA Start!");
|
||||
Static<ArduinoOTAUpdater>::instance()->setEvent(InputEvent::FirmwareUpdate);
|
||||
}
|
||||
|
||||
void ArduinoOTAUpdater::s_onProgress(unsigned int progress, unsigned int total) {
|
||||
Log.notice("OTA Progress! %d / %d", progress, total);
|
||||
Static<ArduinoOTAUpdater>::instance()->setEvent(InputEvent{InputEvent::FirmwareUpdate, progress});
|
||||
}
|
||||
|
||||
STATIC_ALLOC(ArduinoOTAUpdater);
|
||||
STATIC_TASK(ArduinoOTAUpdater);
|
Reference in New Issue
Block a user