remove smart pointer from ota

This commit is contained in:
Peter Buchegger 2021-05-21 23:06:13 +02:00
parent b16ea9dd81
commit 7a6473e30e
2 changed files with 7 additions and 8 deletions

View file

@ -11,10 +11,9 @@ OTATask::~OTATask() {
}
bool OTATask::setup(System &system) {
_ota = std::shared_ptr<ArduinoOTAClass>(new ArduinoOTAClass());
_ota->onStart([&]() {
_ota.onStart([&]() {
String type;
if (_ota->getCommand() == U_FLASH)
if (_ota.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";
@ -44,16 +43,16 @@ bool OTATask::setup(System &system) {
else if (error == OTA_END_ERROR)
logPrintlnE("End Failed");
});
_ota->setHostname(system.getUserConfig()->callsign.c_str());
_ota.setHostname(system.getUserConfig()->callsign.c_str());
_stateInfo = "";
return true;
}
bool OTATask::loop(System &system) {
if (!_beginCalled) {
_ota->begin();
_ota.begin();
_beginCalled = true;
}
_ota->handle();
_ota.handle();
return true;
}

View file

@ -13,8 +13,8 @@ public:
virtual bool loop(System &system) override;
private:
std::shared_ptr<ArduinoOTAClass> _ota;
bool _beginCalled;
ArduinoOTAClass _ota;
bool _beginCalled;
};
#endif