From 8e15be180fbd00778696ce60dea4b967ee4f1e6b Mon Sep 17 00:00:00 2001 From: Eric Duminil <eric.duminil@gmail.com> Date: Mon, 7 Feb 2022 19:54:43 +0100 Subject: [PATCH] Moving all includes to lorawan.cpp web_server is temporarily broken --- ampel-firmware/config.public.h | 5 +---- ampel-firmware/lorawan.cpp | 27 +++++++++++++++++++++++++++ ampel-firmware/lorawan.h | 23 ++--------------------- platformio.ini | 5 ----- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ampel-firmware/config.public.h b/ampel-firmware/config.public.h index 2c9047e..71df084 100644 --- a/ampel-firmware/config.public.h +++ b/ampel-firmware/config.public.h @@ -119,10 +119,7 @@ */ // 1) Requires "MCCI LoRaWAN LMIC library", which will be automatically used with PlatformIO but should be added in "Arduino IDE". -// 2) Region and transceiver type should be specified in: -// * Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h for Arduino IDE -// * platformio.ini for PlatformIO -// See https://github.com/mcci-catena/arduino-lmic#configuration for more information +// 2) If you really want, region and transceiver type can be specified in lorawan.cpp // 3) It has been tested with "TTGO ESP32 SX1276 LoRa 868" and will only work with an ESP32 + LoRa modem // 4) In order to use LoRaWAN, a gateway should be close to the co2ampel, and an account, an application and a device should be registered, // e.g. on https://www.thethingsnetwork.org/docs/applications/ diff --git a/ampel-firmware/lorawan.cpp b/ampel-firmware/lorawan.cpp index 5cb9593..c29b312 100644 --- a/ampel-firmware/lorawan.cpp +++ b/ampel-firmware/lorawan.cpp @@ -6,10 +6,37 @@ #include "sensor_console.h" #include "util.h" +/*** Define region and transceiver type, and ignore the library lmic_project_config.h ***/ +// Those values are probably okay if you're in Europe. +#define ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS +#define CFG_eu868 1 +#define CFG_sx1276_radio 1 +/****************************************************************************************/ + +// 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. +#include <lmic.h> #include <SPI.h> #include <hal/hal.h> #include <arduino_lmic_hal_boards.h> +// Check that a Region was defined +#if defined(CFG_eu868) +# define LMIC_FREQUENCY_PLAN "Europe 868" +#elif defined(CFG_us915) +# define LMIC_FREQUENCY_PLAN "US 915" +#elif defined(CFG_au915) +# define LMIC_FREQUENCY_PLAN "Australia 915" +#elif defined(CFG_as923) +# define LMIC_FREQUENCY_PLAN "Asia 923" +#elif defined(CFG_kr920) +# define LMIC_FREQUENCY_PLAN "Korea 920" +#elif defined(CFG_in866) +# define LMIC_FREQUENCY_PLAN "India 866" +#else +# error "Region should be specified" +#endif + namespace config { // Values should be defined in config.h uint16_t lorawan_sending_interval = LORAWAN_SENDING_INTERVAL; // [s] diff --git a/ampel-firmware/lorawan.h b/ampel-firmware/lorawan.h index d91dacd..2903683 100644 --- a/ampel-firmware/lorawan.h +++ b/ampel-firmware/lorawan.h @@ -3,33 +3,14 @@ #include "config.h" -#if defined(AMPEL_LORAWAN) && defined(ESP32) +# if defined(AMPEL_LORAWAN) && defined(ESP32) #include <stdint.h> // For uint32_t & uint16_t -// 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. -#include <lmic.h> namespace config { extern uint16_t lorawan_sending_interval; // [s] } -#if defined(CFG_eu868) -# define LMIC_FREQUENCY_PLAN "Europe 868" -#elif defined(CFG_us915) -# define LMIC_FREQUENCY_PLAN "US 915" -#elif defined(CFG_au915) -# define LMIC_FREQUENCY_PLAN "Australia 915" -#elif defined(CFG_as923) -# define LMIC_FREQUENCY_PLAN "Asia 923" -#elif defined(CFG_kr920) -# define LMIC_FREQUENCY_PLAN "Korea 920" -#elif defined(CFG_in866) -# define LMIC_FREQUENCY_PLAN "India 866" -#else -# error "Region should be specified" -#endif - namespace lorawan { extern bool waiting_for_confirmation; extern bool connected; @@ -41,5 +22,5 @@ namespace lorawan { void setLoRaInterval(int32_t sending_interval); } -#endif +# endif #endif diff --git a/platformio.ini b/platformio.ini index becf69f..3d016a6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -24,8 +24,3 @@ monitor_speed = 115200 lib_deps = MCCI LoRaWAN LMIC library - -build_flags = - -D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS - -D CFG_eu868=1 - -D CFG_sx1276_radio=1 -- GitLab