From 500630e268860589d5bd0971ec76fb53252731fa Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Tue, 19 Mar 2019 09:29:12 -0700 Subject: [PATCH] Store the init_has_run in the object, not globally --- src/WebOTA.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/WebOTA.cpp b/src/WebOTA.cpp index 9b54b07..9a6bf11 100644 --- a/src/WebOTA.cpp +++ b/src/WebOTA.cpp @@ -2,8 +2,6 @@ #define WEBOTA_VERSION "0.1.5" -bool INIT_RUN = false; - #include "WebOTA.h" #include #include @@ -33,7 +31,8 @@ int WebOTA::init(const unsigned int port, const char *path) { this->port = port; this->path = path; - if (INIT_RUN == true) { + // Only run this once + if (this->init_has_run) { return 0; } @@ -43,7 +42,7 @@ int WebOTA::init(const unsigned int port, const char *path) { Serial.printf("WebOTA url : http://%s.local:%d%s\r\n\r\n", this->mdns.c_str(), port, path); // Store that init has already run - INIT_RUN = true; + this->init_has_run = true; return 1; } @@ -61,7 +60,8 @@ int WebOTA::init() { int WebOTA::handle() { static bool init_run = false; - if (INIT_RUN == false) { + // If we haven't run the init yet run it + if (!this->init_has_run) { WebOTA::init(); }