basic working

This commit is contained in:
Will Bradley
2025-10-11 21:05:39 -07:00
parent 4767b67460
commit d19c071814
8 changed files with 57 additions and 25 deletions
+7 -9
View File
@@ -88,8 +88,8 @@ class MeshtasticMQTTClient {
try {
const { from, to, channel, id, sender } = payload;
// Extract node ID (convert to hex string if it's a number)
const fromNode = sender || (from ? `!${from.toString(16).padStart(8, '0')}` : null);
// Extract node ID (convert to hex string if it's a number, fallback to sender if none
const fromNode = from ? `!${from.toString(16).padStart(8, '0')}` : sender;
const toNode = to ? `!${to.toString(16).padStart(8, '0')}` : null;
// Handle different message types based on actual JSON structure
@@ -344,18 +344,16 @@ class MeshtasticMQTTClient {
}
// Send a text message
async sendTextMessage(text, channel = 0) {
async sendTextMessage(from, text) {
try {
const message = JSON.stringify({
type: 'text',
text,
channel,
timestamp: Date.now()
from: from,
type: 'sendtext',
payload: text
});
// Publish to the appropriate topic
const baseTopic = config.mqtt.topic.replace('/#', '');
await this.publish(`${baseTopic}/2/json/mqtt`, message);
await this.publish(config.mqtt.pubTopic, message);
return true;
} catch (error) {