From 1c5cc64253a8ada23524fa82ee698d4a40b07a56 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 23 Jun 2024 10:29:36 -0700 Subject: [PATCH] cleanup: use HAS_NETWORKING instead of HAS_WIFI || HAS_ETHERNET We already had HAS_NETWORKING as flag in MQTT to mean 'we have tcpip'. Generallize that and move it into configuration.h so that we can use it elsewhere. --- src/DebugConfiguration.cpp | 2 +- src/DebugConfiguration.h | 4 +++- src/RedirectablePrint.cpp | 4 ++-- src/configuration.h | 11 +++++++---- src/mqtt/MQTT.h | 2 -- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/DebugConfiguration.cpp b/src/DebugConfiguration.cpp index 9df402e77b..d9ecd9fe39 100644 --- a/src/DebugConfiguration.cpp +++ b/src/DebugConfiguration.cpp @@ -26,7 +26,7 @@ SOFTWARE.*/ #include "DebugConfiguration.h" -#if HAS_WIFI || HAS_ETHERNET +#if HAS_NETWORKING Syslog::Syslog(UDP &client) { diff --git a/src/DebugConfiguration.h b/src/DebugConfiguration.h index ca908197ed..0b1f4b03b1 100644 --- a/src/DebugConfiguration.h +++ b/src/DebugConfiguration.h @@ -1,6 +1,8 @@ #ifndef SYSLOG_H #define SYSLOG_H +#include "configuration.h" + // DEBUG LED #ifndef LED_INVERTED #define LED_INVERTED 0 // define as 1 if LED is active low (on) @@ -117,7 +119,7 @@ #include #endif // HAS_WIFI -#if HAS_WIFI || HAS_ETHERNET +#if HAS_NETWORKING class Syslog { diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index b77720d85d..f27a8950e4 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -20,7 +20,7 @@ */ NoopPrint noopPrint; -#if HAS_WIFI || HAS_ETHERNET +#if HAS_NETWORKING extern Syslog syslog; #endif void RedirectablePrint::rpInit() @@ -135,7 +135,7 @@ size_t RedirectablePrint::log(const char *logLevel, const char *format, ...) } r += vprintf(format, arg); -#if (HAS_WIFI || HAS_ETHERNET) && !defined(ARCH_PORTDUINO) +#if HAS_NETWORKING && !defined(ARCH_PORTDUINO) // if syslog is in use, collect the log messages and send them to syslog if (syslog.isEnabled()) { int ll = 0; diff --git a/src/configuration.h b/src/configuration.h index 3d10feeaaf..854d3dadfe 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -242,9 +242,6 @@ along with this program. If not, see . #define HAS_BLUETOOTH 0 #endif -#include "DebugConfiguration.h" -#include "RF95Configuration.h" - #ifndef HW_VENDOR #error HW_VENDOR must be defined #endif @@ -290,6 +287,9 @@ along with this program. If not, see . #define HAS_WIFI 0 #endif +// Allow code that needs internet to just check HAS_NETWORKING rather than HAS_WIFI || HAS_ETHERNET +#define HAS_NETWORKING (HAS_WIFI || HAS_ETHERNET) + // // Turn off Bluetooth #ifdef MESHTASTIC_EXCLUDE_BLUETOOTH #undef HAS_BLUETOOTH @@ -308,4 +308,7 @@ along with this program. If not, see . #ifdef MESHTASTIC_EXCLUDE_SCREEN #undef HAS_SCREEN #define HAS_SCREEN 0 -#endif \ No newline at end of file +#endif + +#include "DebugConfiguration.h" +#include "RF95Configuration.h" \ No newline at end of file diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index f2eb6b1204..289f21c36c 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -8,14 +8,12 @@ #include "mqtt/JSON.h" #if HAS_WIFI #include -#define HAS_NETWORKING 1 #if !defined(ARCH_PORTDUINO) #include #endif #endif #if HAS_ETHERNET #include -#define HAS_NETWORKING 1 #endif #ifdef HAS_NETWORKING