From b80294291e437f40055d57e224f194b311fb7f98 Mon Sep 17 00:00:00 2001 From: schinken Date: Tue, 15 Mar 2022 17:48:29 +0100 Subject: [PATCH] Make ArduinoOTA optional --- esp8266-geigercounter.ino | 21 ++++++++++++++------- settings.h.example | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/esp8266-geigercounter.ino b/esp8266-geigercounter.ino index 40f98c3..330f3e0 100644 --- a/esp8266-geigercounter.ino +++ b/esp8266-geigercounter.ino @@ -1,7 +1,10 @@ #include #include #include -#include + +#ifdef OTA_PASSWORD + #include +#endif #include "settings.h" @@ -36,10 +39,12 @@ void setup() { mqttClient.setClient(wifiClient); mqttClient.setServer(MQTT_HOST, 1883); - - ArduinoOTA.setHostname(WIFI_HOSTNAME); - ArduinoOTA.setPassword(OTA_PASSWORD); - ArduinoOTA.begin(); + + #ifdef OTA_PASSWORD + ArduinoOTA.setHostname(WIFI_HOSTNAME); + ArduinoOTA.setPassword(OTA_PASSWORD); + ArduinoOTA.begin(); + #endif } @@ -144,6 +149,8 @@ void loop() { } } - - ArduinoOTA.handle(); + + #ifdef OTA_PASSWORD + ArduinoOTA.handle(); + #endif } diff --git a/settings.h.example b/settings.h.example index cfc8cd0..d16b207 100644 --- a/settings.h.example +++ b/settings.h.example @@ -15,7 +15,7 @@ const char* WIFI_HOSTNAME = "ESP-GeigerCounter"; const char* WIFI_SSID = "xxxxxxxxxx"; const char* WIFI_PASSWORD = "xxxxxxxxxxx"; -const char* OTA_PASSWORD = "foobar"; +//#define OTA_PASSWORD "foobar" #define MQTT_HOST "mqtt.xxxxxxxxx.org"