replace #ifdef with #if to streamline feature setting

This commit is contained in:
Oliver Brandmueller 2019-03-11 18:09:01 +01:00
parent 8c58fa04a7
commit 4a7525efcb
24 changed files with 84 additions and 71 deletions

View File

@ -5,9 +5,11 @@
#include "senddata.h" #include "senddata.h"
#include "rcommand.h" #include "rcommand.h"
#include "spislave.h" #include "spislave.h"
#if(HAS_LORA)
#include <lmic.h> #include <lmic.h>
#endif
#ifdef HAS_BME #if(HAS_BME)
#include "bme680mems.h" #include "bme680mems.h"
#endif #endif

View File

@ -123,15 +123,15 @@ extern time_t userUTCTime;
#include "payload.h" #include "payload.h"
#include "blescan.h" #include "blescan.h"
#ifdef HAS_GPS #if(HAS_GPS)
#include "gpsread.h" #include "gpsread.h"
#endif #endif
#ifdef HAS_LORA #if(HAS_LORA)
#include "lorawan.h" #include "lorawan.h"
#endif #endif
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
#include "display.h" #include "display.h"
#endif #endif
@ -147,11 +147,11 @@ extern time_t userUTCTime;
#include "antenna.h" #include "antenna.h"
#endif #endif
#ifdef HAS_SENSORS #if(HAS_SENSORS)
#include "sensor.h" #include "sensor.h"
#endif #endif
#ifdef HAS_BME #if(HAS_BME)
#include "bme680mems.h" #include "bme680mems.h"
#endif #endif

View File

@ -14,7 +14,7 @@
void irqHandler(void *pvParameters); void irqHandler(void *pvParameters);
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
#include "display.h" #include "display.h"
void IRAM_ATTR DisplayIRQ(); void IRAM_ATTR DisplayIRQ();
#endif #endif

View File

@ -16,6 +16,8 @@
#include "irqhandler.h" #include "irqhandler.h"
#include "led.h" #include "led.h"
#include "spislave.h" #include "spislave.h"
#if(HAS_LORA)
#include "lorawan.h" #include "lorawan.h"
#endif
#include "timekeeper.h" #include "timekeeper.h"
#endif #endif

View File

@ -18,7 +18,7 @@ void start_ota_update();
int version_compare(const String v1, const String v2); int version_compare(const String v1, const String v2);
void display(const uint8_t row, const std::string status, void display(const uint8_t row, const std::string status,
const std::string msg); const std::string msg);
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
void show_progress(unsigned long current, unsigned long size); void show_progress(unsigned long current, unsigned long size);
#endif #endif

View File

@ -4,7 +4,9 @@
#include "senddata.h" #include "senddata.h"
#include "cyclic.h" #include "cyclic.h"
#include "configmanager.h" #include "configmanager.h"
#if(HAS_LORA)
#include "lorawan.h" #include "lorawan.h"
#endif
#include "macsniff.h" #include "macsniff.h"
#include <rom/rtc.h> #include <rom/rtc.h>
#include "cyclic.h" #include "cyclic.h"

View File

@ -2,7 +2,9 @@
#define _SENDDATA_H #define _SENDDATA_H
#include "spislave.h" #include "spislave.h"
#if(HAS_LORA)
#include "lorawan.h" #include "lorawan.h"
#endif
#include "cyclic.h" #include "cyclic.h"
extern Ticker sendcycler; extern Ticker sendcycler;

View File

@ -6,7 +6,7 @@
#include "TimeLib.h" #include "TimeLib.h"
#include "irqhandler.h" #include "irqhandler.h"
#ifdef HAS_GPS #if(HAS_GPS)
#include "gpsread.h" #include "gpsread.h"
#endif #endif
#ifdef HAS_IF482 #ifdef HAS_IF482

View File

