Skip to content

Commit

Permalink
OTA needs to be after MDNS
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Nov 11, 2023
1 parent b419b4f commit 11db776
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/Sys/SysModOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,31 @@ class SysModOTA : public SysModule {

public:
SysModOTA() : SysModule("OTA") {
this->isEnabled = false;
this->success = false;
this->success = true;
this->started = false;
};

void connectedChanged() {
if(!SysModules::isConnected) return;
ArduinoOTA.begin();
this->success = true;
this->started = true;
USER_PRINTF("ArduinoOTA.begin()\n");
}

void loop1s() {
ArduinoOTA.handle();
this->isEnabled = true;
void loop() {
if(this->started) {
ArduinoOTA.handle();
}
}

void loop10s() {
if(!this->started) {
USER_PRINTF("ArduinoOTA not started\n");
}
}

private:
bool started;
};

static SysModOTA *ota;
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ void setup() {
mdls->add(print);
mdls->add(web);
mdls->add(net);
mdls->add(ota);
#ifdef APPMOD_LEDS
#ifdef USERMOD_DDP
mdls->add(ddpmod);
Expand All @@ -115,6 +114,7 @@ void setup() {
mdls->add(wledAudioMod);
#endif
mdls->add(mdns); //no ui
mdls->add(ota); // OTA need to be called after MDNS

//do not add mdls itself as it does setup and loop for itself!!! (it is the orchestrator)
mdls->setup();
Expand Down

0 comments on commit 11db776

Please sign in to comment.