diff --git a/src/plugins/OtaTcpPlugin.cpp b/src/plugins/OtaTcpPlugin.cpp deleted file mode 100644 index 54daa9a..0000000 --- a/src/plugins/OtaTcpPlugin.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __OTA_CLASSIC_H__ -#define __OTA_CLASSIC_H__ - -#include "TaskSchedulerDeclarations.h" -#include "ArduinoOTA.h" -#include "Plugin.h" - -using namespace std; -using namespace std::placeholders; - -struct OtaConfig { - int port; - const char* password; -}; - -class OtaTcpPlugin : public Plugin { - private: - OtaConfig config; - Task otaTask; - public: - OtaTcpPlugin(OtaConfig cfg){ - config = cfg; - - } - void enable() { - Serial.println("OTA enable"); - ArduinoOTA.begin(); - otaTask.enable(); - } - void activate(Scheduler* userScheduler){ - // setup task - // TOOD check if we can increase the time OTA needs to be handled - // FIXME make this configurable - otaTask.set(TASK_MILLISECOND * 1000, TASK_FOREVER, [](){ - ArduinoOTA.handle(); - }); - userScheduler->addTask(otaTask); - - // configure OTA - ArduinoOTA.setPort(config.port); - //ArduinoOTA.setHostname(HOSTNAME); - if(strlen(config.password) > 0){ - ArduinoOTA.setPassword(config.password); - } - // setup callbacks - ArduinoOTA.onStart([]() { - Serial.println("OTA: Start"); - }); - ArduinoOTA.onEnd([]() { - Serial.println("OTA: End"); - }); - ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { - Serial.printf("OTA: Progress: %u%%\r", (progress / (total / 100))); - }); - ArduinoOTA.onError([](ota_error_t error) { - Serial.printf("OTA: Error[%u]: ", error); - if (error == OTA_AUTH_ERROR) Serial.println("OTA: Auth Failed"); - else if (error == OTA_BEGIN_ERROR) Serial.println("OTA: Begin Failed"); - else if (error == OTA_CONNECT_ERROR) Serial.println("OTA: Connect Failed"); - else if (error == OTA_RECEIVE_ERROR) Serial.println("OTA: Receive Failed"); - else if (error == OTA_END_ERROR) Serial.println("OTA: End Failed"); - }); - - enable(); - } - void disable(){ - otaTask.disable(); - } -}; - -#endif \ No newline at end of file