From fa5e053e30a92737b9da5d378e4d09232b3808bd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 25 Jul 2025 13:32:17 -0500 Subject: [PATCH] Try macro exclusion --- src/mqtt/MQTT.cpp | 4 ++++ test/test_mqtt/MQTT.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 86497bf5f..21d4a8fa0 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -627,12 +627,14 @@ bool MQTT::isValidConfig(const meshtastic_ModuleConfig_MQTTConfig &config, MQTTC #else const char *warning = "Invalid MQTT config: proxy_to_client_enabled must be enabled on nodes that do not have a network"; LOG_ERROR(warning); +#if !IS_RUNNING_TESTS meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); cn->level = meshtastic_LogRecord_Level_ERROR; cn->time = getValidTime(RTCQualityFromNet); strncpy(cn->message, warning, sizeof(cn->message) - 1); cn->message[sizeof(cn->message) - 1] = '\0'; // Ensure null termination service->sendClientNotification(cn); +#endif return false; #endif } @@ -641,12 +643,14 @@ bool MQTT::isValidConfig(const meshtastic_ModuleConfig_MQTTConfig &config, MQTTC if (defaultServer && parsed.serverPort != PubSubConfig::defaultPort) { const char *warning = "Invalid MQTT config: default server address must not have a port specified"; LOG_ERROR(warning); +#if !IS_RUNNING_TESTS meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); cn->level = meshtastic_LogRecord_Level_ERROR; cn->time = getValidTime(RTCQualityFromNet); strncpy(cn->message, warning, sizeof(cn->message) - 1); cn->message[sizeof(cn->message) - 1] = '\0'; // Ensure null termination service->sendClientNotification(cn); +#endif return false; } return true; diff --git a/test/test_mqtt/MQTT.cpp b/test/test_mqtt/MQTT.cpp index b5b09d97d..29945419b 100644 --- a/test/test_mqtt/MQTT.cpp +++ b/test/test_mqtt/MQTT.cpp @@ -27,6 +27,11 @@ #include #include +#define IS_RUNNING_TESTS 1 +#else +#define IS_RUNNING_TESTS 0 +#endif + namespace { // Minimal router needed to receive messages from MQTT.