add support for T-Beam ESP32 devices, add error logging for a situation where bridge.source is set to tx but tx logging is off.
This commit is contained in:
1 parent
158748d41f
commit
3c7ac9d154
10 files changed
+357
-7
No files matched your search
@@ -49,7 +49,7 @@ MQTTBridge::MQTTBridge(NodePrefs *prefs, mesh::PacketManager *mgr, mesh::RTCCloc
|
||||
_timezone(nullptr), _last_raw_len(0), _last_snr(0), _last_rssi(0), _last_raw_timestamp(0),
|
||||
_analyzer_us_enabled(false), _analyzer_eu_enabled(false), _identity(identity),
|
||||
_analyzer_us_client(nullptr), _analyzer_eu_client(nullptr), _config_valid(false),
|
||||
_last_no_broker_log(0), _dispatcher(nullptr), _radio(nullptr), _board(nullptr), _ms(nullptr) {
|
||||
_last_no_broker_log(0), _last_config_warning(0), _dispatcher(nullptr), _radio(nullptr), _board(nullptr), _ms(nullptr) {
|
||||
|
||||
// Initialize default values
|
||||
strncpy(_origin, "MeshCore-Repeater", sizeof(_origin) - 1);
|
||||
@@ -161,6 +161,9 @@ void MQTTBridge::begin() {
|
||||
MQTT_DEBUG_PRINTLN("Status publishing: enabled=%s, interval=%lu ms",
|
||||
_status_enabled ? "true" : "false", _status_interval);
|
||||
|
||||
// Check for configuration mismatch: bridge.source=tx but mqtt.tx=off
|
||||
checkConfigurationMismatch();
|
||||
|
||||
MQTT_DEBUG_PRINTLN("Origin: %s, IATA: %s", _origin, _iata);
|
||||
MQTT_DEBUG_PRINTLN("Device ID: %s", _device_id);
|
||||
MQTT_DEBUG_PRINTLN("WiFi SSID: %s", _prefs->wifi_ssid);
|
||||
@@ -338,6 +341,22 @@ bool MQTTBridge::isConfigValid(const NodePrefs* prefs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MQTTBridge::checkConfigurationMismatch() {
|
||||
// Check if bridge.source is set to tx (logTx) but mqtt.tx is disabled
|
||||
// This would prevent packet publishing since sendPacket() requires both packets_enabled and tx_enabled
|
||||
if (_prefs->bridge_pkt_src == 0 && _packets_enabled && !_tx_enabled) {
|
||||
unsigned long now = millis();
|
||||
// Always log on first detection, then throttle to every 5 minutes to avoid spam
|
||||
if (_last_config_warning == 0 || (now - _last_config_warning > CONFIG_WARNING_INTERVAL)) {
|
||||
MQTT_DEBUG_PRINTLN("MQTT: Configuration mismatch detected! bridge.source=tx (logTx) but mqtt.tx=off. Packets will not be published. Run 'set bridge.source rx' or 'set mqtt.tx on' to fix.");
|
||||
_last_config_warning = now;
|
||||
}
|
||||
} else {
|
||||
// Configuration is correct, reset warning timer so we log immediately if it becomes wrong again
|
||||
_last_config_warning = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool MQTTBridge::isReady() const {
|
||||
return _initialized && isWiFiConfigValid(_prefs);
|
||||
}
|
||||
@@ -354,6 +373,9 @@ void MQTTBridge::loop() {
|
||||
// Process packet queue
|
||||
processPacketQueue();
|
||||
|
||||
// Periodic configuration check (throttled to avoid spam)
|
||||
checkConfigurationMismatch();
|
||||
|
||||
// Periodic NTP sync (every hour)
|
||||
if (WiFi.status() == WL_CONNECTED && millis() - _last_ntp_sync > 3600000) {
|
||||
syncTimeWithNTP();
|
||||
|
||||
@@ -151,6 +151,8 @@ private:
|
||||
unsigned long _last_analyzer_us_log;
|
||||
unsigned long _last_analyzer_eu_log;
|
||||
static const unsigned long ANALYZER_LOG_INTERVAL = 30000; // Log every 30 seconds max
|
||||
unsigned long _last_config_warning; // Throttle configuration mismatch warnings
|
||||
static const unsigned long CONFIG_WARNING_INTERVAL = 300000; // Log every 5 minutes max
|
||||
|
||||
// Optional pointers for collecting stats internally (set by mesh if available)
|
||||
mesh::Dispatcher* _dispatcher; // For air times and errors
|
||||
@@ -173,6 +175,7 @@ private:
|
||||
void syncTimeWithNTP();
|
||||
Timezone* createTimezoneFromString(const char* tz_string);
|
||||
bool isMQTTConfigValid();
|
||||
void checkConfigurationMismatch(); // Check for bridge.source/mqtt.tx mismatch
|
||||
bool isIATAValid() const; // Check if IATA code is configured
|
||||
|
||||
public:
|
||||
|
||||
Reference in new issue
Block a user