From 0cae29880c3b962ee8894336153108ee4184a19b Mon Sep 17 00:00:00 2001
From: Eric Duminil <eric.duminil@gmail.com>
Date: Mon, 28 Dec 2020 12:05:11 +0100
Subject: [PATCH] Arduino IDE can compile even without LMIC library when
 LORAWAN is disabled

---
 config.public.h | 2 +-
 lorawan.cpp     | 2 +-
 lorawan.h       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/config.public.h b/config.public.h
index c7e3ac9..e2c5ed2 100644
--- a/config.public.h
+++ b/config.public.h
@@ -12,7 +12,7 @@
 #  define AMPEL_HTTP    // Should HTTP web server be started?
 #  define AMPEL_MQTT    // Should data be sent over MQTT?
 #  define AMPEL_CSV     // Should data be logged as CSV, on the ESP flash memory?
-// #  define AMPEL_LORAWAN // Should data be sent over LoRaWAN? (Requires ESP32 + LoRa modem)
+// #  define AMPEL_LORAWAN // Should data be sent over LoRaWAN? (Requires ESP32 + LoRa modem, and "MCCI LoRaWAN LMIC library")
 
 /**
  * WIFI
diff --git a/lorawan.cpp b/lorawan.cpp
index 2e6c407..57894c4 100644
--- a/lorawan.cpp
+++ b/lorawan.cpp
@@ -1,5 +1,5 @@
 #include "lorawan.h"
-#if defined(ESP32)
+#if defined(AMPEL_LORAWAN) && defined(ESP32)
 
 namespace config {
   // Values should be defined in config.h
diff --git a/lorawan.h b/lorawan.h
index fe4c9e4..28ec972 100644
--- a/lorawan.h
+++ b/lorawan.h
@@ -1,6 +1,6 @@
 #ifndef AMPEL_LORAWAN_H_
 #define AMPEL_LORAWAN_H_
-#if defined(ESP32)
+#if defined(AMPEL_LORAWAN) && defined(ESP32)
 #include <Arduino.h>
 // Requires "MCCI LoRaWAN LMIC library", which will be automatically used with PlatformIO but should be added in "Arduino IDE".
 // Tested successfully with v3.2.0 and connected to a thethingsnetwork.org app.
-- 
GitLab