Comment-out OTA because broken..

This commit is contained in:
Patrick Balsiger
2019-03-22 09:30:00 +01:00
parent 06c836067e
commit 7083aa70f3
9 changed files with 38 additions and 22 deletions

71
src/OtaTcpPlugin.cpp_ Normal file
View File

@@ -0,0 +1,71 @@
#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