From be243e3b50ae299697dcbbd637c6a1e4b7ae12c1 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Sat, 11 Oct 2025 22:42:33 -0700 Subject: [PATCH] messages appear again --- src/database/queries.js | 2 +- src/mqtt/client.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/database/queries.js b/src/database/queries.js index e9dbc93..a2a7463 100644 --- a/src/database/queries.js +++ b/src/database/queries.js @@ -34,7 +34,7 @@ const nodeQueries = { hardware_model = COALESCE(excluded.hardware_model, hardware_model), role = COALESCE(excluded.role, role), firmware_version = COALESCE(excluded.firmware_version, firmware_version), - last_heard = COALESCE(excluded.last_heard, last_heard), + last_heard = COALESCE(excluded.last_heard, CURRENT_TIMESTAMP), battery_level = COALESCE(excluded.battery_level, battery_level), voltage = COALESCE(excluded.voltage, voltage), channel_utilization = COALESCE(excluded.channel_utilization, channel_utilization), diff --git a/src/mqtt/client.js b/src/mqtt/client.js index 0bbd327..49448bb 100644 --- a/src/mqtt/client.js +++ b/src/mqtt/client.js @@ -92,8 +92,13 @@ class MeshtasticMQTTClient { const fromNode = from ? `!${from.toString(16).padStart(8, '0')}` : sender; const toNode = to ? `!${to.toString(16).padStart(8, '0')}` : null; + // Debug log for Aether channel + if (topic.includes('Aether')) { + logger.info(`Aether message - Type: ${payload.type}, From: ${fromNode}, Channel: ${channel}, Payload: ${JSON.stringify(payload)}`); + } + // Handle different message types based on actual JSON structure - if (payload.type === 'sendtext' && payload.payload) { + if ((payload.type === 'sendtext' || payload.type === 'text') && payload.payload) { this.handleTextMessage(fromNode, toNode, { ...payload, text: typeof payload.payload === 'string' ? payload.payload : payload.payload.text, @@ -140,7 +145,7 @@ class MeshtasticMQTTClient { nodeQueries.upsertNode.run( fromNode, null, null, null, null, null, - new Date().toISOString(), + null, // last_heard - will use CURRENT_TIMESTAMP null, null, null, null, null ); } @@ -173,7 +178,7 @@ class MeshtasticMQTTClient { nodeQueries.upsertNode.run( fromNode, null, null, null, null, null, - new Date().toISOString(), + null, // last_heard - will use CURRENT_TIMESTAMP via COALESCE null, null, null, null, null ); @@ -192,7 +197,7 @@ class MeshtasticMQTTClient { toNode, channel, text, - new Date().toISOString(), + null, // rx_time - let database use CURRENT_TIMESTAMP for created_at rxSnr, rxRssi, hopLimit, @@ -217,7 +222,7 @@ class MeshtasticMQTTClient { null, // hardware_model null, // role null, // firmware_version - new Date().toISOString(), + null, // last_heard - will use CURRENT_TIMESTAMP null, // battery_level null, // voltage null, // channel_utilization @@ -252,7 +257,7 @@ class MeshtasticMQTTClient { data.hardwareModel || data.user?.hwModel || null, data.role || null, data.firmwareVersion || null, - new Date().toISOString(), + null, // last_heard - will use CURRENT_TIMESTAMP null, // battery_level null, // voltage null, // channel_utilization @@ -281,7 +286,7 @@ class MeshtasticMQTTClient { null, // hardware_model null, // role null, // firmware_version - new Date().toISOString(), + null, // last_heard - will use CURRENT_TIMESTAMP metrics.batteryLevel || null, metrics.voltage || null, metrics.channelUtilization || null,