Start webserver only in standalone-mode

This commit is contained in:
Ollo 2021-11-28 14:27:14 +01:00
parent 81adc9bd61
commit 41ebed2b27

View File

@ -97,7 +97,7 @@ void log(int level, String message, int code);
bool mConfigured = false;
bool mConnected = false;
bool mFailedI2Cinitialization = false;
AsyncWebServer* mHttp;
AsyncWebServer* mHttp = NULL;
/******************************* Sensor data **************************/
HomieNode particle(NODE_PARTICLE, "particle", "number"); /**< Measuret in micro gram per quibik meter air volume */
@ -209,7 +209,7 @@ void onHomieEvent(const HomieEvent &event)
digitalWrite(WITTY_RGB_B, LOW);
strip.fill(strip.Color(0,0,128));
strip.show();
if (String(Homie.getConfiguration().mqtt.server.host).equals(MQTT_DUMMYHOST)) {
if (mHttp != NULL) {
strip.fill(strip.Color(0,64,0));
mConnectedNonMQTT = true;
}
@ -459,12 +459,6 @@ void setup()
for (int i=0;i < (PIXEL_COUNT / 2); i++) {
strip.setPixelColor(0, strip.Color(0,128,0));
}
} else {
for (int i=0;i < (PIXEL_COUNT / 2); i++) {
strip.setPixelColor(0, strip.Color(0,0,128));
}
}
strip.show();
mHttp = new AsyncWebServer(80);
mHttp->on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/plain", String(ESP.getFreeHeap()));
@ -475,6 +469,12 @@ void setup()
mHttp->serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm");
mHttp->begin();
Homie.getLogger() << "Webserver started" << endl;
} else {
for (int i=0;i < (PIXEL_COUNT / 2); i++) {
strip.setPixelColor(0, strip.Color(0,0,128));
}
}
strip.show();
digitalWrite(WITTY_RGB_B, HIGH);
} else {
strip.fill(strip.Color(128,0,0));