Make ArduinoOTA optional

This commit is contained in:
schinken 2022-03-15 17:48:29 +01:00
parent 9217483abc
commit b80294291e
2 changed files with 15 additions and 8 deletions

View file

@ -1,7 +1,10 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <PubSubClient.h> #include <PubSubClient.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include <ArduinoOTA.h>
#ifdef OTA_PASSWORD
#include <ArduinoOTA.h>
#endif
#include "settings.h" #include "settings.h"
@ -37,9 +40,11 @@ void setup() {
mqttClient.setClient(wifiClient); mqttClient.setClient(wifiClient);
mqttClient.setServer(MQTT_HOST, 1883); mqttClient.setServer(MQTT_HOST, 1883);
ArduinoOTA.setHostname(WIFI_HOSTNAME); #ifdef OTA_PASSWORD
ArduinoOTA.setPassword(OTA_PASSWORD); ArduinoOTA.setHostname(WIFI_HOSTNAME);
ArduinoOTA.begin(); ArduinoOTA.setPassword(OTA_PASSWORD);
ArduinoOTA.begin();
#endif
} }
@ -145,5 +150,7 @@ void loop() {
} }
ArduinoOTA.handle(); #ifdef OTA_PASSWORD
ArduinoOTA.handle();
#endif
} }

View file

@ -15,7 +15,7 @@ const char* WIFI_HOSTNAME = "ESP-GeigerCounter";
const char* WIFI_SSID = "xxxxxxxxxx"; const char* WIFI_SSID = "xxxxxxxxxx";
const char* WIFI_PASSWORD = "xxxxxxxxxxx"; const char* WIFI_PASSWORD = "xxxxxxxxxxx";
const char* OTA_PASSWORD = "foobar"; //#define OTA_PASSWORD "foobar"
#define MQTT_HOST "mqtt.xxxxxxxxx.org" #define MQTT_HOST "mqtt.xxxxxxxxx.org"