@ -1,4 +1,4 @@
#ifdef HAS_BME #if(HAS_BME)
#include "bme680mems.h" #include "bme680mems.h"
@ -103,7 +103,7 @@ void bme_loop(void *pvParameters) {
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
#ifdef HAS_BME #if(HAS_BME)
while (1) { while (1) {
// block i2c bus access // block i2c bus access
if (I2C_MUTEX_LOCK()) { if (I2C_MUTEX_LOCK()) {

View File

@ -24,7 +24,7 @@ void doHousekeeping() {
#ifdef HAS_SPI #ifdef HAS_SPI
spi_housekeeping(); spi_housekeeping();
#endif #endif
#ifdef HAS_LORA #if(HAS_LORA)
lora_housekeeping(); lora_housekeeping();
#endif #endif
@ -32,11 +32,11 @@ void doHousekeeping() {
ESP_LOGD(TAG, "IRQhandler %d bytes left | Taskstate = %d", ESP_LOGD(TAG, "IRQhandler %d bytes left | Taskstate = %d",
uxTaskGetStackHighWaterMark(irqHandlerTask), uxTaskGetStackHighWaterMark(irqHandlerTask),
eTaskGetState(irqHandlerTask)); eTaskGetState(irqHandlerTask));
#ifdef HAS_GPS #if(HAS_GPS)
ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d", ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d",
uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask)); uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask));
#endif #endif
#ifdef HAS_BME #if(HAS_BME)
ESP_LOGD(TAG, "Bmeloop %d bytes left | Taskstate = %d", ESP_LOGD(TAG, "Bmeloop %d bytes left | Taskstate = %d",
uxTaskGetStackHighWaterMark(BmeTask), eTaskGetState(BmeTask)); uxTaskGetStackHighWaterMark(BmeTask), eTaskGetState(BmeTask));
#endif #endif
@ -58,7 +58,7 @@ void doHousekeeping() {
#endif #endif
// display BME sensor data // display BME sensor data
#ifdef HAS_BME #if(HAS_BME)
ESP_LOGI(TAG, "BME680 Temp: %.2f°C | IAQ: %.2f | IAQacc: %d", ESP_LOGI(TAG, "BME680 Temp: %.2f°C | IAQ: %.2f | IAQacc: %d",
bme_status.temperature, bme_status.iaq, bme_status.iaq_accuracy); bme_status.temperature, bme_status.iaq, bme_status.iaq_accuracy);
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
/* /*
@ -105,7 +105,7 @@ void init_display(const char *Productname, const char *Version) {
u8x8.print(" v"); u8x8.print(" v");
u8x8.println(PROGVERSION); u8x8.println(PROGVERSION);
#ifdef HAS_LORA #if(HAS_LORA)
u8x8.println("DEVEUI:"); u8x8.println("DEVEUI:");
os_getDevEui((u1_t *)buf); os_getDevEui((u1_t *)buf);
DisplayKey(buf, 8, true); DisplayKey(buf, 8, true);
@ -163,7 +163,7 @@ void refreshtheDisplay() {
#endif #endif
// update GPS status (line 2) // update GPS status (line 2)
#ifdef HAS_GPS #if(HAS_GPS)
// have we ever got valid gps data? // have we ever got valid gps data?
if (gps.passedChecksum() > 0) { if (gps.passedChecksum() > 0) {
u8x8.setCursor(9, 2); u8x8.setCursor(9, 2);
@ -186,7 +186,7 @@ void refreshtheDisplay() {
u8x8.printf("%s", "BLTH:off"); u8x8.printf("%s", "BLTH:off");
#endif #endif
#ifdef HAS_LORA #if(HAS_LORA)
u8x8.setCursor(11, 3); u8x8.setCursor(11, 3);
u8x8.printf("SF:"); u8x8.printf("SF:");
if (cfg.adrmode) // if ADR=on then display SF value inverse if (cfg.adrmode) // if ADR=on then display SF value inverse
@ -209,7 +209,7 @@ void refreshtheDisplay() {
u8x8.setCursor(10, 5); u8x8.setCursor(10, 5);
u8x8.printf("%4dKB", getFreeRAM() / 1024); u8x8.printf("%4dKB", getFreeRAM() / 1024);
#ifdef HAS_LORA #if(HAS_LORA)
u8x8.setCursor(0, 6); u8x8.setCursor(0, 6);
#if (!defined HAS_DCF77) && (!defined HAS_IF482) #if (!defined HAS_DCF77) && (!defined HAS_IF482)
// update LoRa status display (line 6) // update LoRa status display (line 6)

View File

@ -1,4 +1,4 @@
#ifdef HAS_GPS #if(HAS_GPS)
#include "globals.h" #include "globals.h"

View File

@ -7,6 +7,7 @@
// Hardware related definitions for lolin32lite (without LoRa shield) // Hardware related definitions for lolin32lite (without LoRa shield)
#define HAS_LORA 0 // no LoRa module
#define CFG_sx1272_radio 1 // dummy #define CFG_sx1272_radio 1 // dummy
#define HAS_LED LED_BUILTIN // on board LED on GPIO5 #define HAS_LED LED_BUILTIN // on board LED on GPIO5
#define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW #define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW

View File

@ -24,7 +24,7 @@ void irqHandler(void *pvParameters) {
#endif #endif
// display needs refresh? // display needs refresh?
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
if (InterruptStatus & DISPLAY_IRQ) if (InterruptStatus & DISPLAY_IRQ)
refreshtheDisplay(); refreshtheDisplay();
#endif #endif
@ -49,7 +49,7 @@ void irqHandler(void *pvParameters) {
// esp32 hardware timer triggered interrupt service routines // esp32 hardware timer triggered interrupt service routines
// they notify the irq handler task // they notify the irq handler task
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
void IRAM_ATTR DisplayIRQ() { void IRAM_ATTR DisplayIRQ() {
BaseType_t xHigherPriorityTaskWoken; BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE; xHigherPriorityTaskWoken = pdFALSE;

View File

@ -137,7 +137,7 @@ void ledLoop(void *parameter) {
// No custom blink, check LoRaWAN state // No custom blink, check LoRaWAN state
} else { } else {
#ifdef HAS_LORA #if(HAS_LORA)
// LED indicators for viusalizing LoRaWAN state // LED indicators for viusalizing LoRaWAN state
if (LMIC.opmode & (OP_JOINING | OP_REJOIN)) { if (LMIC.opmode & (OP_JOINING | OP_REJOIN)) {
LEDColor = COLOR_YELLOW; LEDColor = COLOR_YELLOW;

View File

@ -1,4 +1,4 @@
#ifdef HAS_LORA #if(HAS_LORA)
/************************************************************ /************************************************************
* LMIC LoRaWAN configuration * LMIC LoRaWAN configuration

View File

@ -1,10 +1,12 @@
// Basic Config // Basic Config
#if(HAS_LORA)
#include "lorawan.h" #include "lorawan.h"
#endif
// Local logging Tag // Local logging Tag
static const char TAG[] = "lora"; static const char TAG[] = "lora";
#ifdef HAS_LORA #if(HAS_LORA)
#if CLOCK_ERROR_PROCENTAGE > 7 #if CLOCK_ERROR_PROCENTAGE > 7
#warning CLOCK_ERROR_PROCENTAGE value in lmic_config.h is too high; values > 7 will cause side effects #warning CLOCK_ERROR_PROCENTAGE value in lmic_config.h is too high; values > 7 will cause side effects

View File

@ -155,7 +155,7 @@ void setup() {
ESP.getFlashChipSpeed()); ESP.getFlashChipSpeed());
ESP_LOGI(TAG, "Wifi/BT software coexist version %s", esp_coex_version_get()); ESP_LOGI(TAG, "Wifi/BT software coexist version %s", esp_coex_version_get());
#ifdef HAS_LORA #if(HAS_LORA)
ESP_LOGI(TAG, "IBM LMIC version %d.%d.%d", LMIC_VERSION_MAJOR, ESP_LOGI(TAG, "IBM LMIC version %d.%d.%d", LMIC_VERSION_MAJOR,
LMIC_VERSION_MINOR, LMIC_VERSION_BUILD); LMIC_VERSION_MINOR, LMIC_VERSION_BUILD);
ESP_LOGI(TAG, "Arduino LMIC version %d.%d.%d.%d", ESP_LOGI(TAG, "Arduino LMIC version %d.%d.%d.%d",
@ -167,7 +167,7 @@ void setup() {
showLoraKeys(); showLoraKeys();
#endif // HAS_LORA #endif // HAS_LORA
#ifdef HAS_GPS #if(HAS_GPS)
ESP_LOGI(TAG, "TinyGPS+ version %s", TinyGPSPlus::libraryVersion()); ESP_LOGI(TAG, "TinyGPS+ version %s", TinyGPSPlus::libraryVersion());
#endif #endif
@ -269,7 +269,7 @@ void setup() {
#endif // HAS_BUTTON #endif // HAS_BUTTON
// initialize gps // initialize gps
#ifdef HAS_GPS #if(HAS_GPS)
strcat_P(features, " GPS"); strcat_P(features, " GPS");
if (gps_init()) { if (gps_init()) {
ESP_LOGI(TAG, "Starting GPS Feed..."); ESP_LOGI(TAG, "Starting GPS Feed...");
@ -284,13 +284,13 @@ void setup() {
#endif #endif
// initialize sensors // initialize sensors
#ifdef HAS_SENSORS #if(HAS_SENSORS)
strcat_P(features, " SENS"); strcat_P(features, " SENS");
sensor_init(); sensor_init();
#endif #endif
// initialize LoRa // initialize LoRa
#ifdef HAS_LORA #if(HAS_LORA)
strcat_P(features, " LORA"); strcat_P(features, " LORA");
assert(lora_stack_init() == ESP_OK); assert(lora_stack_init() == ESP_OK);
#endif #endif
@ -306,7 +306,7 @@ void setup() {
#endif #endif
// initialize display // initialize display
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
strcat_P(features, " OLED"); strcat_P(features, " OLED");
DisplayState = cfg.screenon; DisplayState = cfg.screenon;
init_display(PRODUCTNAME, PROGVERSION); // note: blocking call init_display(PRODUCTNAME, PROGVERSION); // note: blocking call
@ -359,7 +359,7 @@ void setup() {
1); // CPU core 1); // CPU core
// initialize bme // initialize bme
#ifdef HAS_BME #if(HAS_BME)
strcat_P(features, " BME"); strcat_P(features, " BME");
if (bme_init()) { if (bme_init()) {
ESP_LOGI(TAG, "Starting BME sensor..."); ESP_LOGI(TAG, "Starting BME sensor...");
@ -378,7 +378,7 @@ void setup() {
ESP_LOGI(TAG, "Starting Timers..."); ESP_LOGI(TAG, "Starting Timers...");
// display interrupt // display interrupt
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
// https://techtutorialsx.com/2017/10/07/esp32-arduino-timer-interrupts/ // https://techtutorialsx.com/2017/10/07/esp32-arduino-timer-interrupts/
// prescaler 80 -> divides 80 MHz CPU freq to 1 MHz, timer 0, count up // prescaler 80 -> divides 80 MHz CPU freq to 1 MHz, timer 0, count up
displayIRQ = timerBegin(0, 80, true); displayIRQ = timerBegin(0, 80, true);
@ -421,7 +421,7 @@ void setup() {
void loop() { void loop() {
while (1) { while (1) {
#ifdef HAS_LORA #if(HAS_LORA)
os_runloop_once(); // execute lmic scheduled jobs and events os_runloop_once(); // execute lmic scheduled jobs and events
#endif #endif
delay(2); // yield to CPU delay(2); // yield to CPU

View File

@ -48,7 +48,7 @@ void start_ota_update() {
switch_LED(LED_ON); switch_LED(LED_ON);
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
u8x8.begin(); u8x8.begin();
u8x8.setFont(u8x8_font_chroma48medium8_r); u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.clear(); u8x8.clear();
@ -266,7 +266,7 @@ int do_ota_update() {
goto abort; goto abort;
} }
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
// register callback function for showing progress while streaming data // register callback function for showing progress while streaming data
Update.onProgress(&show_progress); Update.onProgress(&show_progress);
#endif #endif
@ -309,7 +309,7 @@ retry:
void display(const uint8_t row, const std::string status, void display(const uint8_t row, const std::string status,
const std::string msg) { const std::string msg) {
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
u8x8.setCursor(14, row); u8x8.setCursor(14, row);
u8x8.print((status.substr(0, 2)).c_str()); u8x8.print((status.substr(0, 2)).c_str());
if (!msg.empty()) { if (!msg.empty()) {
@ -320,7 +320,7 @@ void display(const uint8_t row, const std::string status,
#endif #endif
} }
#ifdef HAS_DISPLAY #if(HAS_DISPLAY)
// callback function to show download progress while streaming data // callback function to show download progress while streaming data
void show_progress(unsigned long current, unsigned long size) { void show_progress(unsigned long current, unsigned long size) {
char buf[17]; char buf[17];

View File

@ -78,7 +78,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp,
} }
void PayloadConvert::addGPS(gpsStatus_t value) { void PayloadConvert::addGPS(gpsStatus_t value) {
#ifdef HAS_GPS #if(HAS_GPS)
buffer[cursor++] = (byte)((value.latitude & 0xFF000000) >> 24); buffer[cursor++] = (byte)((value.latitude & 0xFF000000) >> 24);
buffer[cursor++] = (byte)((value.latitude & 0x00FF0000) >> 16); buffer[cursor++] = (byte)((value.latitude & 0x00FF0000) >> 16);
buffer[cursor++] = (byte)((value.latitude & 0x0000FF00) >> 8); buffer[cursor++] = (byte)((value.latitude & 0x0000FF00) >> 8);
@ -96,7 +96,7 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
} }
void PayloadConvert::addSensor(uint8_t buf[]) { void PayloadConvert::addSensor(uint8_t buf[]) {
#ifdef HAS_SENSORS #if(HAS_SENSORS)
uint8_t length = buf[0]; uint8_t length = buf[0];
memcpy(buffer, buf + 1, length); memcpy(buffer, buf + 1, length);
cursor += length; // length of buffer cursor += length; // length of buffer
@ -104,7 +104,7 @@ void PayloadConvert::addSensor(uint8_t buf[]) {
} }
void PayloadConvert::addBME(bmeStatus_t value) { void PayloadConvert::addBME(bmeStatus_t value) {
#ifdef HAS_BME #if(HAS_BME)
int16_t temperature = (int16_t)(value.temperature); // float -> int int16_t temperature = (int16_t)(value.temperature); // float -> int
uint16_t humidity = (uint16_t)(value.humidity); // float -> int uint16_t humidity = (uint16_t)(value.humidity); // float -> int
uint16_t pressure = (uint16_t)(value.pressure); // float -> int uint16_t pressure = (uint16_t)(value.pressure); // float -> int
@ -187,7 +187,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp,
} }
void PayloadConvert::addGPS(gpsStatus_t value) { void PayloadConvert::addGPS(gpsStatus_t value) {
#ifdef HAS_GPS #if(HAS_GPS)
writeLatLng(value.latitude, value.longitude); writeLatLng(value.latitude, value.longitude);
writeUint8(value.satellites); writeUint8(value.satellites);
writeUint16(value.hdop); writeUint16(value.hdop);
@ -196,7 +196,7 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
} }
void PayloadConvert::addSensor(uint8_t buf[]) { void PayloadConvert::addSensor(uint8_t buf[]) {
#ifdef HAS_SENSORS #if(HAS_SENSORS)
uint8_t length = buf[0]; uint8_t length = buf[0];
memcpy(buffer, buf + 1, length); memcpy(buffer, buf + 1, length);
cursor += length; // length of buffer cursor += length; // length of buffer
@ -204,7 +204,7 @@ void PayloadConvert::addSensor(uint8_t buf[]) {
} }
void PayloadConvert::addBME(bmeStatus_t value) { void PayloadConvert::addBME(bmeStatus_t value) {
#ifdef HAS_BME #if(HAS_BME)
writeFloat(value.temperature); writeFloat(value.temperature);
writePressure(value.pressure); writePressure(value.pressure);
writeUFloat(value.humidity); writeUFloat(value.humidity);
@ -375,7 +375,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius,
} }
void PayloadConvert::addGPS(gpsStatus_t value) { void PayloadConvert::addGPS(gpsStatus_t value) {
#ifdef HAS_GPS #if(HAS_GPS)
int32_t lat = value.latitude / 100; int32_t lat = value.latitude / 100;
int32_t lon = value.longitude / 100; int32_t lon = value.longitude / 100;
int32_t alt = value.altitude * 100; int32_t alt = value.altitude * 100;
@ -396,7 +396,7 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
} }
void PayloadConvert::addSensor(uint8_t buf[]) { void PayloadConvert::addSensor(uint8_t buf[]) {
#ifdef HAS_SENSORS #if(HAS_SENSORS)
// to come // to come
/* /*
uint8_t length = buf[0]; uint8_t length = buf[0];
@ -407,7 +407,7 @@ void PayloadConvert::addSensor(uint8_t buf[]) {
} }
void PayloadConvert::addBME(bmeStatus_t value) { void PayloadConvert::addBME(bmeStatus_t value) {
#ifdef HAS_BME #if(HAS_BME)
// data value conversions to meet cayenne data type definition // data value conversions to meet cayenne data type definition
// 0.1°C per bit => -3276,7 .. +3276,7 °C // 0.1°C per bit => -3276,7 .. +3276,7 °C

View File

@ -8,7 +8,9 @@ static const char TAG[] = __FILE__;
// helper function // helper function
void do_reset() { void do_reset() {
ESP_LOGI(TAG, "Remote command: restart device"); ESP_LOGI(TAG, "Remote command: restart device");
#if(HAS_LORA)
LMIC_shutdown(); LMIC_shutdown();
#endif
delay(3000); delay(3000);
esp_restart(); esp_restart();
} }
@ -130,7 +132,7 @@ void set_gps(uint8_t val[]) {
} }
void set_sensor(uint8_t val[]) { void set_sensor(uint8_t val[]) {
#ifdef HAS_SENSORS #if(HAS_SENSORS)
switch (val[0]) { // check if valid sensor number 1...4 switch (val[0]) { // check if valid sensor number 1...4
case 1: case 1:
case 2: case 2:
@ -168,7 +170,7 @@ void set_monitor(uint8_t val[]) {
} }
void set_lorasf(uint8_t val[]) { void set_lorasf(uint8_t val[]) {
#ifdef HAS_LORA #if(HAS_LORA)
ESP_LOGI(TAG, "Remote command: set LoRa SF to %d", val[0]); ESP_LOGI(TAG, "Remote command: set LoRa SF to %d", val[0]);
switch_lora(val[0], cfg.txpower); switch_lora(val[0], cfg.txpower);
#else #else
@ -177,7 +179,7 @@ void set_lorasf(uint8_t val[]) {
} }
void set_loraadr(uint8_t val[]) { void set_loraadr(uint8_t val[]) {
#ifdef HAS_LORA #if(HAS_LORA)
ESP_LOGI(TAG, "Remote command: set LoRa ADR mode to %s", ESP_LOGI(TAG, "Remote command: set LoRa ADR mode to %s",
val[0] ? "on" : "off"); val[0] ? "on" : "off");
cfg.adrmode = val[0] ? 1 : 0; cfg.adrmode = val[0] ? 1 : 0;
@ -220,7 +222,7 @@ void set_rgblum(uint8_t val[]) {
}; };
void set_lorapower(uint8_t val[]) { void set_lorapower(uint8_t val[]) {
#ifdef HAS_LORA #if(HAS_LORA)
ESP_LOGI(TAG, "Remote command: set LoRa TXPOWER to %d", val[0]); ESP_LOGI(TAG, "Remote command: set LoRa TXPOWER to %d", val[0]);
switch_lora(cfg.lorasf, val[0]); switch_lora(cfg.lorasf, val[0]);
#else #else
@ -250,7 +252,7 @@ void get_status(uint8_t val[]) {
void get_gps(uint8_t val[]) { void get_gps(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: get gps status"); ESP_LOGI(TAG, "Remote command: get gps status");
#ifdef HAS_GPS #if(HAS_GPS)
gps_read(); gps_read();
payload.reset(); payload.reset();
payload.addGPS(gps_status); payload.addGPS(gps_status);
@ -262,7 +264,7 @@ void get_gps(uint8_t val[]) {
void get_bme(uint8_t val[]) { void get_bme(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: get bme680 sensor data"); ESP_LOGI(TAG, "Remote command: get bme680 sensor data");
#ifdef HAS_BME #if(HAS_BME)
payload.reset(); payload.reset();
payload.addBME(bme_status); payload.addBME(bme_status);
SendPayload(BMEPORT, prio_high); SendPayload(BMEPORT, prio_high);

View File

@ -39,7 +39,7 @@ void SendPayload(uint8_t port, sendprio_t prio) {
memcpy(SendBuffer.Message, payload.getBuffer(), payload.getSize()); memcpy(SendBuffer.Message, payload.getBuffer(), payload.getSize());
// enqueue message in device's send queues // enqueue message in device's send queues
#ifdef HAS_LORA #if(HAS_LORA)
lora_enqueuedata(&SendBuffer, prio); lora_enqueuedata(&SendBuffer, prio);
#endif #endif
#ifdef HAS_SPI #ifdef HAS_SPI
@ -63,7 +63,7 @@ void sendCounter() {
if (cfg.blescan) if (cfg.blescan)
payload.addCount(macs_ble, MAC_SNIFF_BLE); payload.addCount(macs_ble, MAC_SNIFF_BLE);
#ifdef HAS_GPS #if(HAS_GPS)
if (gps.location.isValid()) { // send GPS position only if we have a fix if (gps.location.isValid()) { // send GPS position only if we have a fix
gps_read(); gps_read();
payload.addGPS(gps_status); payload.addGPS(gps_status);
@ -83,7 +83,7 @@ void sendCounter() {
} }
break; break;
#ifdef HAS_BME #if(HAS_BME)
case MEMS_DATA: case MEMS_DATA:
payload.reset(); payload.reset();
payload.addBME(bme_status); payload.addBME(bme_status);
@ -91,7 +91,7 @@ void sendCounter() {
break; break;
#endif #endif
#ifdef HAS_GPS #if(HAS_GPS)
case GPS_DATA: case GPS_DATA:
// send GPS position only if we have a fix // send GPS position only if we have a fix
if (gps.location.isValid()) { if (gps.location.isValid()) {
@ -104,7 +104,7 @@ void sendCounter() {
break; break;
#endif #endif
#ifdef HAS_SENSORS #if(HAS_SENSORS)
case SENSOR1_DATA: case SENSOR1_DATA:
payload.reset(); payload.reset();
payload.addSensor(sensor_read(1)); payload.addSensor(sensor_read(1));
@ -138,7 +138,7 @@ void sendCounter() {
} // sendCounter() } // sendCounter()
void flushQueues() { void flushQueues() {
#ifdef HAS_LORA #if(HAS_LORA)
lora_queuereset(); lora_queuereset();
#endif #endif
#ifdef HAS_SPI #ifdef HAS_SPI

View File

@ -14,7 +14,7 @@ time_t timeProvider(void) {
time_t t = 0; time_t t = 0;
#ifdef HAS_GPS #if(HAS_GPS)
t = get_gpstime(); // fetch recent time from last NEMA record t = get_gpstime(); // fetch recent time from last NEMA record
if (t) { if (t) {
#ifdef HAS_RTC #ifdef HAS_RTC
@ -39,7 +39,7 @@ time_t timeProvider(void) {
#if(DBTIMESYNC) #if(DBTIMESYNC)
send_DBtime_req(); send_DBtime_req();
// kick off asychronous lora sync if we have // kick off asychronous lora sync if we have
#elif defined HAS_LORA && (TIME_SYNC_LORA) #elif (HAS_LORA) && (TIME_SYNC_LORA)
LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime); LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime);
#endif #endif