diff --git a/src/Sys/SysModOTA.h b/src/Sys/SysModOTA.h new file mode 100644 index 00000000..e723b1a5 --- /dev/null +++ b/src/Sys/SysModOTA.h @@ -0,0 +1,35 @@ +/* + @title StarMod + @file SysModOTA.h + @date 20231111 + @repo https://github.com/ewowi/StarMod + @Authors https://github.com/ewowi/StarMod/commits/main + @Copyright (c) 2023 Github StarMod Commit Authors + @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 + */ + +#include "SysModule.h" + +#include + +class SysModOTA : public SysModule { + +public: + SysModOTA() : SysModule("OTA") { + this->isEnabled = false; + this->success = false; + }; + + void connectedChanged() { + if(!SysModules::isConnected) return; + ArduinoOTA.begin(); + this->success = true; + } + + void loop1s() { + ArduinoOTA.handle(); + this->isEnabled = true; + } +}; + +static SysModOTA *ota; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e5a1161a..6afb8b8d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,7 @@ #include "Sys/SysModModel.h" #include "Sys/SysModNetwork.h" #include "Sys/SysModPins.h" +#include "Sys/SysModOTA.h" #include "User/UserModInstances.h" #include "User/UserModMDNS.h" #ifdef APPMOD_LEDS @@ -56,6 +57,7 @@ void setup() { ui = new SysModUI(); sys = new SysModSystem(); pins = new SysModPins(); + ota = new SysModOTA(); instances = new UserModInstances(); mdns = new UserModMDNS(); #ifdef APPMOD_LEDS @@ -92,6 +94,7 @@ void setup() { mdls->add(print); mdls->add(web); mdls->add(net); + mdls->add(ota); #ifdef APPMOD_LEDS #ifdef USERMOD_DDP mdls->add(ddpmod);