Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 5 additions & 6 deletions src/DebugConfiguration.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef SYSLOG_H
#define SYSLOG_H
#pragma once

#include "configuration.h"

// DEBUG LED
#ifndef LED_INVERTED
Expand Down Expand Up @@ -125,7 +126,7 @@
#include <WiFi.h>
#endif // HAS_WIFI

#if HAS_WIFI || HAS_ETHERNET
#if HAS_NETWORKING

class Syslog
{
Expand Down Expand Up @@ -160,6 +161,4 @@ class Syslog
bool vlogf(uint16_t pri, const char *appName, const char *fmt, va_list args) __attribute__((format(printf, 3, 0)));
};

#endif // HAS_ETHERNET || HAS_WIFI

#endif // SYSLOG_H
#endif // HAS_ETHERNET || HAS_WIFI
2 changes: 1 addition & 1 deletion src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#if defined(DEBUG_HEAP_MQTT) && !MESHTASTIC_EXCLUDE_MQTT
#include "mqtt/MQTT.h"
#include "target_specific.h"
#if !MESTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include <WiFi.h>
#endif
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/RedirectablePrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "platform/portduino/PortduinoGlue.h"
#endif

#if HAS_WIFI || HAS_ETHERNET
#if HAS_NETWORKING
extern Syslog syslog;
#endif
void RedirectablePrint::rpInit()
Expand Down Expand Up @@ -137,7 +137,7 @@ void RedirectablePrint::log_to_serial(const char *logLevel, const char *format,

void RedirectablePrint::log_to_syslog(const char *logLevel, const char *format, va_list 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: 1 addition & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <vector>

#ifdef ARCH_ESP32
#if !MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
#endif
#include "modules/esp32/StoreForwardModule.h"
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/http/ContentHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "main.h"
#include "mesh/http/ContentHelper.h"
#include "mesh/http/WebServer.h"
#if !MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
#endif
#include "mqtt/JSON.h"
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/wifi/WiFiAPClient.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "configuration.h"
#if !MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include "NodeDB.h"
#include "RTC.h"
#include "concurrency/Periodic.h"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/AdminModule.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "ProtobufModule.h"
#if HAS_WIFI && !MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
#endif

Expand Down
18 changes: 9 additions & 9 deletions src/mqtt/MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#endif
#include "mesh/generated/meshtastic/remote_hardware.pb.h"
#include "sleep.h"
#if HAS_WIFI && !MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
#include <WiFi.h>
#endif
Expand Down Expand Up @@ -175,7 +175,7 @@ void mqttInit()
new MQTT();
}

#ifdef HAS_NETWORKING
#if HAS_NETWORKING
MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient), mqttQueue(MAX_MQTT_QUEUE)
#else
MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
Expand Down Expand Up @@ -206,7 +206,7 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
moduleConfig.mqtt.map_report_settings.publish_interval_secs, default_map_publish_interval_secs);
}

#ifdef HAS_NETWORKING
#if HAS_NETWORKING
if (!moduleConfig.mqtt.proxy_to_client_enabled)
pubSub.setCallback(mqttCallback);
#endif
Expand All @@ -226,7 +226,7 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)

bool MQTT::isConnectedDirectly()
{
#ifdef HAS_NETWORKING
#if HAS_NETWORKING
return pubSub.connected();
#else
return false;
Expand All @@ -244,7 +244,7 @@ bool MQTT::publish(const char *topic, const char *payload, bool retained)
service.sendMqttMessageToClientProxy(msg);
return true;
}
#ifdef HAS_NETWORKING
#if HAS_NETWORKING
else if (isConnectedDirectly()) {
return pubSub.publish(topic, payload, retained);
}
Expand All @@ -264,7 +264,7 @@ bool MQTT::publish(const char *topic, const uint8_t *payload, size_t length, boo
service.sendMqttMessageToClientProxy(msg);
return true;
}
#ifdef HAS_NETWORKING
#if HAS_NETWORKING
else if (isConnectedDirectly()) {
return pubSub.publish(topic, payload, length, retained);
}
Expand All @@ -284,7 +284,7 @@ void MQTT::reconnect()
publishStatus();
return; // Don't try to connect directly to the server
}
#ifdef HAS_NETWORKING
#if HAS_NETWORKING
// Defaults
int serverPort = 1883;
const char *serverAddr = default_mqtt_address;
Expand Down Expand Up @@ -357,7 +357,7 @@ void MQTT::reconnect()

void MQTT::sendSubscriptions()
{
#ifdef HAS_NETWORKING
#if HAS_NETWORKING
size_t numChan = channels.getNumChannels();
for (size_t i = 0; i < numChan; i++) {
const auto &ch = channels.getByIndex(i);
Expand Down Expand Up @@ -396,7 +396,7 @@ bool MQTT::wantsLink() const

int32_t MQTT::runOnce()
{
#ifdef HAS_NETWORKING
#if HAS_NETWORKING
if (!moduleConfig.mqtt.enabled || !(moduleConfig.mqtt.map_reporting_enabled || channels.anyMqttEnabled()))
return disable();

Expand Down
6 changes: 2 additions & 4 deletions src/mqtt/MQTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
#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
#if HAS_NETWORKING
#include <PubSubClient.h>
#endif

Expand All @@ -43,7 +41,7 @@ class MQTT : private concurrency::OSThread
#endif

public:
#ifdef HAS_NETWORKING
#if HAS_NETWORKING
PubSubClient pubSub;
#endif
MQTT();
Expand Down
29 changes: 14 additions & 15 deletions src/platform/esp32/main-esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "nimble/NimbleBluetooth.h"
#endif

#if !MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
#endif

Expand All @@ -24,23 +24,22 @@
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
void setBluetoothEnable(bool enable)
{
#ifndef MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
if (!isWifiAvailable() && config.bluetooth.enabled == true)
#else
if (config.bluetooth.enabled == true)
#endif
#ifdef MESHTASTIC_EXCLUDE_WIFI
if (config.bluetooth.enabled == true)
#endif
{
if (!nimbleBluetooth) {
nimbleBluetooth = new NimbleBluetooth();
}
if (enable && !nimbleBluetooth->isActive()) {
nimbleBluetooth->setup();
}
// For ESP32, no way to recover from bluetooth shutdown without reboot
// BLE advertising automatically stops when MCU enters light-sleep(?)
// For deep-sleep, shutdown hardware with nimbleBluetooth->deinit(). Requires reboot to reverse
{
if (!nimbleBluetooth) {
nimbleBluetooth = new NimbleBluetooth();
}
if (enable && !nimbleBluetooth->isActive()) {
nimbleBluetooth->setup();
}
// For ESP32, no way to recover from bluetooth shutdown without reboot
// BLE advertising automatically stops when MCU enters light-sleep(?)
// For deep-sleep, shutdown hardware with nimbleBluetooth->deinit(). Requires reboot to reverse
}
}
#else
void setBluetoothEnable(bool enable) {}
Expand Down
4 changes: 2 additions & 2 deletions src/sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifdef ARCH_ESP32
#include "esp32/pm.h"
#include "esp_pm.h"
#if !MESHTASTIC_EXCLUDE_WIFI
#if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h"
#endif
#include "rom/rtc.h"
Expand Down Expand Up @@ -56,7 +56,7 @@ RTC_DATA_ATTR int bootCount = 0;
*/
void setCPUFast(bool on)
{
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WIFI
#if defined(ARCH_ESP32) && HAS_WIFI

if (isWifiAvailable()) {
/*
Expand Down