Skip to content

Commit

Permalink
cleanup: use HAS_NETWORKING instead of HAS_WIFI || HAS_ETHERNET
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geeksville committed Jun 23, 2024
1 parent 60f46d8 commit 1c5cc64
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/DebugConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.*/

#include "DebugConfiguration.h"

#if HAS_WIFI || HAS_ETHERNET
#if HAS_NETWORKING

Syslog::Syslog(UDP &client)
{
Expand Down
4 changes: 3 additions & 1 deletion src/DebugConfiguration.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -117,7 +119,7 @@
#include <WiFi.h>
#endif // HAS_WIFI

#if HAS_WIFI || HAS_ETHERNET
#if HAS_NETWORKING

class Syslog
{
Expand Down
4 changes: 2 additions & 2 deletions src/RedirectablePrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
NoopPrint noopPrint;

#if HAS_WIFI || HAS_ETHERNET
#if HAS_NETWORKING
extern Syslog syslog;
#endif
void RedirectablePrint::rpInit()
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define HAS_BLUETOOTH 0
#endif

#include "DebugConfiguration.h"
#include "RF95Configuration.h"

#ifndef HW_VENDOR
#error HW_VENDOR must be defined
#endif
Expand Down Expand Up @@ -290,6 +287,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
Expand All @@ -308,4 +308,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef MESHTASTIC_EXCLUDE_SCREEN
#undef HAS_SCREEN
#define HAS_SCREEN 0
#endif
#endif

#include "DebugConfiguration.h"
#include "RF95Configuration.h"
2 changes: 0 additions & 2 deletions src/mqtt/MQTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
#include "mqtt/JSON.h"
#if HAS_WIFI
#include <WiFiClient.h>
#define HAS_NETWORKING 1
#if !defined(ARCH_PORTDUINO)
#include <WiFiClientSecure.h>
#endif
#endif
#if HAS_ETHERNET
#include <EthernetClient.h>
#define HAS_NETWORKING 1
#endif

#ifdef HAS_NETWORKING
Expand Down

0 comments on commit 1c5cc64

Please sign in to comment.